Skip to content

Commit 8fc5c56

Browse files
committed
ci/package_core: save and reload build environment
Save the prepared build environment as an artifact after the initial setup, to allow for multiple jobs to reuse it without repeating the initial Zephyr configuration steps. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent bd88735 commit 8fc5c56

File tree

1 file changed

+51
-19
lines changed

1 file changed

+51
-19
lines changed

.github/workflows/package_core.yml

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ on:
66

77
jobs:
88

9-
package-core:
10-
name: Build and package cores
9+
build-env:
10+
name: Prepare build environment
1111
runs-on: ubuntu-latest
12-
env:
13-
CCACHE_IGNOREOPTIONS: -specs=*
1412
outputs:
1513
CORE_TAG: ${{ env.CORE_TAG }}
1614
CORE_HASH: ${{ env.CORE_HASH }}
@@ -46,6 +44,32 @@ jobs:
4644
echo "ARTIFACTS=$(jq -c '["zephyr"] + (map(.artifact) | unique)' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"
4745
echo "SUB_ARCHES=$(jq -c 'map(.subarch) | unique' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV"
4846
47+
(cd && tar cphf - .cmake work zephyr-sdk-* | zstd > build-env.tar.zstd)
48+
49+
- name: Archive build environment
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: build-env
53+
path: ~/build-env.tar.zstd
54+
55+
package-core:
56+
name: Build and package cores
57+
runs-on: ubuntu-latest
58+
needs:
59+
- build-env
60+
env:
61+
CCACHE_IGNOREOPTIONS: -specs=*
62+
CORE_TAG: ${{ needs.build-env.outputs.CORE_TAG }}
63+
steps:
64+
- uses: actions/download-artifact@v4
65+
with:
66+
path: /home/runner
67+
name: build-env
68+
69+
- name: Restore build environment
70+
run: |
71+
(cd ~ && tar --use-compress-program=unzstd -xpf build-env.tar.zstd && rm build-env.tar.zstd)
72+
4973
- name: ccache
5074
uses: hendrikmuhs/ccache-action@v1.2
5175
with:
@@ -72,13 +96,15 @@ jobs:
7296
split-core:
7397
name: Split off ${{ matrix.artifact }}
7498
runs-on: ubuntu-latest
75-
needs: package-core
99+
needs:
100+
- build-env
101+
- package-core
76102
env:
77-
ALL_CORES_ARTIFACT: ArduinoCore-archives-${{ needs.package-core.outputs.CORE_HASH }}
78-
CORE_ARTIFACT: ArduinoCore-${{ matrix.artifact }}-${{ needs.package-core.outputs.CORE_HASH }}
103+
ALL_CORES_ARTIFACT: ArduinoCore-archives-${{ needs.build-env.outputs.CORE_HASH }}
104+
CORE_ARTIFACT: ArduinoCore-${{ matrix.artifact }}-${{ needs.build-env.outputs.CORE_HASH }}
79105
strategy:
80106
matrix:
81-
artifact: ${{ fromJSON( needs.package-core.outputs.ARTIFACTS ) }}
107+
artifact: ${{ fromJSON( needs.build-env.outputs.ARTIFACTS ) }}
82108
steps:
83109
- uses: actions/download-artifact@v4
84110
with:
@@ -93,17 +119,18 @@ jobs:
93119
name: Test ${{ matrix.subarch }}:${{ matrix.board }}
94120
runs-on: ubuntu-latest
95121
needs:
122+
- build-env
96123
- package-core
97124
- split-core
98125
strategy:
99126
matrix:
100127
include:
101-
${{ fromJSON( needs.package-core.outputs.ALL_BOARD_DATA ) }}
128+
${{ fromJSON( needs.build-env.outputs.ALL_BOARD_DATA ) }}
102129
fail-fast: false
103130
env:
104131
PLAT: arduino:${{ matrix.subarch }}
105132
FQBN: arduino:${{ matrix.subarch }}:${{ matrix.board }}
106-
CORE_ARTIFACT: ArduinoCore-${{ matrix.artifact }}-${{ needs.package-core.outputs.CORE_HASH }}
133+
CORE_ARTIFACT: ArduinoCore-${{ matrix.artifact }}-${{ needs.build-env.outputs.CORE_HASH }}
107134
steps:
108135
- uses: actions/download-artifact@v4
109136
with:
@@ -163,18 +190,19 @@ jobs:
163190
- uses: actions/upload-artifact@v4
164191
if: ${{ success() || failure() }}
165192
with:
166-
name: test-report-${{ needs.package-core.outputs.CORE_TAG }}-${{ matrix.board }}
193+
name: test-report-${{ needs.build-env.outputs.CORE_TAG }}-${{ matrix.board }}
167194
path: sketches-reports/*
168195

169196
collect-logs:
170197
name: Collect logs
171198
runs-on: ubuntu-latest
172199
needs:
200+
- build-env
173201
- package-core
174202
- test-core
175203
if: ${{ !cancelled() && needs.package-core.result == 'success' }}
176204
env:
177-
ALL_BOARD_DATA: ${{ needs.package-core.outputs.ALL_BOARD_DATA }}
205+
ALL_BOARD_DATA: ${{ needs.build-env.outputs.ALL_BOARD_DATA }}
178206
steps:
179207
- uses: actions/download-artifact@v4
180208
with:
@@ -230,9 +258,10 @@ jobs:
230258
runs-on: ubuntu-latest
231259
if: cancelled() || contains(needs.*.result, 'failure')
232260
needs:
261+
- build-env
233262
- package-core
234263
- test-core
235-
steps:
264+
steps:
236265
- name: Notify failure
237266
run: exit 1
238267

@@ -241,14 +270,15 @@ jobs:
241270
runs-on: ubuntu-latest
242271
if: ${{ github.event_name == 'push' && github.repository == 'arduino/ArduinoCore-zephyr' }}
243272
needs:
273+
- build-env
244274
- package-core
245275
- test-core
246276
environment: production
247277
permissions:
248278
id-token: write
249279
contents: read
250280
env:
251-
ALL_CORES_ARTIFACT: ArduinoCore-archives-${{ needs.package-core.outputs.CORE_HASH }}
281+
ALL_CORES_ARTIFACT: ArduinoCore-archives-${{ needs.build-env.outputs.CORE_HASH }}
252282
steps:
253283
- uses: actions/download-artifact@v4
254284
with:
@@ -271,13 +301,14 @@ jobs:
271301
runs-on: ubuntu-latest
272302
if: ${{ github.repository == 'arduino/ArduinoCore-zephyr' }}
273303
needs:
304+
- build-env
274305
- package-core
275306
- test-core
276307
env:
277-
ALL_CORES_ARTIFACT: ArduinoCore-archives-${{ needs.package-core.outputs.CORE_HASH }}
278-
CORE_TAG: ${{ needs.package-core.outputs.CORE_TAG }}
279-
CORE_HASH: ${{ needs.package-core.outputs.CORE_HASH }}
280-
ARTIFACTS: ${{ needs.package-core.outputs.ARTIFACTS }}
308+
ALL_CORES_ARTIFACT: ArduinoCore-archives-${{ needs.build-env.outputs.CORE_HASH }}
309+
CORE_TAG: ${{ needs.build-env.outputs.CORE_TAG }}
310+
CORE_HASH: ${{ needs.build-env.outputs.CORE_HASH }}
311+
ARTIFACTS: ${{ needs.build-env.outputs.ARTIFACTS }}
281312
steps:
282313
- uses: actions/checkout@v4
283314
with:
@@ -306,6 +337,7 @@ jobs:
306337
cleanup-artifacts:
307338
runs-on: ubuntu-latest
308339
needs:
340+
- build-env
309341
- package-core
310342
- publish-core
311343
- publish-json
@@ -314,5 +346,5 @@ jobs:
314346
- name: Clean up intermediate artifacts
315347
uses: geekyeggo/delete-artifact@v5.1.0
316348
with:
317-
name: ArduinoCore-archives-${{ needs.package-core.outputs.CORE_HASH }}
349+
name: ArduinoCore-archives-${{ needs.build-env.outputs.CORE_HASH }}
318350
failOnError: false

0 commit comments

Comments
 (0)