3737 type : string
3838
3939jobs :
40+ matrix :
41+ name : espidf-${{ inputs.hil_board }}-hil-matrix
42+ runs-on : ubuntu-24.04
43+
44+ outputs :
45+ tests : ${{ steps.output-tests.outputs.tests }}
46+
47+ steps :
48+ - name : Checkout repository
49+ uses : actions/checkout@v4
50+
51+ - name : Prepare tests matrix
52+ id : output-tests
53+ shell : python
54+ run : |
55+ import json
56+ import os
57+ from pathlib import Path
58+
59+ tests = [p.name for p in Path('tests/hil/tests').iterdir()]
60+
61+ with open(os.environ['GITHUB_OUTPUT'], 'a') as github_output:
62+ print('tests=' + json.dumps(tests), file=github_output)
63+
4064 build :
41- name : esp-idf-${{ inputs.hil_board }}-build
65+ name : espidf-${{ inputs.hil_board }}-hil-build (${{ matrix.test }})
66+ needs : matrix
67+ strategy :
68+ fail-fast : false
69+ matrix :
70+ test : ${{ fromJSON(needs.matrix.outputs.tests) }}
4271 runs-on : ubuntu-24.04
4372 steps :
4473 - name : Checkout Repository and Submodules
4574 uses : actions/checkout@v4
4675 with :
4776 submodules : ' recursive'
77+
4878 - name : Prep for build
4979 id : build_prep
5080 run : |
@@ -53,29 +83,46 @@ jobs:
5383
5484 rm -rf test_binaries
5585 mkdir test_binaries
56- echo test_list=$(ls tests/hil/tests) >> "$GITHUB_OUTPUT"
86+
5787 - name : Build Test Firmware
5888 uses : espressif/esp-idf-ci-action@v1
5989 with :
6090 esp_idf_version : v5.4.1
6191 target : ${{ inputs.idf_target }}
6292 path : ' tests/hil/platform/esp-idf'
6393 command : |
64- for test in ${{ steps.build_prep.outputs.test_list }}; do
65- idf.py -DGOLIOTH_HIL_TEST=$test build && \
66- mv build/merged.bin ../../../../test_binaries/${test}.bin || \
67- EXITCODE=$?
68- done
69- exit $EXITCODE
94+ idf.py -DGOLIOTH_HIL_TEST=${{ matrix.test }} build && \
95+ mv build/merged.bin ../../../../test_binaries/${{ matrix.test }}.bin
96+
7097 - name : Save Artifacts
7198 uses : actions/upload-artifact@v4
7299 with :
73- name : ${{ inputs.hil_board }}-esp-idf
100+ name : ${{ inputs.hil_board }}-hil-espidf-${{ matrix.test }}
74101 path : test_binaries/*
75102
103+ verify_build :
104+ name : espidf-${{ inputs.hil_board }}-hil-verify-build
105+ if : always()
106+ needs :
107+ - matrix
108+ - build
109+ runs-on : ubuntu-24.04
110+
111+ steps :
112+ - name : Decide whether the needed jobs succeeded or failed
113+ uses : re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
114+ with :
115+ jobs : ${{ toJSON(needs) }}
116+
76117 test :
77- name : esp-idf-${{ inputs.hil_board }}-test
78- needs : build
118+ name : espidf-${{ inputs.hil_board }}-hil-test (${{ matrix.test }})
119+ needs :
120+ - matrix
121+ - build
122+ strategy :
123+ fail-fast : false
124+ matrix :
125+ test : ${{ fromJSON(needs.matrix.outputs.tests) }}
79126 runs-on :
80127 - is_active
81128 - has_${{ inputs.hil_board }}
@@ -91,20 +138,24 @@ jobs:
91138 steps :
92139 - name : Checkout repository
93140 uses : actions/checkout@v4
141+
94142 - name : Setup Python dependencies
95143 run : |
96144 uv pip install \
97145 pytest==8.4.2 \
98146 pytest-timeout \
99147 tests/hil/scripts/pytest-hil \
100148 git+https://github.com/golioth/python-golioth-tools@v0.8.1
149+
101150 - name : Power On USB Hub
102151 run : python3 /opt/golioth-scripts/usb_hub_power.py on
152+
103153 - name : Download build
104154 uses : actions/download-artifact@v4
105155 with :
106- name : ${{ inputs.hil_board }}-esp-idf
156+ name : ${{ inputs.hil_board }}-hil-espidf-${{ matrix.test }}
107157 path : .
158+
108159 - name : Run test
109160 shell : bash
110161 env :
@@ -115,59 +166,35 @@ jobs:
115166 rm -rf allure-reports
116167 source /opt/credentials/runner_env.sh
117168 PORT_VAR=CI_${hil_board^^}_PORT
118- for test in $(ls tests/hil/tests)
119- do
120- pytest --rootdir . tests/hil/tests/$test \
121- --board ${{ inputs.hil_board }}_espidf \
122- --port ${!PORT_VAR} \
123- --fw-image ${test}.bin \
124- --api-url ${{ inputs.api-url }} \
125- --api-key ${{ secrets[inputs.api-key-id] }} \
126- --wifi-ssid ${{ secrets[format('{0}_WIFI_SSID', runner.name)] }} \
127- --wifi-psk ${{ secrets[format('{0}_WIFI_PSK', runner.name)] }} \
128- --mask-secrets \
129- --timeout=600 \
130- --junitxml=summary/hil-espidf-${{ inputs.hil_board }}-${test}.xml \
131- --alluredir=allure-reports \
132- --allure-platform esp-idf \
133- --runner-name ${{ runner.name }} \
134- || EXITCODE=$?
135- done
136- exit $EXITCODE
137-
138- - name : Prepare summary
139- if : success() || failure()
140- shell : bash
141- run : |
142- if ! command -v sudo; then
143- # Self-hosted runner docker images don't have sudo installed
144- mkdir -p -m 777 /tmp && apt update && apt install -y xml-twig-tools
145- else
146- sudo apt install -y xml-twig-tools
147- fi
148169
149- xml_grep \
150- --pretty_print indented \
151- --wrap testsuites \
152- --descr '' \
153- --cond "testsuite" \
154- summary/*.xml \
155- > combined.xml
156- mv combined.xml summary/hil-espidf-${{ inputs.hil_board }}.xml
170+ pytest --rootdir . tests/hil/tests/${{ matrix.test }} \
171+ --board ${{ inputs.hil_board }}_espidf \
172+ --port ${!PORT_VAR} \
173+ --fw-image ${{ matrix.test }}.bin \
174+ --api-url ${{ inputs.api-url }} \
175+ --api-key ${{ secrets[inputs.api-key-id] }} \
176+ --wifi-ssid ${{ secrets[format('{0}_WIFI_SSID', runner.name)] }} \
177+ --wifi-psk ${{ secrets[format('{0}_WIFI_PSK', runner.name)] }} \
178+ --mask-secrets \
179+ --timeout=600 \
180+ --junitxml=summary/hil-espidf-${{ inputs.hil_board }}-${{ matrix.test }}.xml \
181+ --alluredir=allure-reports \
182+ --allure-platform esp-idf \
183+ --runner-name ${{ runner.name }} \
157184
158185 - name : Safe upload CI report summary
159186 uses : ./.github/actions/safe-upload-artifacts
160187 if : success() || failure()
161188 with :
162- name : ci-summary -hil-espidf-${{ inputs.hil_board }}
163- path : summary/hil-espidf-${{ inputs.hil_board }} .xml
189+ name : ci-individual -hil-espidf-${{ inputs.hil_board }}-${{ matrix.test }}
190+ path : summary/* .xml
164191
165192 - name : Safe upload Allure reports
166193 if : success() || failure()
167194 uses : ./.github/actions/safe-upload-artifacts
168195 with :
169196 secrets-json : ${{ toJson(secrets) }}
170- name : allure-reports-hil-espidf-${{ inputs.hil_board }}
197+ name : allure-reports-hil-espidf-${{ inputs.hil_board }}-${{ matrix.test }}
171198 path : allure-reports
172199
173200 - name : Erase flash
@@ -179,6 +206,42 @@ jobs:
179206 source /opt/credentials/runner_env.sh
180207 PORT_VAR=CI_${hil_board^^}_PORT
181208 esptool.py --port ${!PORT_VAR} erase_flash
209+
182210 - name : Power Off USB Hub
183211 if : always()
184212 run : python3 /opt/golioth-scripts/usb_hub_power.py off
213+
214+ summary :
215+ name : espidf-${{ inputs.hil_board }}-hil-summary
216+ runs-on : ubuntu-24.04
217+ needs : test
218+ if : success() || failure()
219+
220+ steps :
221+ - name : Collect JUnit reports
222+ uses : actions/download-artifact@v4
223+ with :
224+ path : summary
225+ pattern : ci-individual-hil-espidf-${{ inputs.hil_board }}-*
226+ merge-multiple : true
227+
228+ - name : Prepare CI report summary
229+ if : success() || failure()
230+ shell : bash
231+ run : |
232+ sudo apt install -y xml-twig-tools
233+
234+ xml_grep \
235+ --pretty_print indented \
236+ --wrap testsuites \
237+ --descr '' \
238+ --cond "testsuite" \
239+ summary/*.xml \
240+ > combined.xml
241+ mv combined.xml summary/hil-espidf-${{ inputs.hil_board }}.xml
242+
243+ - name : Upload CI report summary
244+ uses : actions/upload-artifact@v4
245+ with :
246+ name : ci-summary-hil-espidf-${{ inputs.hil_board }}
247+ path : summary/hil-espidf-${{ inputs.hil_board }}.xml
0 commit comments