Skip to content

Commit 358b38a

Browse files
authored
CI: Build examples in parallel on pull requests (#782)
The `build-examples` job built all examples sequentially in a single job, taking ~57 minutes - each example is its own SwiftPM package that recompiles JavaScriptKit and swift-syntax from scratch, with no sharing between them. Split the job by event: - Pull requests fan out a matrix `build-examples` with one job per example, built in parallel. Wall-clock drops to that of the slowest single example (~10 min). Each example now reports as a separate `build-examples (<name>)` check, so the required status checks need updating (see PR description). - `main` keeps the full release build of all examples plus the GitHub Pages deploy (`build-examples-deploy`), so published artifacts are unchanged. Examples are built in release to match the deploy path, keeping the only behavioral change the parallelism. Each matrix step runs `build.sh` from the example directory (via `working-directory`), mirroring Utilities/build-examples.sh.
1 parent 210689e commit 358b38a

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,44 @@ jobs:
155155
exit 1
156156
}
157157
158+
# Pull requests: compile every example in parallel just to catch breakage.
159+
# One job per example avoids rebuilding JavaScriptKit + swift-syntax 6x in series,
160+
# which collapses the wall-clock time from ~1h to that of the slowest single example.
158161
build-examples:
162+
if: github.event_name == 'pull_request'
163+
runs-on: ubuntu-latest
164+
strategy:
165+
fail-fast: false
166+
matrix:
167+
example:
168+
- ActorOnWebWorker
169+
- Basic
170+
- Embedded
171+
- Multithreading
172+
- OffscrenCanvas
173+
- PlayBridgeJS
174+
steps:
175+
- uses: actions/checkout@v7
176+
- uses: ./.github/actions/install-swift
177+
with:
178+
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz
179+
- uses: swiftwasm/setup-swiftwasm@v2
180+
id: setup-wasm32-unknown-wasip1
181+
with: { target: wasm32-unknown-wasip1 }
182+
- uses: swiftwasm/setup-swiftwasm@v2
183+
id: setup-wasm32-unknown-wasip1-threads
184+
with: { target: wasm32-unknown-wasip1-threads }
185+
# build.sh resolves the package relative to the working directory, so run it
186+
# from the example directory (mirroring Utilities/build-examples.sh's `cd`).
187+
- run: ./build.sh release
188+
working-directory: Examples/${{ matrix.example }}
189+
env:
190+
SWIFT_SDK_ID_wasm32_unknown_wasip1_threads: ${{ steps.setup-wasm32-unknown-wasip1-threads.outputs.swift-sdk-id }}
191+
SWIFT_SDK_ID_wasm32_unknown_wasip1: ${{ steps.setup-wasm32-unknown-wasip1.outputs.swift-sdk-id }}
192+
193+
# main: build all examples in release and publish them to GitHub Pages.
194+
build-examples-deploy:
195+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
159196
runs-on: ubuntu-latest
160197
steps:
161198
- uses: actions/checkout@v7
@@ -184,7 +221,7 @@ jobs:
184221
environment:
185222
name: github-pages
186223
url: ${{ steps.deployment.outputs.page_url }}
187-
needs: build-examples
224+
needs: build-examples-deploy
188225
permissions:
189226
pages: write
190227
id-token: write

0 commit comments

Comments
 (0)