forked from espressif/arduino-esp32
-
Notifications
You must be signed in to change notification settings - Fork 0
624 lines (557 loc) · 26.1 KB
/
tests_hw_wokwi.yml
File metadata and controls
624 lines (557 loc) · 26.1 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
name: Hardware and Wokwi tests
on:
workflow_run:
workflows: ["Runtime Tests"]
types:
- completed
# No permissions by default
permissions:
contents: read
jobs:
get-artifacts:
name: Get required artifacts
runs-on: ubuntu-latest
permissions:
actions: read
statuses: write
outputs:
pr_num: ${{ steps.set-ref.outputs.pr_num }}
ref: ${{ steps.set-ref.outputs.ref }}
base: ${{ steps.set-ref.outputs.base }}
hw_types: ${{ steps.set-ref.outputs.hw_types }}
hw_targets: ${{ steps.set-ref.outputs.hw_targets }}
wokwi_types: ${{ steps.set-ref.outputs.wokwi_types }}
wokwi_targets: ${{ steps.set-ref.outputs.wokwi_targets }}
hw_tests_enabled: ${{ steps.set-ref.outputs.hw_tests_enabled }}
wokwi_tests_enabled: ${{ steps.set-ref.outputs.wokwi_tests_enabled }}
rerun_wokwi_test: ${{ steps.set-ref.outputs.rerun_wokwi_test }}
push_time: ${{ steps.set-ref.outputs.push_time }}
steps:
- name: Report pending
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ github.event.workflow_run.head_sha }}';
core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Runtime Tests / Wokwi (Get artifacts) (${{ github.event.workflow_run.event }} -> workflow_run)',
owner: owner,
repo: repo,
sha: sha,
state: 'pending',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})).data;
core.info(`${name} is ${state}`);
- name: Download and extract event file
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
name: event_file
path: artifacts/event_file
- name: Download and extract matrix info
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
name: matrix_info
path: artifacts/matrix_info
- name: Get info
env:
GITLAB_ACCESS_TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }}
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
id: set-ref
run: |
# Get info and sanitize it to avoid security issues
pr_num=$(jq -r '.pull_request.number' artifacts/event_file/event.json | tr -cd "[:digit:]")
if [ -z "$pr_num" ] || [ "$pr_num" == "null" ]; then
pr_num=""
fi
ref=$pr_num
if [ -z "$ref" ] || [ "$ref" == "null" ]; then
ref=${{ github.ref }}
fi
action=$(jq -r '.action' artifacts/event_file/event.json | tr -cd "[:alpha:]_")
if [ "$action" == "null" ]; then
action=""
fi
base=$(jq -r '.pull_request.base.ref' artifacts/event_file/event.json | tr -cd "[:alnum:]/_.-")
if [ -z "$base" ] || [ "$base" == "null" ]; then
base=${{ github.ref }}
fi
if [ -n "$GITLAB_ACCESS_TOKEN" ]; then
hw_tests_enabled="true"
if [[ -n "$pr_num" ]]; then
# This is a PR, check for hil_test label
has_hil_label=$(jq -r '.pull_request.labels[]?.name' artifacts/event_file/event.json 2>/dev/null | grep -q "hil_test" && echo "true" || echo "false")
echo "Has hil_test label: $has_hil_label"
if [[ "$has_hil_label" != "true" ]]; then
echo "PR does not have hil_test label, hardware tests will be disabled"
hw_tests_enabled="false"
fi
fi
else
echo "GITLAB_ACCESS_TOKEN is not set, hardware tests will be disabled"
hw_tests_enabled="false"
fi
if [ -n "$WOKWI_CLI_TOKEN" ]; then
wokwi_tests_enabled="true"
else
echo "WOKWI_CLI_TOKEN is not set, wokwi tests will be disabled"
wokwi_tests_enabled="false"
fi
# Check for Re-trigger Wokwi Tests label
rerun_wokwi_test="false"
if [[ -n "$pr_num" ]]; then
# This is a PR, check for Re-trigger Wokwi Tests label
has_rerun_label=$(jq -r '.pull_request.labels[]?.name' artifacts/event_file/event.json 2>/dev/null | grep -q "Re-trigger Wokwi Tests" && echo "true" || echo "false")
echo "Has Re-trigger Wokwi Tests label: $has_rerun_label"
if [[ "$has_rerun_label" == "true" ]]; then
rerun_wokwi_test="true"
echo "PR has Re-trigger Wokwi Tests label, cached results will be ignored"
fi
fi
push_time=$(jq -r '.repository.pushed_at' artifacts/event_file/event.json | tr -cd "[:alnum:]:-")
if [ -z "$push_time" ] || [ "$push_time" == "null" ]; then
push_time=""
fi
hw_targets=$(jq -c '.hw_targets' artifacts/matrix_info/test_matrix.json | tr -cd "[:alnum:],[]\"")
hw_types=$(jq -c '.hw_types' artifacts/matrix_info/test_matrix.json | tr -cd "[:alpha:],[]\"")
wokwi_targets=$(jq -c '.wokwi_targets' artifacts/matrix_info/test_matrix.json | tr -cd "[:alnum:],[]\"")
wokwi_types=$(jq -c '.wokwi_types' artifacts/matrix_info/test_matrix.json | tr -cd "[:alpha:],[]\"")
qemu_tests_enabled=$(jq -r '.qemu_enabled' artifacts/matrix_info/test_matrix.json | tr -cd "[:alpha:]")
qemu_targets=$(jq -c '.qemu_targets' artifacts/matrix_info/test_matrix.json | tr -cd "[:alnum:],[]\"")
qemu_types=$(jq -c '.qemu_types' artifacts/matrix_info/test_matrix.json | tr -cd "[:alpha:],[]\"")
echo "base = $base"
echo "hw_targets = $hw_targets"
echo "hw_types = $hw_types"
echo "wokwi_targets = $wokwi_targets"
echo "wokwi_types = $wokwi_types"
echo "qemu_tests_enabled = $qemu_tests_enabled"
echo "qemu_targets = $qemu_targets"
echo "qemu_types = $qemu_types"
echo "pr_num = $pr_num"
echo "hw_tests_enabled = $hw_tests_enabled"
echo "wokwi_tests_enabled = $wokwi_tests_enabled"
echo "rerun_wokwi_test = $rerun_wokwi_test"
echo "push_time = $push_time"
conclusion="${{ github.event.workflow_run.conclusion }}"
run_id="${{ github.event.workflow_run.id }}"
event="${{ github.event.workflow_run.event }}"
sha="${{ github.event.workflow_run.head_sha || github.sha }}"
# Create a single JSON file with all workflow run information
cat > artifacts/workflow_info.json <<EOF
{
"hw_tests_enabled": $hw_tests_enabled,
"hw_targets": $hw_targets,
"hw_types": $hw_types,
"wokwi_tests_enabled": $wokwi_tests_enabled,
"wokwi_targets": $wokwi_targets,
"wokwi_types": $wokwi_types,
"qemu_tests_enabled": $qemu_tests_enabled,
"qemu_targets": $qemu_targets,
"qemu_types": $qemu_types,
"ref": "$ref",
"event": "$event",
"sha": "$sha",
"action": "$action",
"run_id": "$run_id",
"conclusion": "$conclusion"
}
EOF
echo "Ref = $ref"
echo "Event name = $event"
echo "Head SHA = $sha"
echo "Action = $action"
echo "Run ID = $run_id"
echo "Conclusion = $conclusion"
if [ -z "$ref" ] || [ "$ref" == "null" ]; then
echo "Failed to get PR number or ref"
exit 1
fi
echo "pr_num=$pr_num" >> $GITHUB_OUTPUT
echo "base=$base" >> $GITHUB_OUTPUT
echo "hw_targets=$hw_targets" >> $GITHUB_OUTPUT
echo "hw_types=$hw_types" >> $GITHUB_OUTPUT
echo "wokwi_targets=$wokwi_targets" >> $GITHUB_OUTPUT
echo "wokwi_types=$wokwi_types" >> $GITHUB_OUTPUT
echo "ref=$ref" >> $GITHUB_OUTPUT
echo "hw_tests_enabled=$hw_tests_enabled" >> $GITHUB_OUTPUT
echo "wokwi_tests_enabled=$wokwi_tests_enabled" >> $GITHUB_OUTPUT
echo "rerun_wokwi_test=$rerun_wokwi_test" >> $GITHUB_OUTPUT
echo "push_time=$push_time" >> $GITHUB_OUTPUT
- name: Download and extract parent QEMU results
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
pattern: test-results-qemu-*
merge-multiple: true
path: artifacts/results/qemu
- name: Upload parent artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: parent-artifacts
path: artifacts
if-no-files-found: error
- name: Report conclusion
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: always()
with:
script: |
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ github.event.workflow_run.head_sha }}';
core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Runtime Tests / Wokwi (Get artifacts) (${{ github.event.workflow_run.event }} -> workflow_run)',
owner: owner,
repo: repo,
sha: sha,
state: '${{ job.status }}',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})).data;
core.info(`${name} is ${state}`);
hardware-test:
name: Internal Hardware Tests
if: |
(github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ||
github.event.workflow_run.conclusion == 'timed_out') &&
needs.get-artifacts.outputs.hw_tests_enabled == 'true'
runs-on: ubuntu-latest
needs: get-artifacts
env:
id: ${{ needs.get-artifacts.outputs.ref }}-${{ github.event.workflow_run.head_sha || github.sha }}
permissions:
actions: read
statuses: write
steps:
- name: Report pending
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ github.event.workflow_run.head_sha }}';
core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Runtime Tests / Internal Hardware Tests (${{ github.event.workflow_run.event }} -> workflow_run)',
owner: owner,
repo: repo,
sha: sha,
state: 'pending',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})).data;
core.info(`${name} is ${state}`);
- name: Check if already passed
id: get-cache-results
if: needs.get-artifacts.outputs.pr_num
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: test-${{ env.id }}-results-hw
path: |
tests/**/*.xml
tests/**/result_*.json
- name: Evaluate if tests should be run
id: check-tests
run: |
cache_exists=${{ steps.get-cache-results.outputs.cache-hit == 'true' }}
enabled=true
# Check cache first
if [[ $cache_exists == 'true' ]]; then
echo "Already ran, skipping GitLab pipeline trigger"
enabled=false
else
echo "Cache miss, hardware tests will run"
fi
echo "enabled=$enabled" >> $GITHUB_OUTPUT
- name: Wait for GitLab sync and prepare variables
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
id: prepare-variables
env:
PUSH_TIME: ${{ needs.get-artifacts.outputs.push_time }}
run: |
# A webhook to sync the repository is sent to GitLab when a commit is pushed to GitHub
# We wait for 10 minutes after the push to GitHub to be safe
echo "Ensuring GitLab sync has completed before triggering pipeline..."
# Use push time determined in get-artifacts job
push_time="$PUSH_TIME"
if [ -n "$push_time" ]; then
echo "Push time: $push_time"
# Convert push time to epoch
push_epoch=$(date -d "$push_time" +%s 2>/dev/null || echo "")
if [ -n "$push_epoch" ]; then
current_epoch=$(date +%s)
elapsed_minutes=$(( (current_epoch - push_epoch) / 60 ))
echo "Elapsed time since push: ${elapsed_minutes} minutes"
if [ $elapsed_minutes -lt 10 ]; then
wait_time=$(( (10 - elapsed_minutes) * 60 ))
echo "Waiting ${wait_time} seconds for GitLab sync to complete..."
sleep $wait_time
else
echo "GitLab sync should be complete (${elapsed_minutes} minutes elapsed)"
fi
else
echo "Could not parse push timestamp, waiting 60 seconds as fallback..."
sleep 60
fi
else
echo "Could not determine push time, waiting 60 seconds as fallback..."
sleep 60
fi
echo "Proceeding with GitLab pipeline trigger..."
# Make targets/types comma-separated strings (remove brackets and quotes)
test_types=$(printf '%s' "${{ needs.get-artifacts.outputs.hw_types }}" | sed -e 's/[][]//g' -e 's/"//g')
test_chips=$(printf '%s' "${{ needs.get-artifacts.outputs.hw_targets }}" | sed -e 's/[][]//g' -e 's/"//g')
echo "test_types=$test_types"
echo "test_chips=$test_chips"
# Expose as step outputs
echo "test_types=$test_types" >> $GITHUB_OUTPUT
echo "test_chips=$test_chips" >> $GITHUB_OUTPUT
- name: Trigger GitLab Pipeline and Download Artifacts
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
uses: digital-blueprint/gitlab-pipeline-trigger-action@20e77989b24af658ba138a0aa5291bdc657f1505 # v1.3.0
id: gitlab-trigger
with:
host: ${{ secrets.GITLAB_URL }}
id: ${{ secrets.GITLAB_PROJECT_ID }}
ref: ${{ needs.get-artifacts.outputs.base || github.ref }}
trigger_token: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
access_token: ${{ secrets.GITLAB_ACCESS_TOKEN }}
download_artifacts: 'true'
download_artifacts_on_failure: 'true'
download_path: './gitlab-artifacts'
variables: >-
{
"TEST_TYPES":"${{ steps.prepare-variables.outputs.test_types }}",
"TEST_CHIPS":"${{ steps.prepare-variables.outputs.test_chips }}",
"PIPELINE_ID":"${{ env.id }}",
"BINARIES_RUN_ID":"${{ github.event.workflow_run.id }}",
"GITHUB_REPOSITORY":"${{ github.repository }}",
"GITHUB_REF":"${{ needs.get-artifacts.outputs.base || github.ref }}"
}
- name: Process Downloaded Artifacts
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
run: |
echo "GitLab Pipeline Status: ${{ steps.gitlab-trigger.outputs.status }}"
echo "Artifacts Downloaded: ${{ steps.gitlab-trigger.outputs.artifacts_downloaded }}"
# Create tests directory structure expected by GitHub caching
mkdir -p tests
# Process downloaded GitLab artifacts
if [ "${{ steps.gitlab-trigger.outputs.artifacts_downloaded }}" = "true" ]; then
echo "Processing downloaded GitLab artifacts..."
# Find and copy test result files while preserving directory structure
# The GitLab artifacts have the structure: gitlab-artifacts/job_*/artifacts/tests/...
# We want to preserve the tests/... part of the structure
for job_dir in ./gitlab-artifacts/job_*; do
if [ -d "$job_dir/artifacts/tests" ]; then
# Merge results into tests/ without failing on non-empty directories
echo "Merging $job_dir/artifacts/tests/ into tests/"
cp -a "$job_dir/artifacts/tests/." tests/
fi
done
echo "Test results found:"
ls -laR tests/ || echo "No test results found"
else
echo "No artifacts were downloaded from GitLab"
fi
- name: Upload hardware results as cache
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
if: steps.check-tests.outputs.enabled == 'true' && needs.get-artifacts.outputs.pr_num
with:
key: test-${{ env.id }}-results-hw
path: |
tests/**/*.xml
tests/**/result_*.json
- name: Upload hardware results as artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: test-results-hw
overwrite: true
path: |
tests/**/*.xml
tests/**/result_*.json
- name: Report conclusion
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: always()
with:
script: |
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ github.event.workflow_run.head_sha }}';
core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Runtime Tests / Internal Hardware Tests (${{ github.event.workflow_run.event }} -> workflow_run)',
owner: owner,
repo: repo,
sha: sha,
state: '${{ job.status }}',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})).data;
core.info(`${name} is ${state}`);
wokwi-test:
name: Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests
if: |
(github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ||
github.event.workflow_run.conclusion == 'timed_out') &&
needs.get-artifacts.outputs.wokwi_tests_enabled == 'true'
runs-on: ubuntu-latest
needs: get-artifacts
env:
id: ${{ needs.get-artifacts.outputs.ref }}-${{ github.event.workflow_run.head_sha || github.sha }}-${{ matrix.chip }}-${{ matrix.type }}
permissions:
actions: read
statuses: write
pull-requests: write
strategy:
fail-fast: false
matrix:
type: ${{ fromJson(needs.get-artifacts.outputs.wokwi_types) }}
chip: ${{ fromJson(needs.get-artifacts.outputs.wokwi_targets) }}
steps:
- name: Report pending
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ github.event.workflow_run.head_sha }}';
core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Runtime Tests / Wokwi (${{ matrix.type }}, ${{ matrix.chip }}) / Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests (${{ github.event.workflow_run.event }} -> workflow_run)',
owner: owner,
repo: repo,
sha: sha,
state: 'pending',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})).data;
core.info(`${name} is ${state}`);
- name: Check if already passed
id: get-cache-results
if: needs.get-artifacts.outputs.pr_num && needs.get-artifacts.outputs.rerun_wokwi_test == 'false'
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: test-${{ env.id }}-results-wokwi
path: |
tests/**/*.xml
tests/**/result_*.json
- name: Evaluate if tests should be run
id: check-tests
run: |
cache_hit="${{ steps.get-cache-results.outputs.cache-hit }}"
rerun_label=${{ needs.get-artifacts.outputs.rerun_wokwi_test }}
if [[ "$rerun_label" == "true" ]]; then
echo "Re-trigger Wokwi Tests label is present, running tests (cache restore was skipped)"
enabled=true
elif [[ "$cache_hit" == "true" ]]; then
echo "Already ran, skipping"
enabled=false
else
echo "No cache found, tests will run"
enabled=true
fi
echo "enabled=$enabled" >> $GITHUB_OUTPUT
# Note that changes to the workflows and tests will only be picked up after the PR is merged
# DO NOT CHECKOUT THE USER'S REPOSITORY IN THIS WORKFLOW. IT HAS HIGH SECURITY RISKS.
- name: Checkout repository
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ needs.get-artifacts.outputs.base || github.ref }}
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.0.4
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
with:
cache-dependency-path: tests/requirements.txt
cache: "pip"
python-version: "3.x"
- name: Install dependencies
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
run: |
pip install -U pip
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi
- name: Wokwi CI Server
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
uses: wokwi/wokwi-ci-server-action@a6fabb5a49e080158c7a1d121ea5b789536a82c3 # v1
- name: Get binaries
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
name: test-bin-${{ matrix.chip }}-${{ matrix.type }}
path: |
~/.arduino/tests/${{ matrix.chip }}
- name: Run Tests
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
env:
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
WOKWI_WIFI_SSID: "Wokwi-GUEST"
# The Wokwi Wi-Fi does not have a password, so we use an empty string
WOKWI_WIFI_PASSWORD: ""
run: |
bash .github/scripts/tests_run.sh -c -type "${{ matrix.type }}" -t "${{ matrix.chip }}" -i 0 -m 1 -W -wifi-ssid "${{ env.WOKWI_WIFI_SSID }}" -wifi-password "${{ env.WOKWI_WIFI_PASSWORD }}"
- name: Upload ${{ matrix.chip }} ${{ matrix.type }} Wokwi results as cache
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
if: steps.check-tests.outputs.enabled == 'true' && needs.get-artifacts.outputs.pr_num
with:
key: test-${{ env.id }}-results-wokwi
path: |
tests/**/*.xml
tests/**/result_*.json
- name: Upload ${{ matrix.chip }} ${{ matrix.type }} Wokwi results as artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: test-results-wokwi-${{ matrix.chip }}-${{ matrix.type }}
overwrite: true
path: |
tests/**/*.xml
tests/**/result_*.json
- name: Report conclusion
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: always()
with:
script: |
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ github.event.workflow_run.head_sha }}';
core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Runtime Tests / Wokwi (${{ matrix.type }}, ${{ matrix.chip }}) / Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests (${{ github.event.workflow_run.event }} -> workflow_run)',
owner: owner,
repo: repo,
sha: sha,
state: '${{ job.status }}',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})).data;
core.info(`${name} is ${state}`);
- name: Remove Re-trigger Wokwi Tests label if it was present
if: |
always() &&
needs.get-artifacts.outputs.pr_num &&
needs.get-artifacts.outputs.rerun_wokwi_test == 'true'
continue-on-error: true
run: |
gh pr edit "$PR_NUM" --repo "$GITHUB_REPOSITORY" --remove-label 'Re-trigger Wokwi Tests'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUM: ${{ needs.get-artifacts.outputs.pr_num }}
GITHUB_REPOSITORY: ${{ github.repository }}