Dshot RPM Telemetry Refactoring (#13012)
[betaflight.git] / .github / workflows / ci.yml
blob8e6b296cf2b98140bb4bcae66584ec43c5d0d5d8
1 # Builds Betaflight Firmware.
4 name: CI
6 on: 
7   workflow_call:
8     inputs:
9       release_build:
10         description: 'Specifies if it is a build that should include commit hash in hex file names or not'
11         default: false
12         required: false
13         type: boolean
15 jobs:
16   setup:
17     name: Setup
18     runs-on: ubuntu-22.04
19     outputs:
20       targets: ${{ steps.get-targets.outputs.targets }}
21     steps:
22       - uses: actions/checkout@v3
24       - name: Cache build toolchain
25         uses: actions/cache@v3
26         id: cache-toolchain
27         with:
28           path: tools
29           key: ${{ runner.os }}-${{ hashFiles('mk/tools.mk') }}
31       - name: Download and install toolchain
32         if: steps.cache-toolchain.outputs.cache-hit != 'true'
33         run: make arm_sdk_install
35       - name: Hydrate configuration
36         id: get-config
37         run: make configs
39       - name: Get all official build targets
40         id: get-targets
41         run: echo "targets=$(make targets-ci-print | jq -R -c 'split(" ")')" >> $GITHUB_OUTPUT
43   build:
44     name: Build
45     needs: setup
46     runs-on: ubuntu-22.04
47     strategy:
48       matrix:
49         target: ${{ fromJson(needs.setup.outputs.targets) }}
50     steps:
51       - name: Checkout code
52         uses: actions/checkout@v3
54       - name: Fetch toolchain from cache
55         uses: actions/cache@v3
56         id: cache-toolchain
57         with:
58           path: tools
59           key: ${{ runner.os }}-${{ hashFiles('mk/tools.mk') }}
61       - name: Hydrate configuration
62         id: get-config
63         run: make configs
65       - name: Build target (without revision)
66         if: inputs.release_build == true
67         run: make EXTRA_FLAGS=-Werror ${{ matrix.target }}
69       - name: Build target (with revision)
70         if: inputs.release_build == false
71         run: make EXTRA_FLAGS=-Werror ${{ matrix.target }}_rev
73       - name: Publish build artifacts
74         uses: actions/upload-artifact@v3
75         with:
76           name: Assets
77           path: obj/*.hex
78           retention-days: 60
80   test:
81     name: Test
82     runs-on: ubuntu-22.04
83     steps:
84       - uses: actions/checkout@v3
86       - name: Install dependencies
87         run: sudo apt-get install -y libblocksruntime-dev clang-12
89       - name: Run sanity checks
90         run: make EXTRA_FLAGS=-Werror checks
92       - name: Run all unit tests
93         run: make EXTRA_FLAGS=-Werror test-all
95   result:
96     name: Complete
97     needs: [build, test]
98     if: ${{ always() }}
99     runs-on: ubuntu-22.04
100     steps:
101       - name: Check build matrix result
102         if: ${{ needs.build.result != 'success' }}
103         run: exit 1
105       - name: Check test result
106         if: ${{ needs.test.result != 'success' }}
107         run: exit 1