Skip to content

Commit 3e82516

Browse files
committed
Fix
1 parent 0700f44 commit 3e82516

File tree

5 files changed

+148
-129
lines changed

5 files changed

+148
-129
lines changed

.github/workflows/build_tests.yml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@ name: Build tests
22

33
on:
44
workflow_call:
5+
inputs:
6+
type:
7+
type: string
8+
description: 'Type of tests to build'
9+
required: true
10+
chip:
11+
type: string
12+
description: 'Chip to build tests for'
13+
required: true
514

615
concurrency:
716
group: tests-build-${{ github.event.pull_request.number || github.ref }}
817
cancel-in-progress: true
918

1019
jobs:
1120
build-tests:
12-
name: Build ${{ matrix.type }} tests for ${{ matrix.chip }}
21+
name: Build ${{ inputs.type }} tests for ${{ inputs.chip }}
1322
runs-on: ubuntu-latest
14-
strategy:
15-
matrix:
16-
type: ['validation', 'performance']
17-
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
1823
env:
19-
id: ${{ github.event.pull_request.number || github.ref }}-${{ matrix.chip }}-${{ matrix.type }}-${{ github.event.pull_request.head.sha || github.sha }}
24+
id: ${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}-${{ github.event.pull_request.head.sha || github.sha }}
2025
steps:
2126
- name: Check if already built
2227
if: ${{ github.event.pull_request.number != null }}
@@ -34,25 +39,11 @@ jobs:
3439
id: check-build
3540
run: |
3641
cache_exists=${{ steps.cache-build-binaries.outputs.cache-hit == 'true' || false }}
37-
is_pr=${{ github.event.pull_request.number != null }}
38-
is_performance_test=${{ matrix.type == 'performance' }}
39-
is_performance_enabled=${{ contains(github.event.pull_request.labels.*.name, 'perf_test') }}
4042
enabled=true
4143
4244
if [[ $cache_exists == 'true' ]]; then
4345
echo "Already built, skipping"
4446
enabled=false
45-
elif [[ $is_pr != 'true' ]]; then
46-
echo "Not a PR, building"
47-
elif [[ $is_performance_test == 'true' ]]; then
48-
if [[ $is_performance_enabled == 'true' ]]; then
49-
echo "Performance test enabled, building"
50-
else
51-
echo "Performance test disabled, skipping"
52-
enabled=false
53-
fi
54-
else
55-
echo "Validation test, building"
5647
fi
5748
5849
echo "enabled=$enabled" >> $GITHUB_OUTPUT
@@ -66,9 +57,9 @@ jobs:
6657
- name: Build sketches
6758
if: ${{ steps.check-build.outputs.enabled == 'true' }}
6859
run: |
69-
bash .github/scripts/tests_build.sh -c -type ${{ matrix.type }} -t ${{ matrix.chip }}
60+
bash .github/scripts/tests_build.sh -c -type ${{ inputs.type }} -t ${{ inputs.chip }}
7061
71-
- name: Upload ${{ matrix.chip }}-${{ matrix.type }} binaries as cache
62+
- name: Upload ${{ inputs.chip }}-${{ inputs.type }} binaries as cache
7263
uses: actions/cache/save@v4
7364
if: ${{ steps.check-build.outputs.enabled == 'true' }}
7465
with:

.github/workflows/clean.yml

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

.github/workflows/hw.yml

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@ name: Hardware tests
22

33
on:
44
workflow_call:
5+
inputs:
6+
type:
7+
type: string
8+
description: 'Type of tests to run'
9+
required: true
10+
chip:
11+
type: string
12+
description: 'Chip to run tests for'
13+
required: true
514

615
concurrency:
716
group: tests-hw-${{ github.event.pull_request.number || github.ref }}
817
cancel-in-progress: true
918

