6666 - build-env
6767 env :
6868 CCACHE_IGNOREOPTIONS : -specs=*
69- OUTPUT_ARTIFACT : binaries- ${{ matrix.board }}-${{ needs.build-env.outputs.CORE_HASH }}
69+ ARTIFACT_TAG : ${{ needs.build-env.outputs.CORE_HASH }}-${{ matrix.board }}
7070 strategy :
7171 matrix :
7272 include :
9090 - name : Build loader
9191 shell : bash
9292 run : |
93- if ! ./extra/build.sh ${{ matrix.board }} 2> >(tee error.log) ; then
93+ if ! ./extra/build.sh ${{ matrix.board }} 1> >(tee output.log) 2> >(tee error.log) ; then
9494 echo "### :x: ${{ matrix.board }} (\`${{ matrix.variant }}\`) build errors" > $GITHUB_STEP_SUMMARY
9595 echo >> $GITHUB_STEP_SUMMARY
9696 echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
@@ -99,21 +99,35 @@ jobs:
9999 exit 1
100100 fi
101101
102+ # extract the memory usage table (from the header to the first non-% line)
103+ cat output.log | sed -n '/^Memory region/,/^[^%]*$/p' | head -n -1 \
104+ | awk 'BEGIN {split("B KB MB GB", u); for(i in u) m[u[i]]=1024^(i-1)} /:/ {print "[\"" $1 "\"," $2*m[$3] "," $4*m[$5] "]"}' \
105+ | sort | jq -s > firmwares/zephyr-${{ matrix.variant }}.meminfo
106+
102107 - name : Package board binaries
103108 if : ${{ !cancelled() }}
104109 run : |
105110 tar chf - \
106111 firmwares/*${{ matrix.variant }}* \
107112 variants/${{ matrix.variant }}/ \
108113 ${{ (job.status == 'failure') && format('build/{0}/', matrix.variant) }} \
109- | zstd > ${OUTPUT_ARTIFACT }.tar.zstd
114+ | zstd > binaries-${ARTIFACT_TAG }.tar.zstd
110115
111116 - name : Archive board binaries
112117 if : ${{ !cancelled() }}
113118 uses : actions/upload-artifact@v4
114119 with :
115- name : ${{ format('{0}{1}', (job.status == 'failure') && 'failed-' || '', env.OUTPUT_ARTIFACT) }}
116- path : ${{ env.OUTPUT_ARTIFACT }}.tar.zstd
120+ name : ${{ format('{0}binaries-{1}', (job.status == 'failure') && 'failed-' || '', env.ARTIFACT_TAG) }}
121+ path : binaries-${{ env.ARTIFACT_TAG }}.tar.zstd
122+
123+ - name : Archive board memory report
124+ if : ${{ !cancelled() }}
125+ uses : actions/upload-artifact@v4
126+ with :
127+ name : mem-report-${{ env.ARTIFACT_TAG }}
128+ path : |
129+ firmwares/zephyr-${{ matrix.variant }}.meminfo
130+ firmwares/zephyr-${{ matrix.variant }}.config
117131
118132 package-core :
119133 name : Package ${{ matrix.artifact }}
@@ -122,6 +136,7 @@ jobs:
122136 - build-env
123137 - build-board
124138 env :
139+ ALL_BOARD_DATA : ${{ needs.build-env.outputs.ALL_BOARD_DATA }}
125140 CORE_ARTIFACT : ArduinoCore-${{ matrix.artifact }}-${{ needs.build-env.outputs.CORE_HASH }}
126141 CORE_TAG : ${{ needs.build-env.outputs.CORE_TAG }}
127142 strategy :
@@ -168,7 +183,6 @@ jobs:
168183 runs-on : ubuntu-latest
169184 needs :
170185 - package-core
171- if : always()
172186 steps :
173187 - uses : geekyeggo/delete-artifact@v5.1.0
174188 with :
@@ -193,8 +207,17 @@ jobs:
193207 PLAT : arduino:${{ matrix.subarch }}
194208 FQBN : arduino:${{ matrix.subarch }}:${{ matrix.board }}
195209 CORE_ARTIFACT : ArduinoCore-${{ matrix.artifact }}-${{ needs.build-env.outputs.CORE_HASH }}
210+ ARTIFACT_TAG : ${{ needs.build-env.outputs.CORE_HASH }}-${{ matrix.board }}
196211 if : ${{ !cancelled() && needs.build-env.result == 'success' }}
197212 steps :
213+ - uses : actions/checkout@v4
214+ with :
215+ fetch-depth : 0
216+ persist-credentials : false
217+ sparse-checkout : |
218+ extra/ci_test_list.sh
219+ extra/artifacts/
220+
198221 - uses : actions/download-artifact@v4
199222 with :
200223 name : ${{ env.CORE_ARTIFACT }}
@@ -204,31 +227,33 @@ jobs:
204227 tar xf ${CORE_ARTIFACT}.tar.bz2 # will create ArduinoCore-zephyr/
205228 echo "REPORT_FILE=$(echo ${FQBN} | tr ':' '-').json" >> $GITHUB_ENV
206229
207- - name : Create Blink sketch
230+ - name : Get test sketches
208231 run : |
209- mkdir Blink/
210- wget -nv https://raw.githubusercontent.com/arduino/arduino-examples/refs/heads/main/examples/01.Basics/Blink/Blink.ino -P Blink/
232+ # sets ALL_TESTS and ALL_LIBRARIES env vars
233+ extra/ci_test_list.sh ${{ matrix.artifact }} ${{ matrix.variant }}
211234
212- - name : Compile Blink for ${{ matrix.board }}
213- uses : pillo79/compile-sketches@main
235+ - name : Compile tests for ${{ matrix.board }}
236+ uses : pillo79/compile-sketches@next
214237 with :
215238 fqbn : ${{ env.FQBN }}
216239 platforms : |
217- # Use Board Manager to install the latest release of Arduino Zephyr Boards to get the toolchain
218- - name: "arduino:zephyr"
219- source-url: "https://downloads.arduino.cc/packages/package_zephyr_index.json"
240+ # Use Board Manager version first, to install the toolchain
241+ - name: ${{ env.PLAT }}
220242 - name: ${{ env.PLAT }}
221243 source-path: "ArduinoCore-zephyr"
222- sketch-paths : Blink
244+ sketch-paths : |
245+ ${{ env.ALL_TESTS }}
246+ libraries : |
247+ ${{ env.ALL_LIBRARIES }}
223248 cli-compile-flags : |
224249 - '--build-property'
225250 - 'compiler.c.extra_flags=-Wno-type-limits -Wno-missing-field-initializers'
226251 - '--build-property'
227252 - 'compiler.cpp.extra_flags=-Wno-type-limits -Wno-missing-field-initializers'
228253 verbose : ' false'
229254 enable-deltas-report : ' false'
230- enable-warnings -report : ' true'
231- enable-warnings-log : ' true'
255+ enable-issues -report : ' true'
256+ always-succeed : ' true'
232257
233258 - name : Get job ID
234259 id : job_id
@@ -247,17 +272,18 @@ jobs:
247272 - name : Prepare log
248273 if : ${{ success() || failure() }}
249274 run : |
275+ [ ! -f sketches-reports/${REPORT_FILE} ] && mkdir -p sketches-reports && echo "{}" > sketches-reports/${REPORT_FILE}
250276 sed -i -e 's!/home/runner/.arduino15/packages/arduino/hardware/zephyr/[^/]*/!!g' sketches-reports/${REPORT_FILE}
251- cat sketches-reports/${REPORT_FILE} | jq -cr ".boards[0].sketches[0] += { job_id: ${{ steps.job_id.outputs.result }} }" > ${REPORT_FILE} && mv ${REPORT_FILE} sketches-reports/
277+ cat sketches-reports/${REPORT_FILE} | jq -cr ". += { job_id: ${{ steps.job_id.outputs.result }} }" > ${REPORT_FILE} && mv ${REPORT_FILE} sketches-reports/
252278
253279 - uses : actions/upload-artifact@v4
254280 if : ${{ success() || failure() }}
255281 with :
256- name : test-report-${{ needs.build- env.outputs.CORE_TAG }}-${{ matrix.board }}
282+ name : test-report-${{ env.ARTIFACT_TAG }}
257283 path : sketches-reports/*
258284
259- collect -logs :
260- name : Collect logs
285+ inspect -logs :
286+ name : Analyze logs
261287 runs-on : ubuntu-latest
262288 needs :
263289 - build-env
@@ -267,66 +293,38 @@ jobs:
267293 env :
268294 ALL_BOARD_DATA : ${{ needs.build-env.outputs.ALL_BOARD_DATA }}
269295 steps :
296+ - uses : actions/checkout@v4
297+ with :
298+ fetch-depth : 0
299+ persist-credentials : false
300+
270301 - uses : actions/download-artifact@v4
271302 with :
272303 path : .
273- pattern : test -report-*
304+ pattern : " * -report-*"
274305 merge-multiple : true
275306
276- - run : |
277- ARTIFACTS=$(jq -cr 'map(.artifact) | unique | .[]' <<< ${ALL_BOARD_DATA}) # this avoids the 'zephyr' artifact
278- for artifact in $ARTIFACTS ; do
279- echo "### \`$artifact\` test results:" >> "$GITHUB_STEP_SUMMARY"
280- jq -c "map(select(.artifact == \"$artifact\")) | .[]" <<< ${ALL_BOARD_DATA} | while read -r BOARD_DATA; do
281- BOARD=$(echo $BOARD_DATA | jq -cr '.board')
282- VARIANT=$(echo $BOARD_DATA | jq -cr '.variant')
283- SUBARCH=$(echo $BOARD_DATA | jq -cr '.subarch')
284- FQBN="arduino:$SUBARCH:$BOARD"
285- REPORT_FILE="$(echo $FQBN | tr ':' '-').json"
286- if [ ! -f $REPORT_FILE ]; then
287- echo "* :x: $BOARD (\`$VARIANT\`) - No report found?" >> "$GITHUB_STEP_SUMMARY"
288- else
289- REPORT=$(jq -cr '.boards[0].sketches[0]' $REPORT_FILE)
290- JOB_ID=$(echo $REPORT | jq -cr '.job_id')
291- JOB_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${JOB_ID}#step:5:2"
292- if ! $(echo $REPORT | jq -cr '.compilation_success') ; then
293- echo "* :x: [$BOARD]($JOB_URL) (\`$VARIANT\`) - Build failed" >> "$GITHUB_STEP_SUMMARY"
294- else
295- WARNINGS=$(echo $REPORT | jq -cr '.warnings.current.absolute // 0')
296- if [ $WARNINGS -eq 0 ]; then
297- echo "* :white_check_mark: $BOARD (\`$VARIANT\`) - Build successful" >> "$GITHUB_STEP_SUMMARY"
298- else
299- echo >> "$GITHUB_STEP_SUMMARY"
300- echo "<details><summary> :warning: <a href=\"$JOB_URL\">$BOARD</a> (<tt>$VARIANT</tt>) - $WARNINGS warnings:</summary>" >> "$GITHUB_STEP_SUMMARY"
301- echo >> "$GITHUB_STEP_SUMMARY"
302- echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY"
303- echo $REPORT | jq -cr '.warnings_log[]' >> "$GITHUB_STEP_SUMMARY"
304- echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY"
305- echo >> "$GITHUB_STEP_SUMMARY"
306- echo "</details>" >> "$GITHUB_STEP_SUMMARY"
307- echo >> "$GITHUB_STEP_SUMMARY"
308- fi
309- fi
310- fi
311- done
312- done
307+ # Collect and summarize logs, will fail the step if any test failed
308+ - run : extra/ci_inspect_logs.py > $GITHUB_STEP_SUMMARY
313309
314310 - name : Clean up intermediate artifacts
315311 uses : geekyeggo/delete-artifact@v5.1.0
316312 with :
317- name : test-report-*
313+ name : |
314+ mem-report-*
315+ test-report-*
318316 failOnError : false
319317
320318 verify-core :
321319 runs-on : ubuntu-latest
322- if : cancelled() || contains(needs.*.result, 'failure')
323320 needs :
324321 - build-env
325322 - package-core
326- - test-core
323+ - inspect-logs
324+ if : ${{ !cancelled() }}
327325 steps :
328- - name : Notify failure
329- run : exit 1
326+ - name : CI run result
327+ run : exit ${{ contains(needs.*.result, 'failure') && '1' || '0' }}
330328
331329 publish-core :
332330 name : Publish core
@@ -335,7 +333,7 @@ jobs:
335333 needs :
336334 - build-env
337335 - package-core
338- - test-core
336+ - inspect-logs
339337 environment : production
340338 permissions :
341339 id-token : write
@@ -365,7 +363,7 @@ jobs:
365363 needs :
366364 - build-env
367365 - package-core
368- - test-core
366+ - inspect-logs
369367 env :
370368 CORE_TAG : ${{ needs.build-env.outputs.CORE_TAG }}
371369 CORE_HASH : ${{ needs.build-env.outputs.CORE_HASH }}
0 commit comments