@@ -13,15 +13,121 @@ env:
13
13
WOKWI_TIMEOUT : 600000 # Milliseconds
14
14
15
15
jobs :
16
+ get-artifacts :
17
+ name : Get required artifacts
18
+ runs-on : ubuntu-latest
19
+ outputs :
20
+ ref : ${{ steps.set-ref.outputs.ref }}
21
+ steps :
22
+ - name : Report pending
23
+ uses : actions/github-script@v7
24
+ with :
25
+ script : |
26
+ const owner = '${{ github.repository_owner }}';
27
+ const repo = '${{ github.repository }}'.split('/')[1];
28
+ const sha = '${{ github.event.workflow_run.head_sha }}';
29
+ core.debug(`owner: ${owner}`);
30
+ core.debug(`repo: ${repo}`);
31
+ core.debug(`sha: ${sha}`);
32
+ const { context: name, state } = (await github.rest.repos.createCommitStatus({
33
+ context: 'Runtime Tests / Wokwi (Get artifacts) (${{ github.event.workflow_run.event }} => workflow_run)',
34
+ owner: owner,
35
+ repo: repo,
36
+ sha: sha,
37
+ state: 'pending',
38
+ target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
39
+ })).data;
40
+ core.info(`${name} is ${state}`);
41
+
42
+ - name : Download and extract event file
43
+ uses : actions/download-artifact@v4
44
+ with :
45
+ github-token : ${{ secrets.GITHUB_TOKEN }}
46
+ run-id : ${{ github.event.workflow_run.id }}
47
+ name : event_file
48
+ path : artifacts/event_file
49
+
50
+ - name : Try to read PR number
51
+ id : set-ref
52
+ run : |
53
+ ref=$(jq -r '.pull_request.number' artifacts/event_file/event.json)
54
+ if [ -z "$ref" ] || [ "$ref" == "null" ]; then
55
+ ref=${{ github.ref }}
56
+ fi
57
+
58
+ echo "ref = $ref"
59
+ printf "${{ github.event.workflow_run.event }}" >> artifacts/event.txt
60
+ printf "Event name = "
61
+ cat artifacts/event.txt
62
+ printf "${{ github.event.workflow_run.head_sha || github.sha }}" >> artifacts/sha.txt
63
+ printf "Head SHA = "
64
+ cat artifacts/sha.txt
65
+
66
+ if [ -z "$ref" ] || [ "$ref" == "null" ]; then
67
+ echo "Failed to get PR number or ref"
68
+ exit 1
69
+ fi
70
+
71
+ echo "ref=$ref" >> $GITHUB_OUTPUT
72
+
73
+ - name : Download and extract parent hardware results
74
+ uses : actions/download-artifact@v4
75
+ continue-on-error : true
76
+ with :
77
+ github-token : ${{ secrets.GITHUB_TOKEN }}
78
+ run-id : ${{ github.event.workflow_run.id }}
79
+ pattern : tests-results-hw-*
80
+ merge-multiple : true
81
+ path : artifacts/results/hw
82
+
83
+ - name : Download and extract parent QEMU results
84
+ uses : actions/download-artifact@v4
85
+ continue-on-error : true
86
+ with :
87
+ github-token : ${{ secrets.GITHUB_TOKEN }}
88
+ run-id : ${{ github.event.workflow_run.id }}
89
+ pattern : tests-results-qemu-*
90
+ merge-multiple : true
91
+ path : artifacts/results/qemu
92
+
93
+ - name : Upload parent artifacts
94
+ uses : actions/upload-artifact@v4
95
+ with :
96
+ name : parent-artifacts
97
+ path : artifacts
98
+ if-no-files-found : error
99
+
100
+ - name : Report conclusion
101
+ uses : actions/github-script@v7
102
+ if : always()
103
+ with :
104
+ script : |
105
+ const owner = '${{ github.repository_owner }}';
106
+ const repo = '${{ github.repository }}'.split('/')[1];
107
+ const sha = '${{ github.event.workflow_run.head_sha }}';
108
+ core.debug(`owner: ${owner}`);
109
+ core.debug(`repo: ${repo}`);
110
+ core.debug(`sha: ${sha}`);
111
+ const { context: name, state } = (await github.rest.repos.createCommitStatus({
112
+ context: 'Runtime Tests / Wokwi (Get artifacts)',
113
+ owner: owner,
114
+ repo: repo,
115
+ sha: sha,
116
+ state: '${{ job.status }}',
117
+ target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
118
+ })).data;
119
+ core.info(`${name} is ${state}`);
120
+
16
121
wokwi-test :
17
122
name : Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests
18
123
if : |
19
124
github.event.workflow_run.conclusion == 'success' ||
20
125
github.event.workflow_run.conclusion == 'failure' ||
21
126
github.event.workflow_run.conclusion == 'timed_out'
22
127
runs-on : ubuntu-latest
128
+ needs : get-artifacts
23
129
env :
24
- id : ${{ github.event.workflow_run.head_sha }}-${{ matrix.chip }}-${{ matrix.type }}
130
+ id : ${{ needs.get-artifacts.outputs.ref }}-${{ github.event.workflow_run.head_sha || github.sha }}-${{ matrix.chip }}-${{ matrix.type }}
25
131
permissions :
26
132
actions : read
27
133
statuses : write
42
148
core.debug(`repo: ${repo}`);
43
149
core.debug(`sha: ${sha}`);
44
150
const { context: name, state } = (await github.rest.repos.createCommitStatus({
45
- context: 'Runtime Tests / Wokwi (${{ matrix.type }}, ${{ matrix.chip }})',
151
+ context: 'Runtime Tests / Wokwi (${{ matrix.type }}, ${{ matrix.chip }}) (${{ github.event.workflow_run.event }} => workflow_run) ',
46
152
owner: owner,
47
153
repo: repo,
48
154
sha: sha,
51
157
})).data;
52
158
core.info(`${name} is ${state}`);
53
159
54
- - name : Check if already run
160
+ - name : Check if already passed
55
161
id : get-cache-results
56
162
uses : actions/cache/restore@v4
57
163
with :
@@ -73,24 +179,10 @@ jobs:
73
179
74
180
echo "enabled=$enabled" >> $GITHUB_OUTPUT
75
181
76
- - name : Checkout user repository
182
+ # Note that changes to the workflows and tests will only be picked up after the PR is merged
183
+ - name : Checkout repository
77
184
if : ${{ steps.check-tests.outputs.enabled == 'true' }}
78
185
uses : actions/checkout@v4
79
- with :
80
- ref : ${{ github.event.workflow_run.head_sha }}
81
- persist-credentials : false
82
- sparse-checkout-cone-mode : false
83
- sparse-checkout : |
84
- /*
85
- !.github
86
-
87
- # To avoid giving unknown scripts elevated permissions, download them from the master branch
88
- - name : Get CI scripts from master
89
- if : ${{ steps.check-tests.outputs.enabled == 'true' }}
90
- run : |
91
- mkdir -p .github
92
- cd .github
93
- curl https://codeload.github.com/${{ github.repository }}/tar.gz/master | tar -xz --strip=2 arduino-esp32-master/.github
94
186
95
187
- uses : actions/setup-python@v5
96
188
if : ${{ steps.check-tests.outputs.enabled == 'true' }}
@@ -113,24 +205,6 @@ jobs:
113
205
if : ${{ steps.check-tests.outputs.enabled == 'true' }}
114
206
uses : wokwi/wokwi-ci-server-action@v1
115
207
116
- # - name: Download and Extract Artifacts
117
- # run: |
118
- # artifacts_url=${{ github.event.workflow_run.artifacts_url }}
119
- # gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
120
- # do
121
- # IFS=$'\t' read name url <<< "$artifact"
122
- # gh api $url > "$name.zip"
123
- # unzip -j "$name.zip" -d "temp_$name"
124
- # if [[ "$name" == "pr_number" ]]; then
125
- # mv "temp_$name"/* workflows
126
- # else
127
- # mv "temp_$name"/* libraries-report
128
- # fi
129
- # rm -r "temp_$name"
130
- # done
131
- # echo "Contents of parent directory:"
132
- # ls -R ..
133
-
134
208
- name : Get binaries
135
209
if : ${{ steps.check-tests.outputs.enabled == 'true' }}
136
210
uses : actions/download-artifact@v4
@@ -150,7 +224,7 @@ jobs:
150
224
151
225
- name : Upload ${{ matrix.chip }} ${{ matrix.type }} Wokwi results as cache
152
226
uses : actions/cache/save@v4
153
- if : ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
227
+ if : ${{ steps.check-tests.outputs.enabled == 'true' }}
154
228
with :
155
229
key : tests-${{ env.id }}-results-wokwi
156
230
path : |
0 commit comments