1019
jobs:
1120
hardware-test:
12-
name: Hardware ${{ matrix.chip }} ${{ matrix.type }} tests
13-
runs-on: [arduino, "${{ matrix.chip }}"]
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
type: ['validation', 'performance']
18-
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
21+
name: Hardware ${{ inputs.chip }} ${{ inputs.type }} tests
22+
runs-on: [arduino, "${{ inputs.chip }}"]
1923
env:
20-
id: ${{ github.event.pull_request.number || github.ref }}-${{ matrix.chip }}-${{ matrix.type }}-${{ github.event.pull_request.head.sha || github.sha }}
24+
id: ${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}-${{ github.event.pull_request.head.sha || github.sha }}
2125
container:
2226
image: python:3.10.1-bullseye
2327
options: --privileged
@@ -37,25 +41,11 @@ jobs:
3741
id: check-tests
3842
run: |
3943
cache_exists=${{ steps.cache-results.outputs.cache-hit == 'true' || false }}
40-
is_pr=${{ github.event.pull_request.number != null }}
41-
is_performance_test=${{ matrix.type == 'performance' }}
42-
is_performance_enabled=${{ contains(github.event.pull_request.labels.*.name, 'perf_test') }}
4344
enabled=true
4445
4546
if [[ $cache_exists == 'true' ]]; then
4647
echo "Already ran, skipping"
4748
enabled=false
48-
elif [[ $is_pr != 'true' ]]; then
49-
echo "Not a PR, running"
50-
elif [[ $is_performance_test == 'true' ]]; then
51-
if [[ $is_performance_enabled == 'true' ]]; then
52-
echo "Performance test enabled, running"
53-
else
54-
echo "Performance test disabled, skipping"
55-
enabled=false
56-
fi
57-
else
58-
echo "Validation test, running"
5949
fi
6050
6151
echo "enabled=$enabled" >> $GITHUB_OUTPUT
@@ -66,12 +56,6 @@ jobs:
6656
with:
6757
ref: ${{ github.event.pull_request.head.sha || github.sha }}
6858

69-
- uses: actions/setup-python@v5
70-
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
71-
with:
72-
cache: 'pip'
73-
python-version: '3.10.1'
74-
7559
- name: Get binaries
7660
id: cache-build-binaries
7761
uses: actions/cache/restore@v4
@@ -93,9 +77,9 @@ jobs:
9377
- name: Run Tests
9478
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
9579
run: |
96-
bash .github/scripts/tests_run.sh -type ${{ matrix.type }} -t ${{ matrix.chip }} -e
80+
bash .github/scripts/tests_run.sh -c -type ${{ inputs.type }} -t ${{ inputs.chip }} -i 0 -m 1 -e
9781
98-
- name: Upload ${{ matrix.chip }}-${{ matrix.type }} results as cache
82+
- name: Upload ${{ inputs.chip }}-${{ inputs.type }} results as cache
9983
uses: actions/cache/save@v4
10084
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
10185
with:

.github/workflows/tests.yml

Lines changed: 108 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,128 @@ concurrency:
1414
permissions: read-all
1515

