Skip to content

Commit d47f53e

Browse files
committed
github: collect test warnings
Collect all warning messages from the build run and add them to the CI run summary.
1 parent c10e060 commit d47f53e

File tree

1 file changed

+81
-3
lines changed

1 file changed

+81
-3
lines changed

Diff for: .github/workflows/package_core.yml

+81-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
path: ${{ env.CORE_ARTIFACT }}.tar.bz2
6161

6262
test-core:
63-
name: Test arduino:zephyr:${{ matrix.board }}
63+
name: Test ${{ matrix.board }} board
6464
runs-on: ubuntu-latest
6565
needs: package-core
6666
strategy:
@@ -69,6 +69,7 @@ jobs:
6969
fail-fast: false
7070
env:
7171
FQBN: arduino:zephyr:${{ matrix.board }}
72+
REPORT_FILE: arduino-zephyr-${{ matrix.board }}.json
7273
steps:
7374
- uses: actions/download-artifact@v4
7475
with:
@@ -83,8 +84,8 @@ jobs:
8384
mkdir Blink/
8485
wget -nv https://raw.githubusercontent.com/arduino/arduino-examples/refs/heads/main/examples/01.Basics/Blink/Blink.ino -P Blink/
8586
86-
- name: Compile Blink for ${{ env.FQBN }}
87-
uses: arduino/compile-sketches@main
87+
- name: Compile Blink for ${{ matrix.board }}
88+
uses: pillo79/compile-sketches@main
8889
with:
8990
fqbn: ${{ env.FQBN }}
9091
platforms: |
@@ -96,3 +97,80 @@ jobs:
9697
sketch-paths: Blink
9798
verbose: 'false'
9899
enable-deltas-report: 'false'
100+
enable-warnings-report: 'true'
101+
enable-warnings-log: 'true'
102+
103+
- name: Get job ID
104+
id: job_id
105+
uses: actions/github-script@main
106+
with:
107+
script: |
108+
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({
109+
owner: context.repo.owner,
110+
repo: context.repo.repo,
111+
run_id: context.runId
112+
});
113+
const job_name = `Test ${{ matrix.board }} board`
114+
return workflow_run.jobs.find((job) => job.name === job_name).id;
115+
116+
- name: Prepare log
117+
run: |
118+
sed -i -e 's!/home/runner/.arduino15/packages/arduino/hardware/zephyr/[^/]*/!!g' sketches-reports/${REPORT_FILE}
119+
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/
120+
121+
- uses: actions/upload-artifact@v4
122+
with:
123+
name: test-report-${{ needs.package-core.outputs.CORE_TAG }}-${{ matrix.board }}
124+
path: sketches-reports/*
125+
126+
collect-logs:
127+
name: Collect logs
128+
runs-on: ubuntu-latest
129+
needs:
130+
- package-core
131+
- test-core
132+
if: ${{ !cancelled() && needs.package-core.result == 'success' }}
133+
env:
134+
BOARD_NAMES: ${{ needs.package-core.outputs.BOARD_NAMES }}
135+
steps:
136+
- uses: actions/download-artifact@v4
137+
with:
138+
path: .
139+
pattern: test-report-*
140+
merge-multiple: true
141+
142+
- run: |
143+
echo "### Core test results:" >> "$GITHUB_STEP_SUMMARY"
144+
for BOARD in $(echo $BOARD_NAMES | jq -cr '.[]'); do
145+
FQBN="arduino:zephyr:$BOARD"
146+
REPORT_FILE="arduino-zephyr-$BOARD.json"
147+
if [ ! -f $REPORT_FILE ]; then
148+
echo ":x: $BOARD - No report found?" >> "$GITHUB_STEP_SUMMARY"
149+
else
150+
REPORT=$(jq -cr '.boards[0].sketches[0]' $REPORT_FILE)
151+
JOB_ID=$(echo $REPORT | jq -cr '.job_id')
152+
JOB_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${JOB_ID}#step:5:2"
153+
if ! $(echo $REPORT | jq -cr '.compilation_success') ; then
154+
echo ":x: [$BOARD]($JOB_URL) - **Build failed**" >> "$GITHUB_STEP_SUMMARY"
155+
else
156+
WARNINGS=$(echo $REPORT | jq -cr '.warnings.current.absolute // 0')
157+
if [ $WARNINGS -eq 0 ]; then
158+
echo ":white_check_mark: [$BOARD]($JOB_URL) - Build successful" >> "$GITHUB_STEP_SUMMARY"
159+
else
160+
echo "<details><summary>:warning: <a href=\"$JOB_URL\">$BOARD</a> - $WARNINGS warnings:</summary>" >> "$GITHUB_STEP_SUMMARY"
161+
echo >> "$GITHUB_STEP_SUMMARY"
162+
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY"
163+
echo $REPORT | jq -cr '.warnings_log[]' >> "$GITHUB_STEP_SUMMARY"
164+
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY"
165+
echo >> "$GITHUB_STEP_SUMMARY"
166+
echo "</details>" >> "$GITHUB_STEP_SUMMARY"
167+
fi
168+
fi
169+
fi
170+
done
171+
172+
- name: Clean up intermediate artifacts
173+
uses: geekyeggo/[email protected]
174+
with:
175+
name: test-report-*
176+
failOnError: false

0 commit comments

Comments
 (0)