Skip to content

Commit 8449f87

Browse files
Use Swift SDK for development snapshot testing in CI (#248)
1 parent 9ad94b9 commit 8449f87

File tree

4 files changed

+81
-9
lines changed

4 files changed

+81
-9
lines changed
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
inputs:
2+
swift-dir:
3+
description: The directory name part of the distribution URL
4+
required: true
5+
swift-version:
6+
description: Git tag indicating the Swift version
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
# https://www.swift.org/install/linux/#installation-via-tarball
13+
- name: Install dependent packages for Swift
14+
shell: bash
15+
run: >
16+
sudo apt-get -q update &&
17+
sudo apt-get install -y
18+
binutils
19+
git
20+
gnupg2
21+
libc6-dev
22+
libcurl4-openssl-dev
23+
libedit2
24+
libgcc-9-dev
25+
libpython3.8
26+
libsqlite3-0
27+
libstdc++-9-dev
28+
libxml2-dev
29+
libz3-dev
30+
pkg-config
31+
tzdata
32+
unzip
33+
zlib1g-dev
34+
curl
35+
36+
- name: Download Swift
37+
shell: bash
38+
run: curl -fLO https://download.swift.org/${{ inputs.swift-dir }}/${{ inputs.swift-version }}/${{ inputs.swift-version }}-ubuntu22.04.tar.gz
39+
working-directory: ${{ env.RUNNER_TEMP }}
40+
41+
- name: Unarchive and Install Swift
42+
shell: bash
43+
run: sudo tar -xf ${{ inputs.swift-version }}-ubuntu22.04.tar.gz --strip-components=2 -C /usr/local
44+
working-directory: ${{ env.RUNNER_TEMP }}

.github/workflows/test.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,19 @@ jobs:
2121
- { os: ubuntu-20.04, toolchain: wasm-5.7.3-RELEASE, wasi-backend: MicroWASI }
2222
- { os: ubuntu-20.04, toolchain: wasm-5.8.0-RELEASE, wasi-backend: MicroWASI }
2323
- { os: ubuntu-20.04, toolchain: wasm-5.9.1-RELEASE, wasi-backend: MicroWASI }
24-
- { os: ubuntu-22.04, toolchain: wasm-DEVELOPMENT-SNAPSHOT-2024-05-02-a, wasi-backend: Node }
24+
- os: ubuntu-22.04
25+
toolchain: DEVELOPMENT-SNAPSHOT-2024-05-01-a
26+
swift-sdk:
27+
id: DEVELOPMENT-SNAPSHOT-2024-05-25-a-wasm32-unknown-wasi
28+
download-url: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-05-25-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-05-25-a-wasm32-unknown-wasi.artifactbundle.zip"
29+
wasi-backend: Node
30+
# TODO: Enable this once we support threads in JavaScriptKit
31+
# - os: ubuntu-22.04
32+
# toolchain: DEVELOPMENT-SNAPSHOT-2024-05-01-a
33+
# swift-sdk:
34+
# id: DEVELOPMENT-SNAPSHOT-2024-05-25-a-wasm32-unknown-wasip1-threads
35+
# download-url: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-05-25-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-05-25-a-wasm32-unknown-wasip1-threads.artifactbundle.zip"
36+
# wasi-backend: Node
2537

2638
runs-on: ${{ matrix.entry.os }}
2739
env:
@@ -34,8 +46,19 @@ jobs:
3446
if: ${{ matrix.entry.xcode }}
3547
run: sudo xcode-select -s /Applications/${{ matrix.entry.xcode }}
3648
- uses: swiftwasm/setup-swiftwasm@v1
49+
if: ${{ matrix.entry.swift-sdk == null }}
3750
with:
3851
swift-version: ${{ matrix.entry.toolchain }}
52+
- uses: ./.github/actions/install-swift
53+
if: ${{ matrix.entry.swift-sdk }}
54+
with:
55+
swift-dir: development/ubuntu2204
56+
swift-version: swift-${{ matrix.entry.toolchain }}
57+
- name: Install Swift SDK
58+
if: ${{ matrix.entry.swift-sdk }}
59+
run: |
60+
swift sdk install "${{ matrix.entry.swift-sdk.download-url }}"
61+
echo "SWIFT_SDK_ID=${{ matrix.entry.swift-sdk.id }}" >> $GITHUB_ENV
3962
- run: make bootstrap
4063
- run: make test
4164
- run: make unittest

IntegrationTests/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ FORCE:
88
TestSuites/.build/$(CONFIGURATION)/%.wasm: FORCE
99
swift build --package-path TestSuites \
1010
--product $(basename $(notdir $@)) \
11-
--triple wasm32-unknown-wasi \
1211
--configuration $(CONFIGURATION) \
1312
-Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor \
1413
-Xlinker --export-if-defined=main -Xlinker --export-if-defined=__main_argc_argv \

Makefile

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
22

3+
ifeq ($(SWIFT_SDK_ID),)
4+
SWIFT_BUILD_FLAGS := --triple wasm32-unknown-wasi
5+
else
6+
SWIFT_BUILD_FLAGS := --swift-sdk $(SWIFT_SDK_ID)
7+
endif
8+
39
.PHONY: bootstrap
410
bootstrap:
511
npm ci
@@ -13,24 +19,24 @@ build:
1319
test:
1420
@echo Running integration tests
1521
cd IntegrationTests && \
16-
CONFIGURATION=debug make test && \
17-
CONFIGURATION=debug SWIFT_BUILD_FLAGS="-Xswiftc -DJAVASCRIPTKIT_WITHOUT_WEAKREFS" make test && \
18-
CONFIGURATION=release make test && \
19-
CONFIGURATION=release SWIFT_BUILD_FLAGS="-Xswiftc -DJAVASCRIPTKIT_WITHOUT_WEAKREFS" make test
22+
CONFIGURATION=debug SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS)" $(MAKE) test && \
23+
CONFIGURATION=debug SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS) -Xswiftc -DJAVASCRIPTKIT_WITHOUT_WEAKREFS" $(MAKE) test && \
24+
CONFIGURATION=release SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS)" $(MAKE) test && \
25+
CONFIGURATION=release SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS) -Xswiftc -DJAVASCRIPTKIT_WITHOUT_WEAKREFS" $(MAKE) test
2026

2127
.PHONY: unittest
2228
unittest:
2329
@echo Running unit tests
24-
swift build --build-tests --triple wasm32-unknown-wasi -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export-if-defined=main -Xlinker --export-if-defined=__main_argc_argv --static-swift-stdlib -Xswiftc -static-stdlib
30+
swift build --build-tests -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export-if-defined=main -Xlinker --export-if-defined=__main_argc_argv --static-swift-stdlib -Xswiftc -static-stdlib $(SWIFT_BUILD_FLAGS)
2531
node --experimental-wasi-unstable-preview1 scripts/test-harness.mjs ./.build/wasm32-unknown-wasi/debug/JavaScriptKitPackageTests.wasm
2632

2733
.PHONY: benchmark_setup
2834
benchmark_setup:
29-
cd IntegrationTests && CONFIGURATION=release make benchmark_setup
35+
SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS)" CONFIGURATION=release $(MAKE) -C IntegrationTests benchmark_setup
3036

3137
.PHONY: run_benchmark
3238
run_benchmark:
33-
cd IntegrationTests && CONFIGURATION=release make -s run_benchmark
39+
SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS)" CONFIGURATION=release $(MAKE) -s -C IntegrationTests run_benchmark
3440

3541
.PHONY: perf-tester
3642
perf-tester:

0 commit comments

Comments
 (0)