Skip to content

Commit d25725a

Browse files
committed
Update CI and swift version
1 parent 4ff93ea commit d25725a

4 files changed

Lines changed: 66 additions & 14 deletions

File tree

.github/workflows/swift.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: swift-actions/setup-swift@v2
1616
with:
17-
swift-version: "6.0.3"
17+
swift-version: "6.1"
1818
- name: Build and Test
1919
run: ./scripts/build-and-test-ios.sh

.github/workflows/wasm.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ jobs:
1414
- name: Install Swift
1515
uses: swift-actions/setup-swift@v2
1616
with:
17-
swift-version: "6.0.3"
17+
swift-version: "6.1"
1818

1919
# Wasmtime is required because `swift test` doesn't work for WebAssembly targets.
2020
# For WASM, we must build tests separately and run them with a WASM runtime.
2121
# See: https://book.swiftwasm.org/getting-started/testing.html
2222
- name: Install Wasmtime
23-
run: |
24-
curl https://wasmtime.dev/install.sh -sSf | bash
25-
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
23+
uses: bytecodealliance/actions/wasmtime/setup@v1
24+
with:
25+
version: "29.0.1"
26+
github_token: ${{ github.token }}
2627

2728
- name: Build and Test
2829
run: ./scripts/build-and-test-wasm.sh

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,10 @@ This script will:
893893

894894
**Note:** The WASM script automatically handles SDK and runtime installation, so you can run it on a fresh machine without any prior setup!
895895

896-
### 📋 Requirements
896+
### Requirements
897897

898-
- **iOS/macOS:** Swift 6.0.3 or later
899-
- **WebAssembly:** Swift 6.0.3 or later (SDK will be automatically installed)
898+
- **iOS/macOS:** Swift 6.1 or later
899+
- **WebAssembly:** Swift 6.1 or later (SDK will be automatically installed)
900900

901901
## Contact
902902

scripts/build-and-test-wasm.sh

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ echo "🌐 =========================================="
77
echo ""
88

99
# Configuration for CI (GitHub Actions)
10-
SWIFT_WASM_SDK_URL="https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.0.3-RELEASE/swift-wasm-6.0.3-RELEASE-wasm32-unknown-wasi.artifactbundle.zip"
11-
SWIFT_WASM_SDK_CHECKSUM="31d3585b06dd92de390bacc18527801480163188cd7473f492956b5e213a8618"
10+
SWIFT_WASM_SDK_URL="https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.1-RELEASE/swift-wasm-6.1-RELEASE-wasm32-unknown-wasi.artifactbundle.zip"
11+
SWIFT_WASM_SDK_CHECKSUM="7550b4c77a55f4b637c376f5d192f297fe185607003a6212ad608276928db992"
1212
CI_SDK_NAME="wasm32-unknown-wasi"
1313

1414
# Swift command to use (may be overridden if toolchain detected)
@@ -99,11 +99,47 @@ install_wasmtime() {
9999
echo "🔧 Checking wasmtime..."
100100
if command -v wasmtime &> /dev/null; then
101101
echo "✅ wasmtime already installed: $(wasmtime --version)"
102+
return 0
103+
fi
104+
105+
echo "⬇️ Installing wasmtime..."
106+
107+
# Pinned version to avoid issues with dynamic version fetching
108+
# The wasmtime.dev/install.sh script can fail when GitHub API rate limits
109+
# cause the version to be parsed incorrectly (e.g., returning '{' as version)
110+
WASMTIME_VERSION="29.0.1"
111+
112+
# Detect platform
113+
case "$(uname -s)" in
114+
Linux)
115+
WASMTIME_ARCH="x86_64-linux"
116+
;;
117+
Darwin)
118+
if [ "$(uname -m)" = "arm64" ]; then
119+
WASMTIME_ARCH="aarch64-macos"
120+
else
121+
WASMTIME_ARCH="x86_64-macos"
122+
fi
123+
;;
124+
*)
125+
echo "❌ Unsupported platform: $(uname -s)"
126+
exit 1
127+
;;
128+
esac
129+
130+
WASMTIME_URL="https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_ARCH}.tar.xz"
131+
WASMTIME_DIR="$HOME/.wasmtime"
132+
133+
echo " Downloading from: $WASMTIME_URL"
134+
mkdir -p "$WASMTIME_DIR/bin"
135+
curl -L "$WASMTIME_URL" | tar -xJ --strip-components=1 -C "$WASMTIME_DIR"
136+
export PATH="$WASMTIME_DIR/bin:$PATH"
137+
138+
if command -v wasmtime &> /dev/null; then
139+
echo "✅ wasmtime installed successfully: $(wasmtime --version)"
102140
else
103-
echo "⬇️ Installing wasmtime..."
104-
curl https://wasmtime.dev/install.sh -sSf | bash
105-
export PATH="$HOME/.wasmtime/bin:$PATH"
106-
echo "✅ wasmtime installed successfully"
141+
echo "❌ Failed to install wasmtime"
142+
exit 1
107143
fi
108144
echo ""
109145
}
@@ -143,11 +179,26 @@ run_tests() {
143179
echo "📍 Test binary: $TEST_BINARY"
144180

145181
# Determine wasmtime flags based on SDK type
182+
# Note: We configure stack and memory limits to prevent crashes:
183+
# 1. max-wasm-stack (32MB): Maximum stack for wasm execution. Required for
184+
# ICU/Foundation date formatting which uses significant stack space.
185+
# 2. async-stack-size (64MB): Stack for async operations. MUST be larger than
186+
# max-wasm-stack. XCTest uses async/await extensively, and swift_task_switch
187+
# operations during test execution and teardown require adequate async stack.
188+
# 3. memory-reservation-for-growth (256MB): Reserve space for memory growth
189+
# without committing large amounts upfront. This allows the linear memory
190+
# to grow on demand while having space available.
191+
# 4. memory-guard-size (64KB): Guard pages to catch out-of-bounds access.
146192
WASMTIME_FLAGS="--dir ."
193+
WASMTIME_FLAGS="$WASMTIME_FLAGS -W max-wasm-stack=33554432"
194+
WASMTIME_FLAGS="$WASMTIME_FLAGS -W async-stack-size=67108864"
195+
WASMTIME_FLAGS="$WASMTIME_FLAGS -O memory-reservation-for-growth=268435456"
196+
WASMTIME_FLAGS="$WASMTIME_FLAGS -O memory-guard-size=65536"
147197
if echo "$SWIFT_SDK_NAME" | grep -q "threads"; then
148198
WASMTIME_FLAGS="$WASMTIME_FLAGS --wasm threads=y --wasi threads=y"
149199
fi
150200

201+
echo "🔧 Wasmtime flags: $WASMTIME_FLAGS"
151202
wasmtime run $WASMTIME_FLAGS "$TEST_BINARY"
152203
echo ""
153204
}

0 commit comments

Comments
 (0)