diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5bbaaa5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,104 @@ +name: Build + +on: + pull_request: + push: + branches: + - main + +jobs: + build: + name: Lint, build, and test firmware code + runs-on: ubuntu-latest + + steps: + - name: Install dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -qq eatmydata + sudo eatmydata apt-get install -qq \ + ninja-build \ + wget \ + clang \ + clang-tools \ + clang-tidy \ + clang-format \ + libasound2-dev + echo "~/.local/bin" >> $GITHUB_PATH + + - name: Cache ~/.local + id: cache-local + uses: actions/cache@v3 + with: + path: ~/.local + key: cache-local + + - name: Install ARM embedded toolchain + if: steps.cache-local.outputs.cache-hit != 'true' + run: | + mkdir -p ~/.local + wget --no-verbose "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz?rev=e434b9ea4afc4ed7998329566b764309&hash=CA590209F5774EE1C96E6450E14A3E26" + tar -C ~/.local --strip-components=1 -xaf arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Show versions + run: | + ninja --version + python3 --version + clang-format --version + clang-tidy --version + gcc --version + arm-none-eabi-gcc --version + + - name: Checkout code + uses: actions/checkout@v4 + # Required so that build_info.mk can properly construct a buildinfo + # string. + with: + fetch-depth: 2 + + - name: Install firmware build dependencies + run: | + python3.12 -m pip install wheel + python3.12 -m pip install -r firmware/requirements.txt + + - name: Check firmware code formatting + run: | + cd firmware + python3.12 configure.py --skip-checks --no-generators --enable-tidy + ninja format + git diff --color --exit-code src + + - name: Lint firmware + run: | + cd firmware + clang-tidy -dump-config + ninja tidy + + - name: Build firmware + run: | + cd firmware + python3.12 configure.py --no-format + ninja + + - name: Upload firmware artifacts + - uses: actions/upload-artifact@v4 + with: + name: gemini-firmware.elf + path: firmware/build/gemini-firmware.* + if-no-files-found: error + + - name: Build test runner + run: | + cd firmware/tests + python3 configure.py + ninja + + - name: Run tests + run: | + cd firmware/tests + build/gemini-firmware-test diff --git a/.github/workflows/firmware.yml b/.github/workflows/firmware.yml deleted file mode 100644 index 2de60f5..0000000 --- a/.github/workflows/firmware.yml +++ /dev/null @@ -1,146 +0,0 @@ -name: Firmware - -on: - pull_request: - push: - branches: - - main - - v2 - -jobs: - lint: - name: Lint firmware code - runs-on: ubuntu-20.04 - - steps: - - name: Install dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -qq eatmydata - sudo eatmydata apt-get install -qq ninja-build clang-tidy clang-format libasound2-dev - - - name: Set up Python 3.9 - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - - name: Versions - run: | - ninja --version - python3 --version - clang-format --version - clang-tidy --version - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install firmware/requirements.txt - run: | - python3 -m pip install wheel - python3 -m pip install -r firmware/requirements.txt - - - name: Run format and error if anything changes - run: | - cd firmware - python3 configure.py --skip-checks --no-generators --enable-tidy - ninja format - git diff --color --exit-code src - - - name: Run tidy - run: | - cd firmware - clang-tidy -dump-config - ninja tidy - - build: - name: Build firmware code - runs-on: ubuntu-20.04 - - steps: - - name: Install dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -qq eatmydata - sudo eatmydata apt-get install -qq ninja-build wget libasound2-dev - - - name: Install ARM embedded toolchain - # TODO: Put this file on static.winterbloom.com - run: | - wget --no-verbose https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 - sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 - - - name: Set up Python 3.9 - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - - name: Versions - run: | - ninja --version - python3 --version - arm-none-eabi-gcc --version - - - name: Checkout code - uses: actions/checkout@v2 - # Required so that build_info.mk can properly construct a buildinfo - # string. - with: - fetch-depth: 0 - - - name: Install firmware/requirements.txt - run: | - python3 -m pip install wheel - python3 -m pip install -r firmware/requirements.txt - - - name: Run build - run: | - cd firmware - python3 configure.py --no-format - ninja - - - uses: actions/upload-artifact@v2 - with: - name: gemini-firmware.elf - path: firmware/build/gemini-firmware.elf - if-no-files-found: error - - test: - name: Run tests - runs-on: ubuntu-20.04 - - steps: - - name: Install dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -qq eatmydata - sudo eatmydata apt-get install -qq ninja-build wget clang clang-tools libasound2-dev - - - name: Set up Python 3.9 - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - - name: Versions - run: | - ninja --version - python3 --version - gcc --version - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install firmware/requirements.txt - run: | - python3 -m pip install wheel - python3 -m pip install -r firmware/requirements.txt - - - name: Build test runner - run: | - cd firmware/tests - python3 configure.py - ninja - - - name: Run tests - run: | - cd firmware/tests - build/gemini-firmware-test