Skip to content

Commit fe58ac0

Browse files
committed
Merge branch 'ci/remove_target'
2 parents b01c318 + 15e9c93 commit fe58ac0

File tree

6 files changed

+141
-70
lines changed

6 files changed

+141
-70
lines changed

.github/workflows/build_tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
id: ${{ github.event.pull_request.number || github.ref }}-${{ github.event.pull_request.head.sha || github.sha }}-${{ inputs.chip }}-${{ inputs.type }}
2121
steps:
2222
- name: Check if already built
23-
if: ${{ github.event.pull_request.number != null }}
2423
id: cache-build-binaries
2524
uses: actions/cache/restore@v4
2625
with:

.github/workflows/hw.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ jobs:
2222
image: python:3.10.1-bullseye
2323
options: --privileged
2424
steps:
25-
- name: Check if already built
26-
if: ${{ github.event.pull_request.number != null }}
25+
- name: Check if already passed
2726
id: cache-results
2827
uses: actions/cache/restore@v4
2928
with:
@@ -80,7 +79,7 @@ jobs:
8079
8180
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} hardware results as cache
8281
uses: actions/cache/save@v4
83-
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
82+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
8483
with:
8584
key: tests-${{ env.id }}-results-hw
8685
path: |

.github/workflows/qemu.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
QEMU_INSTALL_PATH: "$HOME"
1919
runs-on: ubuntu-latest
2020
steps:
21-
- name: Check if already run
22-
if: ${{ github.event.pull_request.number != null }}
21+
- name: Check if already passed
2322
id: get-cache-results
2423
uses: actions/cache/restore@v4
2524
with:
@@ -125,7 +124,7 @@ jobs:
125124

126125
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} QEMU results as cache
127126
uses: actions/cache/save@v4
128-
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
127+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
129128
with:
130129
key: tests-${{ env.id }}-results-qemu
131130
path: |

.github/workflows/tests.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ on:
55
pull_request:
66
types: [opened, reopened, synchronize, labeled, unlabeled]
77
paths:
8+
- '.github/workflows/tests.yml'
9+
- '.github/workflows/build_tests.yml'
10+
- '.github/workflows/hw.yml'
11+
- '.github/workflows/qemu.yml'
12+
- '.github/workflows/wokwi.yml'
13+
- '.github/workflows/tests_publish.yml'
14+
- '.github/scripts/*.sh'
15+
- '!.github/scripts/check-cmakelists.sh'
16+
- '!.github/scripts/find_*'
17+
- '!.github/scripts/on-*.sh'
18+
- '!.github/scripts/set_push_chunks.sh'
19+
- '!.github/scripts/update-version.sh'
20+
- '!.github/scripts/upload_py_tools.sh'
821
- 'tests/**'
922
- 'cores/**'
1023
- 'libraries/**'
@@ -74,6 +87,8 @@ jobs:
7487
type: ${{ matrix.type }}
7588
chip: ${{ matrix.chip }}
7689

90+
# Wokwi tests are run after this workflow as it needs access to secrets
91+
7792
call-hardware-tests:
7893
name: Hardware
7994
uses: ./.github/workflows/hw.yml
@@ -91,8 +106,6 @@ jobs:
91106
type: ${{ matrix.type }}
92107
chip: ${{ matrix.chip }}
93108

94-
# Wokwi tests are run after this workflow as it needs access to secrets
95-
96109
# This job is disabled for now
97110
call-qemu-tests:
98111
name: QEMU

.github/workflows/tests_publish.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,26 @@ jobs:
2222
checks: write
2323
pull-requests: write
2424
steps:
25-
- name: Print info
26-
run: |
27-
echo "Event: ${{ github.event.workflow_run.event }}"
28-
echo "Conclusion: ${{ github.event.workflow_run.conclusion }}"
29-
echo "Status: ${{ github.event.workflow_run.status }}"
30-
echo "Head SHA: ${{ github.event.workflow_run.head_sha }}"
31-
echo "Parent Run ID: ${{ github.event.workflow_run.id }}"
32-
echo "Run Number: ${{ github.run_number }}"
33-
echo "Run ID: ${{ github.run_id }}"
34-
echo "Ref: ${{ github.ref }}"
35-
3625
- name: Download and Extract Artifacts
37-
uses: dawidd6/action-download-artifact@v6
38-
with:
39-
workflow: tests.yml
40-
commit: ${{ github.event.workflow_run.head_sha }}
41-
path: ./artifacts
42-
allow_forks: true
43-
44-
- name: Download and Extract Wokwi Results
4526
uses: dawidd6/action-download-artifact@v6
4627
with:
4728
run_id: ${{ github.event.workflow_run.id }}
4829
path: ./artifacts
4930

50-
- name: List files
31+
- name: Get original info
5132
run: |
52-
ls -R ./artifacts
33+
original_event=$(cat ./artifacts/event.txt)
34+
original_sha=$(cat ./artifacts/sha.txt)
35+
echo "original_event=$original_event" >> $GITHUB_ENV
36+
echo "original_sha=$original_sha" >> $GITHUB_ENV
37+
38+
echo "original_event = $original_event"
39+
echo "original_sha = $original_sha"
5340
5441
- name: Publish Unit Test Results
5542
uses: EnricoMi/publish-unit-test-result-action@v2
5643
with:
57-
commit: ${{ github.event.workflow_run.head_sha }}
44+
commit: ${{ env.original_sha }}
5845
event_file: ./artifacts/event_file/event.json
59-
event_name: ${{ github.event.workflow_run.event }}
46+
event_name: ${{ env.original_event }}
6047
files: ./artifacts/**/*.xml

.github/workflows/wokwi.yml

Lines changed: 112 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,121 @@ env:
1313
WOKWI_TIMEOUT: 600000 # Milliseconds
1414

1515
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+
16121
wokwi-test:
17122
name: Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests
18123
if: |
19124
github.event.workflow_run.conclusion == 'success' ||
20125
github.event.workflow_run.conclusion == 'failure' ||
21126
github.event.workflow_run.conclusion == 'timed_out'
22127
runs-on: ubuntu-latest
128+
needs: get-artifacts
23129
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 }}
25131
permissions:
26132
actions: read
27133
statuses: write
@@ -42,7 +148,7 @@ jobs:
42148
core.debug(`repo: ${repo}`);
43149
core.debug(`sha: ${sha}`);
44150
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)',
46152
owner: owner,
47153
repo: repo,
48154
sha: sha,
@@ -51,7 +157,7 @@ jobs:
51157
})).data;
52158
core.info(`${name} is ${state}`);
53159
54-
- name: Check if already run
160+
- name: Check if already passed
55161
id: get-cache-results
56162
uses: actions/cache/restore@v4
57163
with:
@@ -73,24 +179,10 @@ jobs:
73179
74180
echo "enabled=$enabled" >> $GITHUB_OUTPUT
75181
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
77184
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
78185
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
94186

95187
- uses: actions/setup-python@v5
96188
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
@@ -113,24 +205,6 @@ jobs:
113205
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
114206
uses: wokwi/wokwi-ci-server-action@v1
115207

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-
134208
- name: Get binaries
135209
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
136210
uses: actions/download-artifact@v4
@@ -150,7 +224,7 @@ jobs:
150224
151225
- name: Upload ${{ matrix.chip }} ${{ matrix.type }} Wokwi results as cache
152226
uses: actions/cache/save@v4
153-
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
227+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
154228
with:
155229
key: tests-${{ env.id }}-results-wokwi
156230
path: |

0 commit comments

Comments
 (0)