Skip to content

Commit cd95e40

Browse files
authored
ci(report): Add runtime tests report (#10764)
1 parent 978b441 commit cd95e40

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

.github/scripts/tests_run.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ function run_test {
1111
local error=0
1212
local sdkconfig_path
1313
local extra_args
14+
local test_type
1415

1516
sketchdir=$(dirname "$sketch")
1617
sketchname=$(basename "$sketchdir")
18+
test_type=$(basename "$(dirname "$sketchdir")")
1719

1820
if [ "$options" -eq 0 ] && [ -f "$sketchdir"/ci.json ]; then
1921
len=$(jq -r --arg target "$target" '.fqbn[$target] | length' "$sketchdir"/ci.json)
@@ -113,14 +115,14 @@ function run_test {
113115
rm "$sketchdir"/diagram.json 2>/dev/null || true
114116

115117
result=0
116-
printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "${extra_args[*]@Q}"
117-
bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" ${extra_args[*]@Q}; exit \$?" || result=$?
118+
printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" -o junit_suite_name=%s_%s_%s_%s%s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$test_type" "$platform" "$target" "$sketchname" "$i" "${extra_args[*]@Q}"
119+
bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" -o junit_suite_name=${test_type}_${platform}_${target}_${sketchname}${i} ${extra_args[*]@Q}; exit \$?" || result=$?
118120
printf "\n"
119121
if [ $result -ne 0 ]; then
120122
result=0
121123
printf "\033[95mRetrying test: %s -- Config: %s\033[0m\n" "$sketchname" "$i"
122-
printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "${extra_args[*]@Q}"
123-
bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" ${extra_args[*]@Q}; exit \$?" || result=$?
124+
printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" -o junit_suite_name=%s_%s_%s_%s%s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$test_type" "$platform" "$target" "$sketchname" "$i" "${extra_args[*]@Q}"
125+
bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" -o junit_suite_name=${test_type}_${platform}_${target}_${sketchname}${i} ${extra_args[*]@Q}; exit \$?" || result=$?
124126
printf "\n"
125127
if [ $result -ne 0 ]; then
126128
printf "\033[91mFailed test: %s -- Config: %s\033[0m\n\n" "$sketchname" "$i"

.github/workflows/tests_results.yml

+33-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
original_sha=$(cat ./artifacts/parent-artifacts/sha.txt)
4242
original_ref=$(cat ./artifacts/parent-artifacts/ref.txt)
4343
original_conclusion=$(cat ./artifacts/parent-artifacts/conclusion.txt)
44+
original_run_id=$(cat ./artifacts/parent-artifacts/run_id.txt)
4445
4546
# Sanitize the values to avoid security issues
4647
@@ -59,17 +60,27 @@ jobs:
5960
# Conclusion: Allow alphabetical characters and underscores
6061
original_conclusion=$(echo "$original_conclusion" | tr -cd '[:alpha:]_')
6162
63+
# Run ID: Allow numeric characters
64+
original_run_id=$(echo "$original_run_id" | tr -cd '[:digit:]')
65+
6266
echo "original_event=$original_event" >> $GITHUB_ENV
6367
echo "original_action=$original_action" >> $GITHUB_ENV
6468
echo "original_sha=$original_sha" >> $GITHUB_ENV
6569
echo "original_ref=$original_ref" >> $GITHUB_ENV
6670
echo "original_conclusion=$original_conclusion" >> $GITHUB_ENV
71+
echo "original_run_id=$original_run_id" >> $GITHUB_ENV
6772
6873
echo "original_event = $original_event"
6974
echo "original_action = $original_action"
7075
echo "original_sha = $original_sha"
7176
echo "original_ref = $original_ref"
7277
echo "original_conclusion = $original_conclusion"
78+
echo "original_run_id = $original_run_id"
79+
80+
- name: Print links to other runs
81+
run: |
82+
echo "Build, Hardware and QEMU tests: https://github.com/${{ github.repository }}/actions/runs/${{ env.original_run_id }}"
83+
echo "Wokwi tests: https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}"
7384
7485
- name: Publish Unit Test Results
7586
uses: EnricoMi/publish-unit-test-result-action@v2
@@ -80,6 +91,17 @@ jobs:
8091
files: ./artifacts/**/*.xml
8192
action_fail: true
8293
compare_to_earlier_commit: false
94+
json_file: ./unity_results.json
95+
json_suite_details: true
96+
97+
- name: Upload JSON
98+
uses: actions/upload-artifact@v4
99+
if: ${{ always() }}
100+
with:
101+
name: unity_results
102+
overwrite: true
103+
path: |
104+
./unity_results.json
83105
84106
- name: Fail if tests failed
85107
if: ${{ env.original_conclusion == 'failure' || env.original_conclusion == 'timed_out' || github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out' }}
@@ -138,11 +160,18 @@ jobs:
138160
})).data;
139161
core.info(`${name} is ${state}`);
140162
141-
- name: Create output folder
163+
- name: Generate report
142164
if: ${{ !cancelled() && (env.original_event == 'schedule' || env.original_event == 'workflow_dispatch') }} # codespell:ignore cancelled
165+
env:
166+
REPORT_FILE: ./runtime-tests-results/RUNTIME_TESTS_REPORT.md
167+
WOKWI_RUN_ID: ${{ github.event.workflow_run.id }}
168+
BUILD_RUN_ID: ${{ env.original_run_id }}
169+
IS_FAILING: ${{ env.original_conclusion == 'failure' || env.original_conclusion == 'timed_out' || github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out' || job.status == 'failure' }}
143170
run: |
144-
rm -rf artifacts
145-
mkdir -p runtime-tests-results
171+
rm -rf artifacts $REPORT_FILE
172+
mv -f ./unity_results.json ./runtime-tests-results/unity_results.json
173+
touch $REPORT_FILE
174+
python3 ./runtime-tests-results/table_generator.py ./runtime-tests-results/unity_results.json >> $REPORT_FILE
146175
147176
- name: Generate badge
148177
if: ${{ !cancelled() && (env.original_event == 'schedule' || env.original_event == 'workflow_dispatch') }} # codespell:ignore cancelled
@@ -161,6 +190,6 @@ jobs:
161190
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
162191
if [[ `git status --porcelain` ]]; then
163192
git add --all
164-
git commit -m "Updated runtime tests badge"
193+
git commit -m "Updated runtime tests report"
165194
git push origin HEAD:gh-pages
166195
fi

.github/workflows/tests_wokwi.yml

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ jobs:
109109
printf "\nAction = "
110110
cat artifacts/action.txt
111111
112+
printf "${{ github.event.workflow_run.id }}" >> artifacts/run_id.txt
113+
printf "\nRun ID = "
114+
cat artifacts/run_id.txt
115+
112116
if [ -z "$ref" ] || [ "$ref" == "null" ]; then
113117
echo "Failed to get PR number or ref"
114118
exit 1

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Build Status](https://img.shields.io/github/actions/workflow/status/espressif/arduino-esp32/push.yml?branch=master&event=push&label=Compilation%20Tests)](https://github.com/espressif/arduino-esp32/actions/workflows/push.yml?query=branch%3Amaster+event%3Apush)
44
[![Verbose Build Status](https://img.shields.io/github/actions/workflow/status/espressif/arduino-esp32/push.yml?branch=master&event=schedule&label=Compilation%20Tests%20(Verbose))](https://github.com/espressif/arduino-esp32/actions/workflows/push.yml?query=branch%3Amaster+event%3Aschedule)
55
[![External Libraries Test](https://img.shields.io/github/actions/workflow/status/espressif/arduino-esp32/lib.yml?branch=master&event=schedule&label=External%20Libraries%20Test)](https://github.com/espressif/arduino-esp32/blob/gh-pages/LIBRARIES_TEST.md)
6-
[![Runtime Tests](https://github.com/espressif/arduino-esp32/blob/gh-pages/runtime-tests-results/badge.svg)](https://github.com/espressif/arduino-esp32/actions/workflows/tests_results.yml)
6+
[![Runtime Tests](https://github.com/espressif/arduino-esp32/blob/gh-pages/runtime-tests-results/badge.svg)](https://github.com/espressif/arduino-esp32/blob/gh-pages/runtime-tests-results/RUNTIME_TESTS_REPORT.md)
77

88
### Need help or have a question? Join the chat at [Discord](https://discord.gg/8xY6e9crwv) or [open a new Discussion](https://github.com/espressif/arduino-esp32/discussions)
99

0 commit comments

Comments
 (0)