Skip to content

Commit 77611c9

Browse files
committed
test(hw): Test HW tests
1 parent 5c8cc7a commit 77611c9

File tree

6 files changed

+252
-143
lines changed

6 files changed

+252
-143
lines changed

.github/workflows/tests_hw.yml

Lines changed: 0 additions & 122 deletions
This file was deleted.

.github/workflows/tests_wokwi.yml renamed to .github/workflows/tests_hw_wokwi.yml

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Wokwi tests
1+
name: Hardware and Wokwi tests
22

33
on:
44
workflow_run:
@@ -188,6 +188,179 @@ jobs:
188188
})).data;
189189
core.info(`${name} is ${state}`);
190190
191+
hardware-test:
192+
name: Hardware ${{ matrix.chip }} ${{ matrix.type }} tests
193+
if: |
194+
github.event.workflow_run.conclusion == 'success' ||
195+
github.event.workflow_run.conclusion == 'failure' ||
196+
github.event.workflow_run.conclusion == 'timed_out'
197+
runs-on: ubuntu-latest
198+
needs: get-artifacts
199+
env:
200+
id: ${{ needs.get-artifacts.outputs.ref }}-${{ github.event.workflow_run.head_sha || github.sha }}-${{ matrix.chip }}-${{ matrix.type }}
201+
permissions:
202+
actions: read
203+
statuses: write
204+
strategy:
205+
fail-fast: false
206+
matrix:
207+
type: ${{ fromJson(needs.get-artifacts.outputs.types) }}
208+
chip: ${{ fromJson(needs.get-artifacts.outputs.targets) }}
209+
steps:
210+
- name: Report pending
211+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
212+
with:
213+
script: |
214+
const owner = '${{ github.repository_owner }}';
215+
const repo = '${{ github.repository }}'.split('/')[1];
216+
const sha = '${{ github.event.workflow_run.head_sha }}';
217+
core.debug(`owner: ${owner}`);
218+
core.debug(`repo: ${repo}`);
219+
core.debug(`sha: ${sha}`);
220+
const { context: name, state } = (await github.rest.repos.createCommitStatus({
221+
context: 'Runtime Tests / Hardware (${{ matrix.type }}, ${{ matrix.chip }}) / Hardware ${{ matrix.chip }} ${{ matrix.type }} tests (${{ github.event.workflow_run.event }} -> workflow_run)',
222+
owner: owner,
223+
repo: repo,
224+
sha: sha,
225+
state: 'pending',
226+
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
227+
})).data;
228+
core.info(`${name} is ${state}`);
229+
230+
- name: Check if already passed
231+
id: get-cache-results
232+
if: needs.get-artifacts.outputs.pr_num
233+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
234+
with:
235+
key: test-${{ env.id }}-results-hw
236+
path: |
237+
tests/**/*.xml
238+
tests/**/result_*.json
239+
240+
- name: Evaluate if tests should be run
241+
id: check-tests
242+
run: |
243+
cache_exists=${{ steps.get-cache-results.outputs.cache-hit == 'true' }}
244+
enabled=true
245+
246+
if [[ $cache_exists == 'true' ]]; then
247+
echo "Already ran, skipping GitLab pipeline trigger"
248+
enabled=false
249+
else
250+
echo "Cache miss, will trigger GitLab pipeline for hardware tests"
251+
fi
252+
253+
echo "enabled=$enabled" >> $GITHUB_OUTPUT
254+
255+
- name: Checkout repository
256+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
257+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
258+
with:
259+
ref: ${{ needs.get-artifacts.outputs.base || github.ref }}
260+
261+
- name: Get test binaries
262+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
263+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
264+
with:
265+
github-token: ${{ secrets.GITHUB_TOKEN }}
266+
run-id: ${{ github.event.workflow_run.id }}
267+
name: test-bin-${{ matrix.chip }}-${{ matrix.type }}
268+
path: test-binaries
269+
270+
- name: Trigger GitLab Pipeline and Download Artifacts
271+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
272+
uses: digital-blueprint/[email protected]
273+
id: gitlab-trigger
274+
with:
275+
host: ${{ secrets.GITLAB_URL }}
276+
id: ${{ secrets.GITLAB_PROJECT_ID }}
277+
ref: 'ci/hw_gitlab'
278+
#ref: 'master'
279+
trigger_token: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
280+
access_token: ${{ secrets.GITLAB_ACCESS_TOKEN }}
281+
download_artifacts: 'true'
282+
download_artifacts_on_failure: 'true'
283+
download_path: './gitlab-artifacts'
284+
variables: |
285+
'{
286+
"TEST_TYPE":"${{ matrix.type }}",
287+
"TEST_CHIP":"${{ matrix.chip }}",
288+
"PIPELINE_ID":"${{ env.id }}",
289+
"BINARIES_RUN_ID":"${{ github.event.workflow_run.id }}",
290+
"GITHUB_REPOSITORY":"${{ github.repository }}"
291+
}'
292+
293+
- name: Process Downloaded Artifacts
294+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
295+
run: |
296+
echo "GitLab Pipeline Status: ${{ steps.gitlab-trigger.outputs.status }}"
297+
echo "Artifacts Downloaded: ${{ steps.gitlab-trigger.outputs.artifacts_downloaded }}"
298+
299+
# Create tests directory structure expected by GitHub caching
300+
mkdir -p tests
301+
302+
# Process downloaded GitLab artifacts
303+
if [ "${{ steps.gitlab-trigger.outputs.artifacts_downloaded }}" = "true" ]; then
304+
echo "Processing downloaded GitLab artifacts..."
305+
306+
# The action downloads artifacts organized by job:
307+
# gitlab-artifacts/job_123_job_name_1/artifacts/...
308+
# gitlab-artifacts/job_124_job_name_2/artifacts/...
309+
310+
# Print the contents of the gitlab-artifacts directory to debug
311+
echo "Contents of gitlab-artifacts directory:"
312+
ls -la ./gitlab-artifacts/
313+
314+
# Find and copy test result files
315+
find ./gitlab-artifacts -name "*.xml" -exec cp {} tests/ \;
316+
find ./gitlab-artifacts -name "result_*.json" -exec cp {} tests/ \;
317+
318+
echo "Test results found:"
319+
ls -la tests/ || echo "No test results found"
320+
else
321+
echo "No artifacts were downloaded from GitLab"
322+
fi
323+
324+
- name: Upload ${{ matrix.chip }} ${{ matrix.type }} hardware results as cache
325+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
326+
if: steps.check-tests.outputs.enabled == 'true' && needs.get-artifacts.outputs.pr_num
327+
with:
328+
key: test-${{ env.id }}-results-hw
329+
path: |
330+
tests/**/*.xml
331+
tests/**/result_*.json
332+
333+
- name: Upload ${{ matrix.chip }} ${{ matrix.type }} hardware results as artifacts
334+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
335+
if: always()
336+
with:
337+
name: test-results-hw-${{ matrix.chip }}-${{ matrix.type }}
338+
overwrite: true
339+
path: |
340+
tests/**/*.xml
341+
tests/**/result_*.json
342+
343+
- name: Report conclusion
344+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
345+
if: always()
346+
with:
347+
script: |
348+
const owner = '${{ github.repository_owner }}';
349+
const repo = '${{ github.repository }}'.split('/')[1];
350+
const sha = '${{ github.event.workflow_run.head_sha }}';
351+
core.debug(`owner: ${owner}`);
352+
core.debug(`repo: ${repo}`);
353+
core.debug(`sha: ${sha}`);
354+
const { context: name, state } = (await github.rest.repos.createCommitStatus({
355+
context: 'Runtime Tests / Hardware (${{ matrix.type }}, ${{ matrix.chip }}) / Hardware ${{ matrix.chip }} ${{ matrix.type }} tests (${{ github.event.workflow_run.event }} -> workflow_run)',
356+
owner: owner,
357+
repo: repo,
358+
sha: sha,
359+
state: '${{ job.status }}',
360+
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
361+
})).data;
362+
core.info(`${name} is ${state}`);
363+
191364
wokwi-test:
192365
name: Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests
193366
if: |

.github/workflows/tests_results.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish and clean test results
22

33
on:
44
workflow_run:
5-
workflows: ["Wokwi tests"]
5+
workflows: ["Hardware and Wokwi tests"]
66
types:
77
- completed
88

@@ -80,8 +80,8 @@ jobs:
8080
8181
- name: Print links to other runs
8282
run: |
83-
echo "Build, Hardware and QEMU tests: https://github.com/${{ github.repository }}/actions/runs/${{ env.original_run_id }}"
84-
echo "Wokwi tests: https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}"
83+
echo "Build and QEMU tests: https://github.com/${{ github.repository }}/actions/runs/${{ env.original_run_id }}"
84+
echo "Hardware and Wokwi tests: https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}"
8585
8686
- name: Publish Unit Test Results
8787
uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ workflow:
2222

2323
include:
2424
- ".gitlab/workflows/common.yml"
25-
- ".gitlab/workflows/sample.yml"
25+
- ".gitlab/workflows/hardware_tests.yml"

0 commit comments

Comments
 (0)