-
Notifications
You must be signed in to change notification settings - Fork 3
321 lines (295 loc) · 11.9 KB
/
hardware-test.yml
File metadata and controls
321 lines (295 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
name: Hardware Tests
permissions:
contents: read
# `dorny/test-reporter` needs to create Check Runs for the per-leg
# test reports; these show as individual PR checks.
checks: write
pull-requests: write
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
COORDINATOR: 10.0.0.41:20408
concurrency:
group: hw-${{ github.ref }}
cancel-in-progress: false
jobs:
preflight:
# Runs on the coordinator host itself so the labgrid-client query
# has a route to the coordinator daemon. GitHub-hosted runners
# cannot reach the private lab network.
runs-on: [self-hosted, hw-coordinator]
timeout-minutes: 3
outputs:
available_nodes: ${{ steps.probe.outputs.available_nodes }}
steps:
- uses: actions/checkout@v6
- name: Bootstrap uv
run: bash .github/scripts/bootstrap-uv.sh
- id: probe
timeout-minutes: 2
env:
LABGRID_PIP: 'labgrid @ git+https://github.com/tfcollins/labgrid.git@tfcollins/plugin-support'
run: |
set -euo pipefail
MANIFEST=.github/hw-nodes.json
HOST="${COORDINATOR%%:*}"
PORT="${COORDINATOR##*:}"
if ! timeout 10 bash -c "</dev/tcp/$HOST/$PORT" 2>/dev/null; then
echo "Coordinator $COORDINATOR unreachable — marking all nodes unavailable." >&2
echo 'available_nodes=[]' >> "$GITHUB_OUTPUT"
exit 0
fi
export PATH="$HOME/.local/bin:$PATH"
# uv-managed persistent venv for labgrid-client. Fresh hosts
# build it once (~10 s); subsequent runs skip straight to
# the probe.
VENV="$HOME/.cache/adidt-ci/labgrid-venv"
if [[ ! -x "$VENV/bin/labgrid-client" ]]; then
echo "Creating labgrid venv at $VENV" >&2
uv venv --quiet "$VENV"
uv pip install --quiet --python "$VENV/bin/python" "$LABGRID_PIP"
fi
LGCLIENT="$VENV/bin/labgrid-client"
echo "Using labgrid-client: $LGCLIENT" >&2
echo "--- places output ---" >&2
PLACES_OUT=$(timeout 30 "$LGCLIENT" -x "$COORDINATOR" places 2>&1 || true)
echo "$PLACES_OUT" >&2
echo "--- end places output ---" >&2
python3 - "$MANIFEST" "$PLACES_OUT" >> "$GITHUB_OUTPUT" <<'PY'
import json, sys
manifest = json.load(open(sys.argv[1]))
# `labgrid-client places` prints one place name per line.
# Any non-alphanumeric-heavy line (e.g. error banners) is
# filtered out by requiring each token to look like an
# identifier.
raw = sys.argv[2]
places = {
line.strip()
for line in raw.splitlines()
if line.strip() and all(c.isalnum() or c in "-_" for c in line.strip())
}
avail = [n for n in manifest if n["place"] in places]
print("available_nodes=" + json.dumps(avail))
PY
hw-direct:
needs: preflight
if: needs.preflight.outputs.available_nodes != '[]'
strategy:
fail-fast: false
matrix:
node: ${{ fromJSON(needs.preflight.outputs.available_nodes) }}
name: hw-direct (${{ matrix.node.place }})
runs-on: [self-hosted, "${{ matrix.node.runner_label }}"]
timeout-minutes: 40
concurrency:
group: hw-direct-${{ matrix.node.place }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v6
- name: Check LG_DIRECT_ENV on runner
id: check_direct_env
run: |
# If the runner hasn't been configured with a node-local
# labgrid YAML (LG_DIRECT_ENV in ~/actions-runner/.env),
# mark the job to skip gracefully rather than fail. Until
# each node's lab owner authors its direct YAML the
# hw-direct leg is a no-op on that runner; the hw-coord leg
# still exercises the same tests via the coordinator.
if [ -z "${LG_DIRECT_ENV:-}" ]; then
echo "LG_DIRECT_ENV is not set on this runner — skipping direct-mode tests." >&2
echo "To enable: add LG_DIRECT_ENV=<path> to ~/actions-runner/.env" >&2
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ ! -f "$LG_DIRECT_ENV" ]; then
echo "LG_DIRECT_ENV=$LG_DIRECT_ENV does not exist." >&2
exit 1
fi
echo "skip=false" >> "$GITHUB_OUTPUT"
- name: Bootstrap uv
if: steps.check_direct_env.outputs.skip != 'true'
run: bash .github/scripts/bootstrap-uv.sh
- name: Install adidt into host venv
if: steps.check_direct_env.outputs.skip != 'true'
env:
PYADI_BUILD_TOKEN: ${{ secrets.PYADI_BUILD_TOKEN }}
run: |
set -euo pipefail
if [[ -n "${PYADI_BUILD_TOKEN:-}" ]]; then
# Route any git clone of github.com through the token.
# GIT_CONFIG_* env-vars are per-process and don't persist
# into the runner's ~/.gitconfig, so the secret isn't left
# behind after the step.
export GIT_CONFIG_COUNT=1
export GIT_CONFIG_KEY_0="url.https://x-access-token:${PYADI_BUILD_TOKEN}@github.com/.insteadOf"
export GIT_CONFIG_VALUE_0="https://github.com/"
fi
bash .github/scripts/install-adidt-venv.sh
- name: Run direct-mode tests
if: steps.check_direct_env.outputs.skip != 'true'
run: |
set -euo pipefail
if [ -f /tools/Xilinx/2025.1/Vivado/settings64.sh ]; then
# Xilinx settings scripts reference PYTHONPATH/XILINX_*
# unconditionally; drop `set -u` while sourcing them.
set +u
# shellcheck disable=SC1091
source /tools/Xilinx/2025.1/Vivado/settings64.sh
set -u
fi
export LG_ENV="$LG_DIRECT_ENV"
"$HOME/.cache/adidt-ci/adidt-venv/bin/pytest" \
-p no:genalyzer -v -s ${{ join(matrix.node.tests, ' ') }} \
--junitxml=junit-hw-direct-${{ matrix.node.place }}.xml
- name: Publish hw-direct test results to PR
if: always() && steps.check_direct_env.outputs.skip != 'true'
uses: dorny/test-reporter@v1
with:
name: Tests (hw-direct ${{ matrix.node.place }})
path: junit-hw-direct-${{ matrix.node.place }}.xml
reporter: java-junit
fail-on-error: false
- name: Upload JUnit XML (standalone for PR comment aggregation)
if: always() && steps.check_direct_env.outputs.skip != 'true'
uses: actions/upload-artifact@v4
with:
name: junit-hw-direct-${{ matrix.node.place }}
path: junit-hw-direct-${{ matrix.node.place }}.xml
retention-days: 14
if-no-files-found: warn
- name: Upload test output artifacts
if: always() && steps.check_direct_env.outputs.skip != 'true'
uses: actions/upload-artifact@v4
with:
name: hw-direct-${{ matrix.node.place }}-output
path: |
test/hw/output/**/*.dts
test/hw/output/**/*.pp.dts
test/hw/output/**/*.dtb
test/hw/output/**/*.dtbo
test/hw/output/**/*.log
test/hw/output/**/uart_log_*.txt
uart_log_*.txt
junit-hw-direct-${{ matrix.node.place }}.xml
if-no-files-found: ignore
retention-days: 14
hw-coord:
needs: preflight
if: needs.preflight.outputs.available_nodes != '[]'
strategy:
fail-fast: false
matrix:
node: ${{ fromJSON(needs.preflight.outputs.available_nodes) }}
name: hw-coord (${{ matrix.node.place }})
# Run on the per-node runner (same label as hw-direct) so the
# Xilinx toolchain (sdtgen, xsct) available there can drive the
# XSA pipeline. The coordinator host (lbvm) lacks Vivado, so
# running pytest there silently skips every XSA-dependent test.
runs-on: [self-hosted, "${{ matrix.node.runner_label }}"]
timeout-minutes: 40
concurrency:
group: hw-coord-${{ matrix.node.place }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v6
- name: Bootstrap uv
run: bash .github/scripts/bootstrap-uv.sh
- name: Install adidt into host venv
env:
PYADI_BUILD_TOKEN: ${{ secrets.PYADI_BUILD_TOKEN }}
run: |
set -euo pipefail
if [[ -n "${PYADI_BUILD_TOKEN:-}" ]]; then
export GIT_CONFIG_COUNT=1
export GIT_CONFIG_KEY_0="url.https://x-access-token:${PYADI_BUILD_TOKEN}@github.com/.insteadOf"
export GIT_CONFIG_VALUE_0="https://github.com/"
fi
bash .github/scripts/install-adidt-venv.sh
- name: Acquire coordinator place
env:
LG_COORDINATOR: ${{ env.COORDINATOR }}
run: |
set -euo pipefail
# labgrid-client is a transitive dep of adidt's dev extras,
# so it lands in the per-node adidt-venv.
LGCLIENT="$HOME/.cache/adidt-ci/adidt-venv/bin/labgrid-client"
"$LGCLIENT" -x "$LG_COORDINATOR" -p "${{ matrix.node.place }}" acquire
- name: Run coordinator-mode tests
env:
LG_COORDINATOR: ${{ env.COORDINATOR }}
LG_ENV: ${{ github.workspace }}/${{ matrix.node.env_remote }}
run: |
set -euo pipefail
# Source Vivado settings so sdtgen / xsct / xsdb are on PATH
# for XSA-pipeline tests.
if [ -f /tools/Xilinx/2025.1/Vivado/settings64.sh ]; then
# Xilinx settings scripts reference PYTHONPATH/XILINX_*
# unconditionally; drop `set -u` while sourcing them.
set +u
# shellcheck disable=SC1091
source /tools/Xilinx/2025.1/Vivado/settings64.sh
set -u
fi
"$HOME/.cache/adidt-ci/adidt-venv/bin/pytest" \
-p no:genalyzer -v -s ${{ join(matrix.node.tests, ' ') }} \
--junitxml=junit-hw-coord-${{ matrix.node.place }}.xml
- name: Release coordinator place
if: always()
env:
LG_COORDINATOR: ${{ env.COORDINATOR }}
run: |
set -euo pipefail
LGCLIENT="$HOME/.cache/adidt-ci/adidt-venv/bin/labgrid-client"
"$LGCLIENT" -x "$LG_COORDINATOR" -p "${{ matrix.node.place }}" release || true
- name: Publish hw-coord test results to PR
if: always()
uses: dorny/test-reporter@v1
with:
name: Tests (hw-coord ${{ matrix.node.place }})
path: junit-hw-coord-${{ matrix.node.place }}.xml
reporter: java-junit
fail-on-error: false
- name: Upload JUnit XML (standalone for PR comment aggregation)
if: always()
uses: actions/upload-artifact@v4
with:
name: junit-hw-coord-${{ matrix.node.place }}
path: junit-hw-coord-${{ matrix.node.place }}.xml
retention-days: 14
if-no-files-found: warn
- name: Upload test output artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: hw-coord-${{ matrix.node.place }}-output
path: |
test/hw/output/**/*.dts
test/hw/output/**/*.pp.dts
test/hw/output/**/*.dtb
test/hw/output/**/*.dtbo
test/hw/output/**/*.log
test/hw/output/**/uart_log_*.txt
uart_log_*.txt
junit-hw-coord-${{ matrix.node.place }}.xml
if-no-files-found: ignore
retention-days: 14
publish-pr-test-summary:
name: PR Test Summary
needs: [hw-direct, hw-coord]
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: junit-hw-*
path: junit
merge-multiple: true
- uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: 'junit/**/*.xml'
check_name: 'Hardware Test Results'
comment_mode: always
report_individual_runs: true