1616
jobs:
17+
gen-matrix:
18+
name: Generate matrix
19+
if: github.event.action != 'closed'
20+
runs-on: ubuntu-latest
21+
outputs:
22+
build-types: ${{ steps.set-matrix.outputs.build-types }}
23+
hw-types: ${{ steps.set-matrix.outputs.hw-types }}
24+
wokwi-types: ${{ steps.set-matrix.outputs.wokwi-types }}
25+
qemu-types: ${{ steps.set-matrix.outputs.qemu-types }}
26+
steps:
27+
- name: Set matrix
28+
id: set-matrix
29+
run: |
30+
build_types=[\"validation\"
31+
hw_types=[\"validation\"
32+
wokwi_types=["validation\"
33+
qemu_types=[\"validation\"
34+
35+
is_pr=${{ github.event.pull_request.number != null }}
36+
is_performance_enabled=${{ contains(github.event.pull_request.labels.*.name, 'perf_test') }}
37+
38+
if [[ $is_pr != 'true' ]] || [[ $is_performance_enabled == 'true' ]]; then
39+
build_types+=,\"performance\"
40+
hw_types+=,\"performance\"
41+
#wokwi_types+=,\"performance\"
42+
#qemu_types+=,\"performance\"
43+
fi
44+
45+
echo "build-types=$build_types]" >> $GITHUB_OUTPUT
46+
echo "hw-types=$hw_types]" >> $GITHUB_OUTPUT
47+
echo "wokwi-types=$wokwi_types]" >> $GITHUB_OUTPUT
48+
echo "qemu-types=$qemu_types]" >> $GITHUB_OUTPUT
49+
1750
call-build-tests:
1851
name: Build tests
19-
if: github.event.action != 'closed'
2052
uses: ./.github/workflows/build_tests.yml
53+
needs: gen-matrix
54+
if: github.event.action != 'closed'
55+
strategy:
56+
matrix:
57+
type: ${{ fromJson(needs.gen-matrix.outputs.build-types) }}
58+
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
2159

2260
call-hardware-tests:
2361
name: Run tests on hardware
2462
uses: ./.github/workflows/hw.yml
25-
needs: call-build-tests
26-
#if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'hil_test') }}
27-
if: false
63+
needs: [gen-matrix, call-build-tests]
64+
if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'hil_test') }}
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
type: ${{ fromJson(needs.gen-matrix.outputs.hw-types) }}
69+
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
2870

2971
call-wokwi-tests:
3072
uses: ./.github/workflows/wokwi.yml
31-
needs: call-build-tests
73+
needs: [gen-matrix, call-build-tests]
74+
if: github.event.action != 'closed'
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
type: ${{ fromJson(needs.gen-matrix.outputs.wokwi-types) }}
79+
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
3280
secrets:
3381
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
3482

3583
# call-qemu-tests:
36-
# uses: espressif/arduino-esp32/.github/workflows/qemu.yml@master
37-
# needs: [call-build-validation-tests]
38-
# permissions:
39-
# contents: read
40-
# strategy:
41-
# matrix:
42-
# chip: ['esp32', 'esp32c3']
43-
# with:
44-
# chip: ${{matrix.chip}}
45-
# type: "validation"
46-
# ref: ${{ github.event.pull_request.number || github.ref }}
47-
48-
call-clean:
84+
# uses: ./.github/workflows/qemu.yml@master
85+
# needs: [gen-matrix, call-build-tests]
86+
# strategy:
87+
# matrix:
88+
# type: ${{ fromJson(needs.gen-matrix.outputs.qemu-types) }}
89+
# chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
90+
91+
clean:
4992
name: Clean objects
50-
uses: ./.github/workflows/clean.yml
51-
needs: [call-build-tests, call-hardware-tests, call-wokwi-tests]
52-
if: always() && (github.event_name != 'pull_request' || github.event.action == 'closed')
93+
needs: [call-hardware-tests, call-wokwi-tests]
94+
if: always()
5395
permissions:
5496
actions: write
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Clean up caches
100+
uses: actions/github-script@v7
101+
with:
102+
script: |
103+
// Check if event is not a pull request or is a closed pull request
104+
if (github.event_name === 'pull_request' && github.event.action !== 'closed') {
105+
console.log('Skipping cache cleanup');
106+
return;
107+
}
108+
109+
const ref = "${{ github.event.pull_request.number || github.ref }}";
110+
const cacheKeysPattern = `tests-bin-${ref}-*`;
111+
112+
console.log(`Deleting caches matching pattern: ${cacheKeysPattern}`);
113+
114+
// Fetch all cache entries for the repository
115+
const caches = await github.rest.actions.getActionsCacheList({
116+
owner: context.repo.owner,
117+
repo: context.repo.repo,
118+
});
119+
120+
if (caches.data) {
121+
console.log(`Found ${caches.data.actions_caches.length} caches.`);
122+
console.log(caches.data.actions_caches.map(cache => cache.key));
123+
// Filter caches matching the specified pattern
124+
const matchingCaches = caches.data.actions_caches.filter(cache =>
125+
cache.key.startsWith(cacheKeysPattern)
126+
);
127+
128+
// Delete matching caches
129+
for (const cache of matchingCaches) {
130+
/*
131+
await github.rest.actions.deleteActionsCacheById({
132+
owner: context.repo.owner,
133+
repo: context.repo.repo,
134+
cache_id: cache.id
135+
});
136+
*/
137+
console.log(`Deleted cache with key: ${cache.key}`);
138+
}
139+
140+
console.log(`Deleted ${matchingCaches.length} caches.`);
141+
}

.github/workflows/wokwi.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: Wokwi tests
22

33
on:
44
workflow_call:
5+
inputs:
6+
chip:
7+
type: string
8+
description: 'Chip to run tests for'
9+
required: true
10+
type:
11+
type: string
12+
description: 'Type of tests to run'
13+
required: true
514
secrets:
615
WOKWI_CLI_TOKEN:
716
description: 'Wokwi CLI API token'
@@ -16,14 +25,9 @@ env:
1625

1726
jobs:
1827
wokwi-test:
19-
name: Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests
20-
strategy:
21-
fail-fast: false
22-
matrix:
23-
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
24-
type: ['validation']
28+
name: Wokwi ${{ inputs.chip }} ${{ inputs.type }} tests
2529
env:
26-
id: ${{ github.event.pull_request.number || github.ref }}-${{ matrix.chip }}-${{ matrix.type }}-${{ github.event.pull_request.head.sha || github.sha }}
30+
id: ${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}-${{ github.event.pull_request.head.sha || github.sha }}
2731
runs-on: ubuntu-latest
2832
steps:
2933
- name: Check if already run
@@ -87,9 +91,9 @@ jobs:
8791
env:
8892
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
8993
run: |
90-
bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i 0 -m 1 -W ${{env.WOKWI_TIMEOUT}}
94+
bash .github/scripts/tests_run.sh -c -type ${{ inputs.type }} -t ${{inputs.chip}} -i 0 -m 1 -W ${{env.WOKWI_TIMEOUT}}
9195
92-
- name: Upload ${{ matrix.chip }}-${{ matrix.type }} binaries as cache
96+
- name: Upload ${{ inputs.chip }}-${{ inputs.type }} binaries as cache
9397
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
9498
uses: actions/cache/save@v4
9599
with:

0 commit comments

Comments
 (0)