Skip to content

Commit 8e1111e

Browse files
committed
WIP
1 parent c45b736 commit 8e1111e

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

.github/workflows/wasm.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,31 @@ jobs:
1515
- uses: actions/checkout@v4
1616

1717
# Install the specific Swift development snapshot required for WASM builds
18+
# Toolchain comes from SwiftWasm releases (includes WASM support)
1819
- name: Install Swift Toolchain
1920
run: |
20-
SWIFT_URL="https://download.swift.org/development/ubuntu2404/swift-${SWIFT_TOOLCHAIN_VERSION}/swift-${SWIFT_TOOLCHAIN_VERSION}-ubuntu24.04.tar.gz"
21+
SWIFT_URL="https://github.com/swiftwasm/swift/releases/download/swift-wasm-${SWIFT_TOOLCHAIN_VERSION}/swift-wasm-${SWIFT_TOOLCHAIN_VERSION}-ubuntu24.04_x86_64.tar.gz"
2122
echo "Downloading Swift toolchain from: $SWIFT_URL"
22-
curl -sL "$SWIFT_URL" | tar xz --strip-components=1 -C /opt
23-
echo "/opt/usr/bin" >> $GITHUB_PATH
23+
mkdir -p /opt/swift
24+
curl -sL "$SWIFT_URL" | tar xz --strip-components=1 -C /opt/swift
25+
echo "/opt/swift/usr/bin" >> $GITHUB_PATH
2426
2527
- name: Verify Swift Installation
2628
run: swift --version
2729

30+
# Install the matching WASM SDK
31+
- name: Install WASM SDK
32+
run: |
33+
SDK_URL="https://github.com/swiftwasm/swift/releases/download/swift-wasm-${SWIFT_TOOLCHAIN_VERSION}/swift-wasm-${SWIFT_TOOLCHAIN_VERSION}-wasm32-unknown-wasip1-threads.artifactbundle.zip"
34+
echo "Installing WASM SDK from: $SDK_URL"
35+
swift sdk install "$SDK_URL" || true
36+
echo "Installed SDKs:"
37+
swift sdk list
38+
39+
# Set environment variable to signal the correct toolchain is installed
40+
- name: Set Toolchain Environment
41+
run: echo "SWIFT_WASM_TOOLCHAIN_VERIFIED=1" >> $GITHUB_ENV
42+
2843
# Wasmtime is required because `swift test` doesn't work for WebAssembly targets.
2944
# For WASM, we must build tests separately and run them with a WASM runtime.
3045
# See: https://book.swiftwasm.org/getting-started/testing.html

scripts/build-and-test-wasm.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,15 @@ setup_swift() {
4141
echo "📦 Setting up Swift..."
4242
echo " Required toolchain: $REQUIRED_TOOLCHAIN_VERSION"
4343

44-
# First, check if Swift in PATH is the required development snapshot (CI environment)
45-
if command -v swift &> /dev/null; then
44+
# In CI, the workflow installs the exact toolchain and sets this env var
45+
if [ "${SWIFT_WASM_TOOLCHAIN_VERIFIED:-}" = "1" ] && command -v swift &> /dev/null; then
46+
SWIFT_CMD="swift"
47+
SWIFT_VERSION="dev"
4648
local VERSION_OUTPUT=$(swift --version 2>/dev/null | head -1)
47-
if echo "$VERSION_OUTPUT" | grep -q "$REQUIRED_TOOLCHAIN_VERSION"; then
48-
SWIFT_CMD="swift"
49-
SWIFT_VERSION="dev"
50-
echo "✅ Using required toolchain from PATH"
51-
echo " Version: $VERSION_OUTPUT"
52-
echo ""
53-
return 0
54-
fi
49+
echo "✅ Using CI-installed toolchain"
50+
echo " Version: $VERSION_OUTPUT"
51+
echo ""
52+
return 0
5553
fi
5654

5755
# Check for local SwiftWasm toolchain (macOS development with newer SDK)

0 commit comments

Comments
 (0)