Skip to content

Commit 7c5c3ce

Browse files
committed
Merge branch 'master' into ci/tests_refactor
2 parents f064139 + bcfd9f3 commit 7c5c3ce

File tree

4 files changed

+78
-30
lines changed

4 files changed

+78
-30
lines changed

.github/workflows/build_tests.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ jobs:
1717
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
1818
steps:
1919
- name: Check if already built
20-
id: artifact-exists
21-
uses: LIT-Protocol/artifact-exists-action@v0
20+
if: ${{ github.event.pull_request.number != null }}
21+
id: cache-build-binaries
22+
uses: actions/cache/restore@v4
2223
with:
23-
name: ${{ matrix.chip }}-${{ matrix.type }}.artifacts
24+
lookup-only: true
25+
path: ~/.arduino/tests/*
26+
key: tests-${{ github.event.pull_request.number }}-${{ matrix.chip }}-${{ matrix.type }}-${{ github.event.pull_request.head.sha }}
2427

2528
- name: Evaluate if tests should be built
2629
id: check-build
2730
run: |
28-
artifact_exists=${{ steps.artifact-exists.outputs.exists }}
31+
artifact_exists=${{ steps.cache-build-binaries.outputs.cache-hit == 'true' || false }}
2932
is_pr=${{ github.event.pull_request.number != null }}
3033
is_performance_test=${{ matrix.type == 'performance' }}
3134
is_performance_enabled=${{ contains(github.event.pull_request.labels.*.name, 'perf_test') }}
@@ -48,16 +51,17 @@ jobs:
4851
4952
- name: Checkout Repository
5053
uses: actions/checkout@v4
54+
with:
55+
ref: ${{ github.event.pull_request.head.sha }}
5156

5257
- name: Build sketches
5358
run: |
5459
bash .github/scripts/tests_build.sh -c -type ${{ matrix.type }} -t ${{ matrix.chip }}
5560
56-
- name: Upload ${{ matrix.chip }}-${{ matrix.type }} artifacts
57-
uses: actions/upload-artifact@v4
61+
- name: Upload ${{ matrix.chip }}-${{ matrix.type }} binaries as cache
62+
uses: actions/cache/save@v4
5863
with:
59-
name: ${{ matrix.chip }}-${{ matrix.type }}.artifacts
60-
if-no-files-found: error
64+
key: tests-${{ github.event.pull_request.number || github.ref }}-${{ matrix.chip }}-${{ matrix.type }}-${{ github.event.pull_request.head.sha || github.sha }}
6165
path: |
6266
~/.arduino/tests/**/build*.tmp/*.bin
6367
~/.arduino/tests/**/build*.tmp/*.elf

.github/workflows/clean.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Clean objects
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
clean:
8+
name: Clean built binary caches
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Clean up caches
12+
uses: actions/github-script@v7
13+
with:
14+
script: |
15+
const ref = "${{ github.event.pull_request.number || github.ref }}";
16+
const cacheKeysPattern = `tests-${ref}-*`;
17+
18+
const { listForRepo } = require("@octokit/plugin-paginate-rest");
19+
const octokit = github.getOctokit(process.env.GITHUB_TOKEN);
20+
21+
// Fetch all cache entries for the repository
22+
const caches = await octokit.actions.listRepoCaches({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
});
26+
27+
// Filter caches matching the specified pattern
28+
const matchingCaches = caches.data.actions_caches.filter(cache =>
29+
cache.key.startsWith(`tests-${ref}-`)
30+
);
31+
32+
// Delete matching caches
33+
for (const cache of matchingCaches) {
34+
/*
35+
await octokit.actions.deleteActionsCacheById({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
cache_id: cache.id
39+
});
40+
*/
41+
console.log(`Deleted cache with key: ${cache.key}`);
42+
}
43+
44+
console.log(`Deleted ${matchingCaches.length} caches.`);
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/hw.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ jobs:
3939
echo "Validation test, running"
4040
fi
4141
42+
- name: Get binaries
43+
id: cache-build-binaries
44+
uses: actions/cache/restore@v4
45+
with:
46+
fail-on-cache-miss: true
47+
path: ~/.arduino/tests/*
48+
key: tests-${{ github.event.pull_request.number || github.ref }}-${{ matrix.chip }}-${{ matrix.type }}-${{ github.event.pull_request.head.sha || github.sha }}
49+
4250
- uses: actions/setup-python@v5
4351
with:
4452
cache: 'pip'
@@ -47,12 +55,6 @@ jobs:
4755
- name: Checkout repository
4856
uses: actions/checkout@v4
4957

50-
- name: Download ${{ matrix.chip }}-${{ matrix.type }} artifacts
51-
uses: actions/download-artifact@v4
52-
with:
53-
name: ${{ matrix.chip }}-${{ matrix.type }}.artifacts
54-
path: ~/.arduino/tests
55-
5658
- name: Install dependencies
5759
run: |
5860
pip install -U pip

.github/workflows/tests.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,22 @@ concurrency:
1111
group: tests-${{ github.event.pull_request.number || github.ref }}
1212
cancel-in-progress: true
1313

14+
permissions: read-all
15+
1416
jobs:
1517
call-build-tests:
1618
name: Build tests
1719
uses: ./.github/workflows/build_tests.yml
18-
permissions:
19-
contents: read
2020

2121
call-hardware-tests:
2222
name: Run tests on hardware
2323
uses: ./.github/workflows/hw.yml
2424
needs: call-build-tests
25-
if: ${{ github.event_name == 'schedule' || contains(github.event.pull_request.labels.*.name, 'hil_test') }}
26-
permissions:
27-
contents: read
25+
if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'hil_test') }}
2826

2927
# call-wokwi-tests:
30-
# uses: espressif/arduino-esp32/.github/workflows/wokwi.yml@master
31-
# needs: [call-build-validation-tests]
32-
# permissions:
33-
# contents: read
34-
# strategy:
35-
# matrix:
36-
# chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
37-
# with:
38-
# chip: ${{matrix.chip}}
39-
# type: "validation"
40-
# ref: ${{ github.event.pull_request.number || github.ref }}
28+
# uses: ./.github/workflows/wokwi.yml
29+
# needs: call-build-tests
4130
# secrets:
4231
# WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
4332

@@ -53,3 +42,10 @@ jobs:
5342
# chip: ${{matrix.chip}}
5443
# type: "validation"
5544
# ref: ${{ github.event.pull_request.number || github.ref }}
45+
46+
call-clean:
47+
name: Clean objects
48+
uses: ./.github/workflows/clean.yml
49+
if: github.event_name != 'pull_request' || github.event.action == 'closed'
50+
permissions:
51+
actions: write

0 commit comments

Comments
 (0)