diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..e44b86089 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,11 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/ubuntu/.devcontainer/base.Dockerfile + +# [Choice] Ubuntu version: bionic, focal +ARG VARIANT="focal" +FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} + +# [Optional] Uncomment this section to install additional OS packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install python3-distutils python3-pip +RUN pip3 install platformio meshtastic adafruit-nrfutil +RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip -O /tmp/protoc.zip && cd /tmp && unzip protoc.zip && chmod a+x bin/protoc && cp bin/protoc /usr/local/bin diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..e0a284e88 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/ubuntu +{ + "name": "Ubuntu", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version: focal, bionic + "args": { "VARIANT": "focal" } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "platformio.platformio-ide", + "xaver.clang-format" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "uname -a", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + + "postCreateCommand": "git submodule update --init" +} \ No newline at end of file diff --git a/.github/actions/initbuild/action.yml b/.github/actions/initbuild/action.yml new file mode 100644 index 000000000..b852d0a6c --- /dev/null +++ b/.github/actions/initbuild/action.yml @@ -0,0 +1,39 @@ +name: 'Common init' + +# WARNING due to https://github.com/actions/runner/issues/646 +# this code can't work - must copy and paste into workflows for now because 'uses' is not supported +runs: + using: "composite" + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Cache python libs + uses: actions/cache@v1 + id: cache-pip # needed in if test + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip + + - name: Upgrade python tools + # We actually want to run this every time + # if: steps.cache-pip.outputs.cache-hit != 'true' + run: | + python -m pip install --upgrade pip + pip install -U platformio meshtastic adafruit-nrfutil + + # Don't cache for now because I want to be lazy with portuino updates githashes + # - name: Cache platformio + # uses: actions/cache@v1 + # id: cache-platformio # needed in if test + # with: + # path: ~/.platformio + # key: ${{ runner.os }}-platformio + + - name: Upgrade platformio + run: | + pio upgrade + + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 8b7b4592c..9ef8f77c6 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,7 +7,7 @@ is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc... - Please do not check in files that don't have real changes - Please do not reformat lines that you didn't have to change the code on -- We recommend using the [Visual Studio Code](https://platformio.org/install/ide?install=vscode) editor, +- We recommend using the [Visual Studio Code](https://platformio.org/install/ide?install=vscode) editor and the 'clang-format' extension, because automatically follows our indentation rules and it's auto reformatting will not cause spurious changes to lines. - If your PR fixes a bug, mention "fixes #bugnum" somewhere in your pull request description. - If your other co-developers have comments on your PR please tweak as needed. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 585775e48..9b1424419 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,36 +1,86 @@ name: Continuous Integration on: - - push - - pull_request + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ master ] + pull_request: + branches: [ master ] jobs: - setup: + # setup: + # runs-on: ubuntu-latest + # steps: + + # - name: Startup + # run: echo "No action setup currently needed, skipping..." + + ci-build: + # needs: setup runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: true - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - name: Install Platform IO - run: | - python -m pip install --upgrade pip - pip install -U platformio - - name: Install extra python tools - run: | - pip install -U adafruit-nrfutil - - name: Install libs needed for linux build - run: | - sudo apt install -y libpsocksxx-dev - - name: Build for tbeam - run: platformio run -e tbeam - - name: Build for heltec - run: platformio run -e heltec - - name: Build for lora-relay-v1 - run: platformio run -e lora-relay-v1 - # Turn off linux for now - name: Build for native - run: platformio run -e native + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Cache python libs + uses: actions/cache@v1 + id: cache-pip # needed in if test + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip + + #- name: Install linux apt packages + # run: | + # sudo apt-get install -y libgpiod-dev + + - name: Upgrade python tools + # We actually want to run this every time + # if: steps.cache-pip.outputs.cache-hit != 'true' + run: | + python -m pip install --upgrade pip + pip install -U platformio meshtastic adafruit-nrfutil + + # - name: Cache platformio + # uses: actions/cache@v1 + # id: cache-platformio # needed in if test + # with: + # path: ~/.platformio + # key: ${{ runner.os }}-platformio + + - name: Upgrade platformio + run: | + pio upgrade + + # We now run integration test before other build steps (to quickly see runtime failures) + - name: Build for native + run: platformio run -e native + - name: Integration test + run: | + .pio/build/native/program & + sleep 20 # 5 seconds was not enough + echo "Simulator started, launching python test..." + python3 -c 'from meshtastic.test import testSimulator; testSimulator()' + + # - name: Build for tbeam + # run: platformio run -e tbeam + # - name: Build for heltec + # run: platformio run -e heltec + # - name: Build for wisblock RAK4631 + # run: platformio run -e rak4631 + + - name: Build everything + run: bin/build-all.sh + + - name: Store release zip as an artifact + uses: actions/upload-artifact@v2 + with: + name: built + path: release/archive/firmware-*.zip + retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..470614817 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,80 @@ +name: Make Release +on: + # Can optionally take parameters from the github UI, more info here https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/#:~:text=You%20can%20now%20create%20workflows,the%20workflow%20is%20run%20on. + # workflow_dispatch: + # inputs: + + # Only want to be run if a new tag starting with v is pushed. + push: + branches: + - "!*" + tags: + - "v1*" + +jobs: + release-build: + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + # get github branch and tag names as ${{ steps.branch_name.outputs.SOURCE_TAG }} + - name: Branch name + id: branch_name + run: | + echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/} + echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/} + echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + # Note: we don't use caches on release builds because we don't want to accidentally not have a virgin build machine + + - name: Upgrade python tools + # We actually want to run this every time + # if: steps.cache-pip.outputs.cache-hit != 'true' + run: | + python -m pip install --upgrade pip + pip install -U platformio meshtastic adafruit-nrfutil + + - name: Upgrade platformio + run: | + pio upgrade + + # Will be available in steps.version.outputs.version + - name: Get version string + run: echo "::set-output name=version::$(./bin/buildinfo.py long)" + id: version + + - name: Build everything + run: bin/build-all.sh + + - name: Create release + uses: actions/create-release@v1 + id: create_release + with: + draft: true + prerelease: true + release_name: ${{ steps.version.outputs.version }} alpha + tag_name: ${{ steps.branch_name.outputs.SOURCE_TAG }} + # was ${{ github.ref }} + body: | + Autogenerated by github action, developer should edit as required before publishing... + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Add artifact to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: release/archive/firmware-${{ steps.version.outputs.version }}.zip + asset_name: firmware-${{ steps.version.outputs.version }}.zip + asset_content_type: application/zip \ No newline at end of file diff --git a/.gitignore b/.gitignore index d250737cb..eeb1bcb09 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ main/credentials.h !.vscode/extensions.json *.code-workspace +.idea/workspace.xml + .DS_Store Thumbs.db .autotools @@ -19,4 +21,5 @@ Thumbs.db nanopb* flash.uf2 cmake-build* +__pycache__ diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 1381bb27a..000000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1615788661896 - - - - - - - - - - - - - file://$PROJECT_DIR$/src/mesh/StreamAPI.cpp - 20 - - - file://$PROJECT_DIR$/src/mesh/wifi/WiFiServerAPI.cpp - 53 - - - - - - -