From abef8eaa3c025def5ac085560ce9a127376cd208 Mon Sep 17 00:00:00 2001 From: Mathias Rasmussen Date: Mon, 3 Jan 2022 16:48:50 +0100 Subject: [PATCH 1/4] Use GitHub Actions for CI --- .github/workflows/ci.yml | 94 ++++++++++++++++++++++++++++++++++++++++ Makefile | 3 ++ make/tools.mk | 2 +- 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..df08f85768 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,94 @@ +# Builds the Betaflight firmware +# +# After building, artifacts are released to a separate repository. + +name: CI + +on: + push: + branches: + - master + - '*-maintenance' + pull_request: + branches: + - master + - '*-maintenance' + +jobs: + setup: + name: Setup + runs-on: ubuntu-20.04 + outputs: + targets: ${{ steps.get-targets.outputs.targets }} + steps: + - uses: actions/checkout@v2 + + - name: Get all official build targets + id: get-targets + run: echo "::set-output name=targets::$(make targets-ci-print | jq -R -c 'split(" ")')" + + - name: Cache build toolchain + uses: actions/cache@v2 + id: cache-toolchain + with: + path: tools/ + key: ${{ runner.os }}-${{ hashFiles('make/tools.mk') }} + + - name: Download and install toolchain + if: steps.cache-toolchain.outputs.cache-hit != 'true' + run: make arm_sdk_install + + build: + name: Build + needs: setup + runs-on: ubuntu-20.04 + strategy: + matrix: + target: ${{ fromJson(needs.setup.outputs.targets) }} + steps: + - uses: actions/checkout@v2 + + - name: Fetch toolchain from cache + uses: actions/cache@v2 + id: cache-toolchain + with: + path: tools/ + key: ${{ runner.os }}-${{ hashFiles('make/tools.mk') }} + + - name: Build target + run: make EXTRA_FLAGS=-Werror ${{ matrix.target }} + + - name: Publish build artifacts + uses: actions/upload-artifact@v2 + with: + name: firmware + path: obj/*.hex + + test: + name: Test + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies + run: sudo apt-get install -y libblocksruntime-dev + + - name: Run sanity checks + run: make EXTRA_FLAGS=-Werror checks + + - name: Run all unit tests + run: make EXTRA_FLAGS=-Werror test-all + + result: + name: Complete + needs: [build, test] + if: ${{ always() }} + runs-on: ubuntu-20.04 + steps: + - name: Check build matrix result + if: ${{ needs.build.result != 'success' }} + run: exit 1 + + - name: Check test result + if: ${{ needs.test.result != 'success' }} + run: exit 1 diff --git a/Makefile b/Makefile index eb458444f2..5ea154b334 100644 --- a/Makefile +++ b/Makefile @@ -618,6 +618,9 @@ targets: @echo "targets-group-rest: $(words $(GROUP_OTHER_TARGETS)) targets" @echo "total in all groups $(words $(CI_TARGETS)) targets" +targets-ci-print: + @echo $(CI_TARGETS) + ## target-mcu : print the MCU type of the target target-mcu: @echo $(TARGET_MCU) diff --git a/make/tools.mk b/make/tools.mk index 7b65029319..ebf2a55b2b 100644 --- a/make/tools.mk +++ b/make/tools.mk @@ -261,7 +261,7 @@ zip_clean: ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && echo "exists"), exists) ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi- -else ifeq (,$(findstring _install,$(MAKECMDGOALS))) +else ifeq (,$(filter %_install test% clean% %-print checks help, $(MAKECMDGOALS))) GCC_VERSION = $(shell arm-none-eabi-gcc -dumpversion) ifeq ($(GCC_VERSION),) $(error **ERROR** arm-none-eabi-gcc not in the PATH. Run 'make arm_sdk_install' to install automatically in the tools folder of this repo) From 551808c12cd690a69aefa69f71daef14bd333fbf Mon Sep 17 00:00:00 2001 From: J Blackman Date: Fri, 8 Jul 2022 15:02:12 +1000 Subject: [PATCH 2/4] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d005c5b994..5083667470 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: run: make EXTRA_FLAGS=-Werror ${{ matrix.target }}_rev - name: Publish build artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: firmware path: obj/*.hex From 9ffd2df4978549daf45225af6f2fc2ff39c787c7 Mon Sep 17 00:00:00 2001 From: J Blackman Date: Fri, 8 Jul 2022 15:03:33 +1000 Subject: [PATCH 3/4] Update ci.yml --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5083667470..79a9117c06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,8 @@ jobs: matrix: target: ${{ fromJson(needs.setup.outputs.targets) }} steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 - name: Fetch toolchain from cache uses: actions/cache@v2 @@ -64,7 +65,7 @@ jobs: - name: Publish build artifacts uses: actions/upload-artifact@v3 with: - name: firmware + name: Assets path: obj/*.hex retention-days: 60 From 8a7bf514d6cd509caa8c5bbda7e2e034360fd002 Mon Sep 17 00:00:00 2001 From: J Blackman Date: Fri, 8 Jul 2022 23:55:59 +1000 Subject: [PATCH 4/4] Update .github/workflows/ci.yml Co-authored-by: haslinghuis --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79a9117c06..b186fb2118 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: path: tools/ key: ${{ runner.os }}-${{ hashFiles('make/tools.mk') }} - - name: Build target (with revision) + - name: Build target (without revision) if: inputs.release_build == true run: make EXTRA_FLAGS=-Werror ${{ matrix.target }}