Skip to content

Commit c45b736

Browse files
committed
Update CI
1 parent f4b6f0b commit c45b736

2 files changed

Lines changed: 39 additions & 17 deletions

File tree

.github/workflows/wasm.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,28 @@ name: wasm
33
on:
44
push:
55

6+
env:
7+
# Required Swift toolchain version for WASM builds
8+
# Must match REQUIRED_TOOLCHAIN_VERSION in scripts/build-and-test-wasm.sh
9+
SWIFT_TOOLCHAIN_VERSION: "DEVELOPMENT-SNAPSHOT-2025-11-03-a"
10+
611
jobs:
712
build:
8-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-24.04
914
steps:
1015
- uses: actions/checkout@v4
1116

17+
# Install the specific Swift development snapshot required for WASM builds
18+
- name: Install Swift Toolchain
19+
run: |
20+
SWIFT_URL="https://download.swift.org/development/ubuntu2404/swift-${SWIFT_TOOLCHAIN_VERSION}/swift-${SWIFT_TOOLCHAIN_VERSION}-ubuntu24.04.tar.gz"
21+
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
24+
25+
- name: Verify Swift Installation
26+
run: swift --version
27+
1228
# Wasmtime is required because `swift test` doesn't work for WebAssembly targets.
1329
# For WASM, we must build tests separately and run them with a WASM runtime.
1430
# See: https://book.swiftwasm.org/getting-started/testing.html

scripts/build-and-test-wasm.sh

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

44-
# Check for local SwiftWasm toolchain first (macOS development with newer SDK)
44+
# First, check if Swift in PATH is the required development snapshot (CI environment)
45+
if command -v swift &> /dev/null; then
46+
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
55+
fi
56+
57+
# Check for local SwiftWasm toolchain (macOS development with newer SDK)
4558
TOOLCHAIN_DIR="$HOME/Library/Developer/Toolchains"
4659
if [ -d "$TOOLCHAIN_DIR" ]; then
4760
# Look for the specific required toolchain version
@@ -62,26 +75,19 @@ setup_swift() {
6275
echo "❌ Toolchain found but swift binary not executable: $TOOLCHAIN_SWIFT"
6376
exit 1
6477
fi
65-
else
66-
echo "⚠️ Required toolchain not found locally: $WASM_TOOLCHAIN"
67-
echo " Checked: $TOOLCHAIN_DIR/$WASM_TOOLCHAIN"
68-
echo " Will try system Swift..."
6978
fi
7079
fi
7180

72-
# Use system Swift (CI environment)
81+
# No matching toolchain found
82+
echo "❌ Required Swift toolchain not found: $REQUIRED_TOOLCHAIN_VERSION"
83+
echo ""
84+
echo " For macOS: Install the toolchain to ~/Library/Developer/Toolchains/"
85+
echo " For Linux/CI: Install from https://download.swift.org/development/"
86+
echo ""
7387
if command -v swift &> /dev/null; then
74-
SWIFT_CMD="swift"
75-
local VERSION_OUTPUT=$($SWIFT_CMD --version 2>/dev/null)
76-
# Extract version number (e.g., "6.1.3" from "Swift version 6.1.3")
77-
SWIFT_VERSION=$(echo "$VERSION_OUTPUT" | grep -oE "Swift version [0-9]+\.[0-9]+(\.[0-9]+)?" | head -1 | sed 's/Swift version //')
78-
echo "✅ Using system Swift"
79-
echo " Version: $SWIFT_VERSION"
80-
echo ""
81-
return 0
88+
echo " Current Swift in PATH:"
89+
swift --version 2>/dev/null | head -1 | sed 's/^/ /'
8290
fi
83-
84-
echo "❌ No Swift installation found"
8591
exit 1
8692
}
8793

0 commit comments

Comments
 (0)