2 # Don't enable CI on push, just on PR. If you
3 # are working on the main repo and want to trigger
4 # a CI build submit a draft PR.
18 runs-on: ubuntu-latest
21 id: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
24 - uses: actions/checkout@v4
25 - name: Install dependencies
26 run: sudo apt-get update && sudo apt-get -y install ninja-build
27 - name: Setup environment
29 ACTIONS_ALLOW_UNSECURE_COMMANDS: true
31 # This is the hash of the commit for the PR
32 # when the action is triggered by PR, empty otherwise
33 COMMIT_ID=${{ github.event.pull_request.head.sha }}
34 # This is the hash of the commit when triggered by push
35 # but the hash of refs/pull/<n>/merge, which is different
36 # from the hash of the latest commit in the PR, that's
37 # why we try github.event.pull_request.head.sha first
38 COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
39 BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
40 VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }')
41 echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
42 echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
43 echo "NUM_CORES=$(grep processor /proc/cpuinfo | wc -l)" >> $GITHUB_ENV
44 - uses: actions/cache@v4
47 key: ${{ runner.os }}-downloads-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('**/cmake/*')}}
48 - name: Build targets (${{ matrix.id }})
49 run: mkdir -p build && cd build && cmake -DWARNINGS_AS_ERRORS=ON -DCI_JOB_INDEX=${{ matrix.id }} -DCI_JOB_COUNT=${{ strategy.job-total }} -DBUILD_SUFFIX=${{ env.BUILD_SUFFIX }} -DMAIN_COMPILE_OPTIONS=-pipe -G Ninja .. && ninja -j${{ env.NUM_CORES }} ci
50 - name: Upload artifacts
51 uses: actions/upload-artifact@v4
53 name: matrix-${{ env.BUILD_NAME }}.${{ matrix.id }}
58 runs-on: ubuntu-latest
61 - uses: actions/checkout@v4
62 - name: Setup environment
64 ACTIONS_ALLOW_UNSECURE_COMMANDS: true
66 # This is the hash of the commit for the PR
67 # when the action is triggered by PR, empty otherwise
68 COMMIT_ID=${{ github.event.pull_request.head.sha }}
69 # This is the hash of the commit when triggered by push
70 # but the hash of refs/pull/<n>/merge, which is different
71 # from the hash of the latest commit in the PR, that's
72 # why we try github.event.pull_request.head.sha first
73 COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
74 BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
75 VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }')
76 echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
77 echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
78 echo "NUM_CORES=$(grep processor /proc/cpuinfo | wc -l)" >> $GITHUB_ENV
79 - name: Download artifacts
80 uses: actions/download-artifact@v4
82 pattern: matrix-inav-*
85 - name: Build target list
87 ls -1 binaries/*.hex | cut -d/ -f2 > targets.txt
88 - name: Upload firmware images
89 uses: actions/upload-artifact@v4
91 name: ${{ env.BUILD_NAME }}
93 - name: Upload firmware images
94 uses: actions/upload-artifact@v4
100 runs-on: ubuntu-latest
102 - uses: actions/checkout@v4
103 - name: Install dependencies
104 run: sudo apt-get update && sudo apt-get -y install ninja-build
105 - name: Setup environment
107 ACTIONS_ALLOW_UNSECURE_COMMANDS: true
109 # This is the hash of the commit for the PR
110 # when the action is triggered by PR, empty otherwise
111 COMMIT_ID=${{ github.event.pull_request.head.sha }}
112 # This is the hash of the commit when triggered by push
113 # but the hash of refs/pull/<n>/merge, which is different
114 # from the hash of the latest commit in the PR, that's
115 # why we try github.event.pull_request.head.sha first
116 COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
117 BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
118 VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }')
119 echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
120 echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
121 echo "NUM_CORES=$(grep processor /proc/cpuinfo | wc -l)" >> $GITHUB_ENV
123 run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja -j${{ env.NUM_CORES }}
124 - name: Upload artifacts
125 uses: actions/upload-artifact@v4
127 name: ${{ env.BUILD_NAME }}_SITL-Linux
128 path: ./build_SITL/*_SITL
131 runs-on: macos-latest
133 - uses: actions/checkout@v4
134 - name: Install dependencies
136 brew install cmake ninja ruby
138 - name: Setup environment
140 ACTIONS_ALLOW_UNSECURE_COMMANDS: true
142 # This is the hash of the commit for the PR
143 # when the action is triggered by PR, empty otherwise
144 COMMIT_ID=${{ github.event.pull_request.head.sha }}
145 # This is the hash of the commit when triggered by push
146 # but the hash of refs/pull/<n>/merge, which is different
147 # from the hash of the latest commit in the PR, that's
148 # why we try github.event.pull_request.head.sha first
149 COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
150 BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
151 VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }')
152 echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
153 echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
154 echo "NUM_CORES=$(grep processor /proc/cpuinfo | wc -l)" >> $GITHUB_ENV
157 mkdir -p build_SITL && cd build_SITL
158 cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -G Ninja ..
161 - name: Upload artifacts
162 uses: actions/upload-artifact@v4
164 name: ${{ env.BUILD_NAME }}_SITL-MacOS
165 path: ./build_SITL/*_SITL
168 runs-on: windows-latest
171 shell: C:\tools\cygwin\bin\bash.exe -o igncr '{0}'
173 - uses: actions/checkout@v4
175 uses: egor-tensin/setup-cygwin@v4
177 packages: cmake ruby ninja gcc-g++
178 - name: Setup environment
180 ACTIONS_ALLOW_UNSECURE_COMMANDS: true
182 # This is the hash of the commit for the PR
183 # when the action is triggered by PR, empty otherwise
184 COMMIT_ID=${{ github.event.pull_request.head.sha }}
185 # This is the hash of the commit when triggered by push
186 # but the hash of refs/pull/<n>/merge, which is different
187 # from the hash of the latest commit in the PR, that's
188 # why we try github.event.pull_request.head.sha first
189 COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
190 BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
191 VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }')
192 echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
193 echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
196 run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja -j4
197 - name: Upload artifacts
198 uses: actions/upload-artifact@v4
200 name: ${{ env.BUILD_NAME }}_SITL-WIN
201 path: ./build_SITL/*.exe
206 runs-on: ubuntu-latest
208 - uses: actions/checkout@v4
209 - name: Install dependencies
210 run: sudo apt-get update && sudo apt-get -y install ninja-build
212 run: mkdir -p build && cd build && cmake -DTOOLCHAIN=none -G Ninja .. && ninja check