1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Merge pull request #11132 from mathiasvr/github-action-build

Use GitHub Actions for CI
This commit is contained in:
J Blackman 2022-07-10 15:39:30 +10:00 committed by GitHub
commit 26a8bb8f39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 13 deletions

View file

@ -1,6 +1,5 @@
# Builds Betaflight Firmware.
#
# After building, artifacts are kept for 7 days.
name: CI
@ -8,28 +7,93 @@ on:
workflow_call:
inputs:
release_build:
description: 'Specifies if it is a debug build or a release build'
description: 'Specifies if it is a build that should include commit hash in hex file names or not'
default: false
required: false
type: boolean
jobs:
build:
name: Build
runs-on: ubuntu-20.04
setup:
name: Setup
runs-on: ubuntu-20.04
outputs:
targets: ${{ steps.get-targets.outputs.targets }}
steps:
- name: Code Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2
- name: Prepare environment
- 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
- name: Execute Build
run: make all
build:
name: Build
needs: setup
runs-on: ubuntu-20.04
strategy:
matrix:
target: ${{ fromJson(needs.setup.outputs.targets) }}
steps:
- name: Checkout code
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 (without revision)
if: inputs.release_build == true
run: make EXTRA_FLAGS=-Werror ${{ matrix.target }}
- name: Build target (with revision)
if: inputs.release_build == false
run: make EXTRA_FLAGS=-Werror ${{ matrix.target }}_rev
- name: Publish build artifacts
uses: actions/upload-artifact@v3
with:
name: Assets
path: ./obj/*.hex
retention-days: 7
path: obj/*.hex
retention-days: 60
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

View file

@ -623,6 +623,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)

View file

@ -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)