|
1 |
| -name: Wokwi tests |
2 |
| - |
3 |
| -on: |
4 |
| - workflow_run: |
5 |
| - workflows: ["Runtime Tests"] |
6 |
| - types: |
7 |
| - - completed |
8 |
| - |
9 |
| -# No permissions by default |
10 |
| -permissions: { contents: read } |
11 |
| - |
12 |
| -env: |
13 |
| - WOKWI_TIMEOUT: 600000 # Milliseconds |
14 |
| - |
15 |
| -jobs: |
16 |
| - get-artifacts: |
17 |
| - name: Get required artifacts |
18 |
| - runs-on: ubuntu-latest |
19 |
| - permissions: |
20 |
| - actions: read |
21 |
| - statuses: write |
22 |
| - outputs: |
23 |
| - pr_num: ${{ steps.set-ref.outputs.pr_num }} |
24 |
| - ref: ${{ steps.set-ref.outputs.ref }} |
25 |
| - steps: |
26 |
| - - name: Report pending |
27 |
| - uses: actions/github-script@v7 |
28 |
| - with: |
29 |
| - script: | |
30 |
| - const owner = '${{ github.repository_owner }}'; |
31 |
| - const repo = '${{ github.repository }}'.split('/')[1]; |
32 |
| - const sha = '${{ github.event.workflow_run.head_sha }}'; |
33 |
| - core.debug(`owner: ${owner}`); |
34 |
| - core.debug(`repo: ${repo}`); |
35 |
| - core.debug(`sha: ${sha}`); |
36 |
| - const { context: name, state } = (await github.rest.repos.createCommitStatus({ |
37 |
| - context: 'Runtime Tests / Wokwi (Get artifacts) (${{ github.event.workflow_run.event }} -> workflow_run)', |
38 |
| - owner: owner, |
39 |
| - repo: repo, |
40 |
| - sha: sha, |
41 |
| - state: 'pending', |
42 |
| - target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
43 |
| - })).data; |
44 |
| - core.info(`${name} is ${state}`); |
45 |
| -
|
46 |
| - - name: Download and extract event file |
47 |
| - uses: actions/download-artifact@v4 |
48 |
| - with: |
49 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
50 |
| - run-id: ${{ github.event.workflow_run.id }} |
51 |
| - name: event_file |
52 |
| - path: artifacts/event_file |
53 |
| - |
54 |
| - - name: Try to read PR number |
55 |
| - id: set-ref |
56 |
| - run: | |
57 |
| - pr_num=$(jq -r '.pull_request.number' artifacts/event_file/event.json) |
58 |
| - if [ -z "$pr_num" ] || [ "$pr_num" == "null" ]; then |
59 |
| - pr_num="" |
60 |
| - fi |
61 |
| -
|
62 |
| - ref=$pr_num |
63 |
| - if [ -z "$ref" ] || [ "$ref" == "null" ]; then |
64 |
| - ref=${{ github.ref }} |
65 |
| - fi |
66 |
| -
|
67 |
| - action=$(jq -r '.action' artifacts/event_file/event.json) |
68 |
| - if [ "$action" == "null" ]; then |
69 |
| - action="" |
70 |
| - fi |
71 |
| -
|
72 |
| - echo "pr_num = $pr_num" |
73 |
| -
|
74 |
| - printf "$ref" >> artifacts/ref.txt |
75 |
| - printf "Ref = " |
76 |
| - cat artifacts/ref.txt |
77 |
| -
|
78 |
| - printf "${{ github.event.workflow_run.event }}" >> artifacts/event.txt |
79 |
| - printf "\nEvent name = " |
80 |
| - cat artifacts/event.txt |
81 |
| -
|
82 |
| - printf "${{ github.event.workflow_run.head_sha || github.sha }}" >> artifacts/sha.txt |
83 |
| - printf "\nHead SHA = " |
84 |
| - cat artifacts/sha.txt |
85 |
| -
|
86 |
| - printf "$action" >> artifacts/action.txt |
87 |
| - printf "\nAction = " |
88 |
| - cat artifacts/action.txt |
89 |
| -
|
90 |
| - if [ -z "$ref" ] || [ "$ref" == "null" ]; then |
91 |
| - echo "Failed to get PR number or ref" |
92 |
| - exit 1 |
93 |
| - fi |
94 |
| -
|
95 |
| - conclusion="${{ github.event.workflow_run.conclusion }}" |
96 |
| - printf "$conclusion" >> artifacts/conclusion.txt |
97 |
| - printf "\nConclusion = " |
98 |
| - cat artifacts/conclusion.txt |
99 |
| -
|
100 |
| - echo "pr_num=$pr_num" >> $GITHUB_OUTPUT |
101 |
| - echo "ref=$ref" >> $GITHUB_OUTPUT |
102 |
| -
|
103 |
| - - name: Download and extract parent hardware results |
104 |
| - uses: actions/download-artifact@v4 |
105 |
| - continue-on-error: true |
106 |
| - with: |
107 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
108 |
| - run-id: ${{ github.event.workflow_run.id }} |
109 |
| - pattern: tests-results-hw-* |
110 |
| - merge-multiple: true |
111 |
| - path: artifacts/results/hw |
112 |
| - |
113 |
| - - name: Download and extract parent QEMU results |
114 |
| - uses: actions/download-artifact@v4 |
115 |
| - continue-on-error: true |
116 |
| - with: |
117 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
118 |
| - run-id: ${{ github.event.workflow_run.id }} |
119 |
| - pattern: tests-results-qemu-* |
120 |
| - merge-multiple: true |
121 |
| - path: artifacts/results/qemu |
122 |
| - |
123 |
| - - name: Upload parent artifacts |
124 |
| - uses: actions/upload-artifact@v4 |
125 |
| - with: |
126 |
| - name: parent-artifacts |
127 |
| - path: artifacts |
128 |
| - if-no-files-found: error |
129 |
| - |
130 |
| - - name: Report conclusion |
131 |
| - uses: actions/github-script@v7 |
132 |
| - if: always() |
133 |
| - with: |
134 |
| - script: | |
135 |
| - const owner = '${{ github.repository_owner }}'; |
136 |
| - const repo = '${{ github.repository }}'.split('/')[1]; |
137 |
| - const sha = '${{ github.event.workflow_run.head_sha }}'; |
138 |
| - core.debug(`owner: ${owner}`); |
139 |
| - core.debug(`repo: ${repo}`); |
140 |
| - core.debug(`sha: ${sha}`); |
141 |
| - const { context: name, state } = (await github.rest.repos.createCommitStatus({ |
142 |
| - context: 'Runtime Tests / Wokwi (Get artifacts) (${{ github.event.workflow_run.event }} -> workflow_run)', |
143 |
| - owner: owner, |
144 |
| - repo: repo, |
145 |
| - sha: sha, |
146 |
| - state: '${{ job.status }}', |
147 |
| - target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
148 |
| - })).data; |
149 |
| - core.info(`${name} is ${state}`); |
150 |
| -
|
151 |
| - wokwi-test: |
152 |
| - name: Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests |
153 |
| - if: | |
154 |
| - github.event.workflow_run.conclusion == 'success' || |
155 |
| - github.event.workflow_run.conclusion == 'failure' || |
156 |
| - github.event.workflow_run.conclusion == 'timed_out' |
157 |
| - runs-on: ubuntu-latest |
158 |
| - needs: get-artifacts |
159 |
| - env: |
160 |
| - id: ${{ needs.get-artifacts.outputs.ref }}-${{ github.event.workflow_run.head_sha || github.sha }}-${{ matrix.chip }}-${{ matrix.type }} |
161 |
| - permissions: |
162 |
| - actions: read |
163 |
| - statuses: write |
164 |
| - strategy: |
165 |
| - fail-fast: false |
166 |
| - matrix: |
167 |
| - type: ['validation'] |
168 |
| - chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2'] |
169 |
| - steps: |
170 |
| - - name: Report pending |
171 |
| - uses: actions/github-script@v7 |
172 |
| - with: |
173 |
| - script: | |
174 |
| - const owner = '${{ github.repository_owner }}'; |
175 |
| - const repo = '${{ github.repository }}'.split('/')[1]; |
176 |
| - const sha = '${{ github.event.workflow_run.head_sha }}'; |
177 |
| - core.debug(`owner: ${owner}`); |
178 |
| - core.debug(`repo: ${repo}`); |
179 |
| - core.debug(`sha: ${sha}`); |
180 |
| - const { context: name, state } = (await github.rest.repos.createCommitStatus({ |
181 |
| - context: 'Runtime Tests / Wokwi (${{ matrix.type }}, ${{ matrix.chip }}) / Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests (${{ github.event.workflow_run.event }} -> workflow_run)', |
182 |
| - owner: owner, |
183 |
| - repo: repo, |
184 |
| - sha: sha, |
185 |
| - state: 'pending', |
186 |
| - target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
187 |
| - })).data; |
188 |
| - core.info(`${name} is ${state}`); |
189 |
| -
|
190 |
| - - name: Check if already passed |
191 |
| - id: get-cache-results |
192 |
| - if: needs.get-artifacts.outputs.pr_num |
193 |
| - uses: actions/cache/restore@v4 |
194 |
| - with: |
195 |
| - key: tests-${{ env.id }}-results-wokwi |
196 |
| - path: | |
197 |
| - tests/**/*.xml |
198 |
| - tests/**/result_*.json |
199 |
| -
|
200 |
| - - name: Evaluate if tests should be run |
201 |
| - id: check-tests |
202 |
| - run: | |
203 |
| - cache_exists=${{ steps.get-cache-results.outputs.cache-hit == 'true' }} |
204 |
| - enabled=true |
205 |
| -
|
206 |
| - if [[ $cache_exists == 'true' ]]; then |
207 |
| - echo "Already ran, skipping" |
208 |
| - enabled=false |
209 |
| - fi |
210 |
| -
|
211 |
| - echo "enabled=$enabled" >> $GITHUB_OUTPUT |
212 |
| -
|
213 |
| - # Note that changes to the workflows and tests will only be picked up after the PR is merged |
214 |
| - - name: Checkout repository |
215 |
| - if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
216 |
| - uses: actions/checkout@v4 |
217 |
| - |
218 |
| - - uses: actions/setup-python@v5 |
219 |
| - if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
220 |
| - with: |
221 |
| - cache-dependency-path: tests/requirements.txt |
222 |
| - cache: 'pip' |
223 |
| - python-version: '3.x' |
224 |
| - |
225 |
| - - name: Install dependencies |
226 |
| - if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
227 |
| - run: | |
228 |
| - pip install -U pip |
229 |
| - pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi |
230 |
| -
|
231 |
| - - name: Install Wokwi CLI |
232 |
| - if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
233 |
| - run: curl -L https://wokwi.com/ci/install.sh | sh |
234 |
| - |
235 |
| - - name: Wokwi CI Server |
236 |
| - if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
237 |
| - uses: wokwi/wokwi-ci-server-action@v1 |
238 |
| - |
239 |
| - - name: Get binaries |
240 |
| - if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
241 |
| - uses: actions/download-artifact@v4 |
242 |
| - with: |
243 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
244 |
| - run-id: ${{ github.event.workflow_run.id }} |
245 |
| - name: tests-bin-${{ matrix.chip }}-${{ matrix.type }} |
246 |
| - path: | |
247 |
| - ~/.arduino/tests |
248 |
| -
|
249 |
| - - name: Run Tests |
250 |
| - if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
251 |
| - env: |
252 |
| - WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} |
253 |
| - run: | |
254 |
| - bash .github/scripts/tests_run.sh -c -type ${{ matrix.type }} -t ${{ matrix.chip }} -i 0 -m 1 -W ${{ env.WOKWI_TIMEOUT }} |
255 |
| -
|
256 |
| - - name: Upload ${{ matrix.chip }} ${{ matrix.type }} Wokwi results as cache |
257 |
| - uses: actions/cache/save@v4 |
258 |
| - if: steps.check-tests.outputs.enabled == 'true' && needs.get-artifacts.outputs.pr_num |
259 |
| - with: |
260 |
| - key: tests-${{ env.id }}-results-wokwi |
261 |
| - path: | |
262 |
| - tests/**/*.xml |
263 |
| - tests/**/result_*.json |
264 |
| -
|
265 |
| - - name: Upload ${{ matrix.chip }} ${{ matrix.type }} Wokwi results as artifacts |
266 |
| - uses: actions/upload-artifact@v4 |
267 |
| - if: always() |
268 |
| - with: |
269 |
| - name: tests-results-wokwi-${{ matrix.chip }}-${{ matrix.type }} |
270 |
| - overwrite: true |
271 |
| - path: | |
272 |
| - tests/**/*.xml |
273 |
| - tests/**/result_*.json |
274 |
| -
|
275 |
| - - name: Report conclusion |
276 |
| - uses: actions/github-script@v7 |
277 |
| - if: always() |
278 |
| - with: |
279 |
| - script: | |
280 |
| - const owner = '${{ github.repository_owner }}'; |
281 |
| - const repo = '${{ github.repository }}'.split('/')[1]; |
282 |
| - const sha = '${{ github.event.workflow_run.head_sha }}'; |
283 |
| - core.debug(`owner: ${owner}`); |
284 |
| - core.debug(`repo: ${repo}`); |
285 |
| - core.debug(`sha: ${sha}`); |
286 |
| - const { context: name, state } = (await github.rest.repos.createCommitStatus({ |
287 |
| - context: 'Runtime Tests / Wokwi (${{ matrix.type }}, ${{ matrix.chip }}) / Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests (${{ github.event.workflow_run.event }} -> workflow_run)', |
288 |
| - owner: owner, |
289 |
| - repo: repo, |
290 |
| - sha: sha, |
291 |
| - state: '${{ job.status }}', |
292 |
| - target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
293 |
| - })).data; |
294 |
| - core.info(`${name} is ${state}`); |
0 commit comments