Skip to content

Commit aad5f80

Browse files
committed
Merge branch 'master' into ci/tests_refactor
2 parents a8362d3 + 9776e65 commit aad5f80

File tree

8 files changed

+104
-89
lines changed

8 files changed

+104
-89
lines changed

.github/scripts/sketch_utils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
157157
build_dir="$ARDUINO_BUILD_DIR"
158158
elif [ $len -eq 1 ]; then
159159
# build_dir="$sketchdir/build"
160-
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp"
160+
build_dir="$HOME/.arduino/tests/$sketchname/$target/build.tmp"
161161
fi
162162

163163
output_file="$HOME/.arduino/cli_compile_output.txt"
@@ -168,7 +168,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
168168
do
169169
if [ $len -ne 1 ]; then
170170
# build_dir="$sketchdir/build$i"
171-
build_dir="$HOME/.arduino/tests/$sketchname/build$i.tmp"
171+
build_dir="$HOME/.arduino/tests/$sketchname/$target/build$i.tmp"
172172
fi
173173
rm -rf $build_dir
174174
mkdir -p $build_dir

.github/scripts/tests_run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function run_test() {
3333

3434
if [ $len -eq 1 ]; then
3535
# build_dir="$sketchdir/build"
36-
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp"
36+
build_dir="$HOME/.arduino/tests/$sketchname/$target/build.tmp"
3737
report_file="$sketchdir/$sketchname.xml"
3838
fi
3939

@@ -57,7 +57,7 @@ function run_test() {
5757

5858
if [ $len -ne 1 ]; then
5959
# build_dir="$sketchdir/build$i"
60-
build_dir="$HOME/.arduino/tests/$sketchname/build$i.tmp"
60+
build_dir="$HOME/.arduino/tests/$sketchname/$target/build$i.tmp"
6161
report_file="$sketchdir/$sketchname$i.xml"
6262
fi
6363

.github/workflows/build_tests.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ jobs:
2121
name: Build ${{ inputs.type }} tests for ${{ inputs.chip }}
2222
runs-on: ubuntu-latest
2323
env:
24-
id: ${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}-${{ github.event.pull_request.head.sha || github.sha }}
24+
id: ${{ github.event.pull_request.number || github.ref }}-${{ github.event.pull_request.head.sha || github.sha }}-${{ inputs.chip }}-${{ inputs.type }}
2525
steps:
2626
- name: Check if already built
2727
if: ${{ github.event.pull_request.number != null }}
2828
id: cache-build-binaries
2929
uses: actions/cache/restore@v4
3030
with:
31-
lookup-only: true
32-
key: tests-bin-${{ env.id }}
31+
key: tests-${{ env.id }}-bin
3332
path: |
3433
~/.arduino/tests/**/build*.tmp/*.bin
3534
~/.arduino/tests/**/build*.tmp/*.elf
@@ -73,11 +72,20 @@ jobs:
7372
run: |
7473
bash .github/scripts/tests_build.sh -c -type ${{ inputs.type }} -t ${{ inputs.chip }}
7574
76-
- name: Upload ${{ inputs.chip }}-${{ inputs.type }} binaries as cache
75+
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} binaries as cache
7776
uses: actions/cache/save@v4
7877
if: ${{ steps.check-build.outputs.enabled == 'true' }}
7978
with:
80-
key: tests-bin-${{ env.id }}
79+
key: tests-${{ env.id }}-bin
80+
path: |
81+
~/.arduino/tests/**/build*.tmp/*.bin
82+
~/.arduino/tests/**/build*.tmp/*.elf
83+
~/.arduino/tests/**/build*.tmp/*.json
84+
85+
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} binaries as artifacts
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: tests-bin-${{ inputs.chip }}-${{ inputs.type }}
8189
path: |
8290
~/.arduino/tests/**/build*.tmp/*.bin
8391
~/.arduino/tests/**/build*.tmp/*.elf

.github/workflows/hw.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Hardware ${{ inputs.chip }} ${{ inputs.type }} tests
2222
runs-on: [arduino, "${{ inputs.chip }}"]
2323
env:
24-
id: ${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}-${{ github.event.pull_request.head.sha || github.sha }}
24+
id: ${{ github.event.pull_request.number || github.ref }}-${{ github.event.pull_request.head.sha || github.sha }}-${{ inputs.chip }}-${{ inputs.type }}
2525
container:
2626
image: python:3.10.1-bullseye
2727
options: --privileged
@@ -31,8 +31,7 @@ jobs:
3131
id: cache-results
3232
uses: actions/cache/restore@v4
3333
with:
34-
lookup-only: true
35-
key: tests-hw-${{ env.id }}
34+
key: tests-${{ env.id }}-results-hw
3635
path: |
3736
tests/**/*.xml
3837
tests/**/result_*.json
@@ -89,7 +88,16 @@ jobs:
8988
uses: actions/cache/save@v4
9089
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
9190
with:
92-
key: tests-hw-${{ env.id }}
91+
key: tests-${{ env.id }}-results-hw
92+
path: |
93+
tests/**/*.xml
94+
tests/**/result_*.json
95+
96+
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} hardware results as artifacts
97+
uses: actions/upload-artifact@v4
98+
if: always()
99+
with:
100+
name: tests-results-hw-${{ inputs.chip }}-${{ inputs.type }}
93101
path: |
94102
tests/**/*.xml
95103
tests/**/result_*.json

.github/workflows/publish.yml

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

.github/workflows/qemu.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
qemu-test:
1919
name: QEMU ${{ inputs.chip }} ${{ inputs.type }} tests
2020
env:
21-
id: ${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}-${{ github.event.pull_request.head.sha || github.sha }}
21+
id: ${{ github.event.pull_request.number || github.ref }}-${{ github.event.pull_request.head.sha || github.sha }}-${{ inputs.chip }}-${{ inputs.type }}
2222
QEMU_INSTALL_PATH: "$HOME"
2323
runs-on: ubuntu-latest
2424
steps:
@@ -27,8 +27,7 @@ jobs:
2727
id: get-cache-results
2828
uses: actions/cache/restore@v4
2929
with:
30-
lookup-only: true
31-
key: tests-qemu-${{ env.id }}
30+
key: tests-${{ env.id }}-results-qemu
3231
path: |
3332
tests/**/*.xml
3433
tests/**/result_*.json
@@ -122,7 +121,16 @@ jobs:
122121
uses: actions/cache/save@v4
123122
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
124123
with:
125-
key: tests-qemu-${{ env.id }}
124+
key: tests-${{ env.id }}-results-qemu
125+
path: |
126+
tests/**/*.xml
127+
tests/**/result_*.json
128+
129+
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} QEMU results as artifacts
130+
uses: actions/upload-artifact@v4
131+
if: always()
132+
with:
133+
name: tests-results-qemu-${{ inputs.chip }}-${{ inputs.type }}
126134
path: |
127135
tests/**/*.xml
128136
tests/**/result_*.json

