Skip to content

Commit 166377f

Browse files
committed
CI: Cache example .build to speed up warm example builds
Cache each example's `.build` plus the SwiftPM dependency cache, keyed on the workflow file and the example's Package.resolved. On a warm cache the matrix jobs skip recompiling swift-syntax (pulled in by the @js macro plugin and BridgeJSTool), which dominates a cold example build. Measured per-example wall-clock on the example matrix: no cache: ~10 min cold (miss + save): ~10-12 min warm (hit): ~1-2 min Cold runs - the first run, or whenever Package.resolved or the workflow file change - pay a small cache-save overhead. Warm runs, the common case, drop the example matrix from ~10 min to ~2 min. GitHub's 10 GB cache budget is shared across the six example `.build` caches, so heavy eviction falls back to cold.
1 parent 46d2ded commit 166377f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ jobs:
182182
- uses: swiftwasm/setup-swiftwasm@v2
183183
id: setup-wasm32-unknown-wasip1-threads
184184
with: { target: wasm32-unknown-wasip1-threads }
185+
- uses: actions/cache@v4
186+
with:
187+
path: |
188+
Examples/${{ matrix.example }}/.build
189+
~/.cache/org.swift.swiftpm
190+
key: ex-${{ matrix.example }}-${{ hashFiles('.github/workflows/test.yml', format('Examples/{0}/Package.resolved', matrix.example)) }}
191+
restore-keys: |
192+
ex-${{ matrix.example }}-
185193
# build.sh resolves the package relative to the working directory, so run it
186194
# from the example directory (mirroring Utilities/build-examples.sh's `cd`).
187195
- run: ./build.sh release

0 commit comments

Comments
 (0)