Skip to content

Commit 07f5509

Browse files
committed
CI: Build examples in parallel on pull requests
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-example` with one job per example. Parallelism collapses the wall-clock time to that of the slowest single example (~10 min). An aggregate `build-examples` job gates on the matrix so the existing required status check of that name keeps working. - `main` keeps the full release build of all examples plus the GitHub Pages deploy (`build-examples-deploy`), so published artifacts are unchanged. Examples are still built in release: building them in debug currently fails because the host `BridgeJSTool` plugin gets compiled against the wasm SDK (no `Dispatch`), a pre-existing issue that only surfaces in debug. No caching is introduced here.
1 parent ebbde04 commit 07f5509

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,50 @@ 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.
161+
build-example:
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+
- run: ./Examples/${{ matrix.example }}/build.sh release
186+
env:
187+
SWIFT_SDK_ID_wasm32_unknown_wasip1_threads: ${{ steps.setup-wasm32-unknown-wasip1-threads.outputs.swift-sdk-id }}
188+
SWIFT_SDK_ID_wasm32_unknown_wasip1: ${{ steps.setup-wasm32-unknown-wasip1.outputs.swift-sdk-id }}
189+
190+
# Aggregate gate so the required `build-examples` status check still exists and
191+
# only passes when every matrix job above succeeds.
158192
build-examples:
193+
if: github.event_name == 'pull_request'
194+
needs: build-example
195+
runs-on: ubuntu-latest
196+
steps:
197+
- run: echo "All examples built successfully."
198+
199+
# main: build all examples in release and publish them to GitHub Pages.
200+
build-examples-deploy:
201+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
159202
runs-on: ubuntu-latest
160203
steps:
161204
- uses: actions/checkout@v7
@@ -184,7 +227,7 @@ jobs:
184227
environment:
185228
name: github-pages
186229
url: ${{ steps.deployment.outputs.page_url }}
187-
needs: build-examples
230+
needs: build-examples-deploy
188231
permissions:
189232
pages: write
190233
id-token: write

0 commit comments

Comments
 (0)