.github/workflows/tests.yml

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,48 @@ jobs:
123123
type: ${{ matrix.type }}
124124
chip: ${{ matrix.chip }}
125125

126+
unit-test-results:
127+
name: Unit Test Results
128+
needs: [call-hardware-tests, call-wokwi-tests, call-qemu-tests]
129+
if: always() && github.event_name == 'pull_request_target'
130+
runs-on: ubuntu-latest
131+
permissions:
132+
checks: write
133+
pull-requests: write
134+
steps:
135+
- name: Download and Extract HW Artifacts
136+
uses: actions/download-artifact@v4
137+
continue-on-error: true
138+
with:
139+
merge-multiple: true
140+
pattern: test-results-hw-*
141+
path: ./results/hw
142+
143+
- name: Download and Extract Wokwi Artifacts
144+
uses: actions/download-artifact@v4
145+
continue-on-error: true
146+
with:
147+
merge-multiple: true
148+
pattern: test-results-wokwi-*
149+
path: ./results/wokwi
150+
151+
- name: Download and Extract QEMU Artifacts
152+
uses: actions/download-artifact@v4
153+
continue-on-error: true
154+
with:
155+
merge-multiple: true
156+
pattern: test-results-qemu-*
157+
path: ./results/qemu
158+
159+
- name: Publish Unit Test Results
160+
uses: EnricoMi/publish-unit-test-result-action@v2
161+
with:
162+
commit: ${{ github.event.pull_request.head.sha || github.sha }}
163+
files: ./results/**/*.xml
126164
clean:
127165
name: Clean objects
128-
needs: [call-hardware-tests, call-wokwi-tests, call-qemu-tests]
129-
if: always()
166+
needs: unit-test-results
167+
if: always() && ${{ github.event_name }} == 'pull_request_target' && ${{ github.event.action }} != 'closed'
130168
permissions:
131169
actions: write
132170
runs-on: ubuntu-latest
@@ -135,36 +173,18 @@ jobs:
135173
uses: actions/github-script@v7
136174
with:
137175
script: |
138-
// Check if event is not a pull request or is a closed pull request
139-
if ('${{ github.event_name }}' == 'pull_request_target' && '${{ github.event.action }}' != 'closed') {
140-
console.log('Skipping cache cleanup');
141-
return;
142-
}
143-
144-
const sha = '${{ github.event.pull_request.head.sha || github.sha }}';
145-
const pr = '${{ github.event.pull_request.number }}';
146176
const ref = '${{ github.event.pull_request.number || github.ref }}';
147-
const regex = new RegExp("^tests-[\\w]+-"+ref+"-", "m"); // Match "tests-<type>-<ref>-" in cache key
148-
149-
console.log(`ref: ${ref}, SHA: ${sha}`);
177+
const key_prefix = 'tests-' + ref + '-';
150178
151179
await github.paginate(github.rest.actions.getActionsCacheList, {
152180
owner: context.repo.owner,
153181
repo: context.repo.repo,
154182
per_page: 100,
155-
sort: 'created_at',
156-
direction: 'asc',
157-
key: 'tests-'
183+
key: key_prefix
158184
}).then(caches => {
159185
if (caches) {
160186
for (const cache of caches) {
161-
if (cache.key.endsWith(sha) || !regex.test(cache.key) || (!pr && !cache.key.startsWith("tests-bin-"))) {
162-
console.log(`Skipping cache with key: ${cache.key}`);
163-
continue;
164-
}
165-
166187
console.log(`Deleting cache: ${cache.key}`);
167-
168188
github.rest.actions.deleteActionsCacheById({
169189
owner: context.repo.owner,
170190
repo: context.repo.repo,

.github/workflows/wokwi.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ jobs:
2727
wokwi-test:
2828
name: Wokwi ${{ inputs.chip }} ${{ inputs.type }} tests
2929
env:
30-
id: ${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}-${{ github.event.pull_request.head.sha || github.sha }}
30+
id: ${{ github.event.pull_request.number || github.ref }}-${{ github.event.pull_request.head.sha || github.sha }}-${{ inputs.chip }}-${{ inputs.type }}
3131
runs-on: ubuntu-latest
3232
steps:
33-
- name: Check if already run
34-
if: ${{ github.event.pull_request.number != null }}
35-
id: get-cache-results
36-
uses: actions/cache/restore@v4
37-
with:
38-
lookup-only: true
39-
key: tests-wokwi-${{ env.id }}
40-
path: |
41-
tests/**/*.xml
42-
tests/**/result_*.json
33+
# Disabled as Wokwi infrastrucutre is not stable (so we can re-trigger the tests manually)
34+
# - name: Check if already run
35+
# if: ${{ github.event.pull_request.number != null }}
36+
# id: get-cache-results
37+
# uses: actions/cache/restore@v4
38+
# with:
39+
# key: tests-${{ env.id }}-results-wokwi
40+
# path: |
41+
# tests/**/*.xml
42+
# tests/**/result_*.json
4343

4444
- name: Evaluate if tests should be run
4545
id: check-tests
@@ -100,7 +100,16 @@ jobs:
100100
uses: actions/cache/save@v4
101101
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
102102
with:
103-
key: tests-wokwi-${{ env.id }}
103+
key: tests-${{ env.id }}-results-wokwi
104+
path: |
105+
tests/**/*.xml
106+
tests/**/result_*.json
107+
108+
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} Wokwi results as artifacts
109+
uses: actions/upload-artifact@v4
110+
if: always()
111+
with:
112+
name: tests-results-wokwi-${{ inputs.chip }}-${{ inputs.type }}
104113
path: |
105114
tests/**/*.xml
106115
tests/**/result_*.json

0 commit comments

Comments
 (0)