PureYAML/scripts/check-wasm.sh
Mihaela Mihaljevic 3dd92f8645
Some checks failed
rules-freshness / rules (push) Failing after 15s
chore(release): 0.4.1 builds for WASM, from the hosted SDK
check-wasm.sh takes the swift of the toolchain to use. The SDK and the
toolchain are hosted on an external disk; the notes record the build.
2026-11-16 00:31:19 +01:00

36 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# The WASM gate needs a swift.org toolchain (Xcode's cannot target WebAssembly) and the Swift SDK for WebAssembly of the same version.
# SWIFT_WASM_SDK_ID the SDK, `swift sdk list` names it (default swift-6.3.2-RELEASE_wasm)
# SWIFT_WASM_SWIFT the `swift` of the swift.org toolchain, when it is not the one swiftly selects; it wins over swiftly
# SWIFT_WASM_SWIFT_SELECTOR the swiftly selector (default +6.3.2)
# On the machine that hosts them (SDK and toolchain kept on an external disk):
# SWIFT_WASM_SDK_ID=swift-6.3.3-RELEASE_wasm SWIFT_WASM_SWIFT=~/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift bash scripts/check-wasm.sh
SDK_ID="${SWIFT_WASM_SDK_ID:-swift-6.3.2-RELEASE_wasm}"
SWIFT_SELECTOR="${SWIFT_WASM_SWIFT_SELECTOR:-+6.3.2}"
swift_command() {
if [ -n "${SWIFT_WASM_SWIFT:-}" ]; then
"$SWIFT_WASM_SWIFT" "$@"
elif command -v swiftly >/dev/null 2>&1; then
swiftly run swift "$@" "$SWIFT_SELECTOR"
else
swift "$@"
fi
}
if ! swift_command sdk list | grep -qx "$SDK_ID"; then
# A missing SDK is "infrastructure unavailable", the same class as an
# unreachable Linux runner: exit 77 so check-all.sh records a SKIP and
# the authoritative wasm gate runs on hosted CI. A machine with the SDK
# installed still fails hard on a real build break below.
echo "wasm: SKIP (missing Swift SDK '$SDK_ID' on this machine)." >&2
echo "wasm: install the SDK or set SWIFT_WASM_SDK_ID to gate locally." >&2
exit 77
fi
swift_command build --swift-sdk "$SDK_ID"
swift_command build -c release --swift-sdk "$SDK_ID"