Merge pull request #11898 from SteveCEvans/dps310_coef
[betaflight.git] / .github / workflows / ci.yml
blobde1b32fd076942d5e693dad6e7f28944ec3b9629
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: Get all official build targets
25         id: get-targets
26         run: echo "::set-output name=targets::$(make targets-ci-print | jq -R -c 'split(" ")')"
28       - name: Cache build toolchain
29         uses: actions/cache@v3
30         id: cache-toolchain
31         with:
32           path: tools
33           key: ${{ runner.os }}-${{ hashFiles('make/tools.mk') }}
35       - name: Download and install toolchain
36         if: steps.cache-toolchain.outputs.cache-hit != 'true'
37         run: make arm_sdk_install
39   build:
40     name: Build
41     needs: setup
42     runs-on: ubuntu-22.04
43     strategy:
44       matrix:
45         target: ${{ fromJson(needs.setup.outputs.targets) }}
46     steps:
47       - name: Checkout code
48         uses: actions/checkout@v2
50       - name: Fetch toolchain from cache
51         uses: actions/cache@v3
52         id: cache-toolchain
53         with:
54           path: tools
55           key: ${{ runner.os }}-${{ hashFiles('make/tools.mk') }}
57       - name: Build target (without revision)
58         if: inputs.release_build == true
59         run: make EXTRA_FLAGS=-Werror ${{ matrix.target }}
60         
61       - name: Build target (with revision)
62         if: inputs.release_build == false
63         run: make EXTRA_FLAGS=-Werror ${{ matrix.target }}_rev
65       - name: Publish build artifacts
66         uses: actions/upload-artifact@v3
67         with:
68           name: Assets
69           path: obj/*.hex
70           retention-days: 60
72   test:
73     name: Test
74     runs-on: ubuntu-22.04
75     steps:
76       - uses: actions/checkout@v3
78       - name: Install dependencies
79         run: sudo apt-get install -y libblocksruntime-dev
81       - name: Run sanity checks
82         run: make EXTRA_FLAGS=-Werror checks
84       - name: Run all unit tests
85         run: make EXTRA_FLAGS=-Werror test-all
87   result:
88     name: Complete
89     needs: [build, test]
90     if: ${{ always() }}
91     runs-on: ubuntu-22.04
92     steps:
93       - name: Check build matrix result
94         if: ${{ needs.build.result != 'success' }}
95         run: exit 1
97       - name: Check test result
98         if: ${{ needs.test.result != 'success' }}
99         run: exit 1