From bbc08891659efe67673ffcee32262cbd63058496 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Mon, 27 May 2024 11:57:34 +0000 Subject: [PATCH] Use Swift SDK for development snapshot testing in CI --- .github/actions/install-swift/action.yml | 44 ++++++++++++++++++++++++ .github/workflows/test.yml | 25 +++++++++++++- IntegrationTests/Makefile | 1 - Makefile | 20 +++++++---- 4 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 .github/actions/install-swift/action.yml diff --git a/.github/actions/install-swift/action.yml b/.github/actions/install-swift/action.yml new file mode 100644 index 00000000..bdc4c934 --- /dev/null +++ b/.github/actions/install-swift/action.yml @@ -0,0 +1,44 @@ +inputs: + swift-dir: + description: The directory name part of the distribution URL + required: true + swift-version: + description: Git tag indicating the Swift version + required: true + +runs: + using: composite + steps: + # https://www.swift.org/install/linux/#installation-via-tarball + - name: Install dependent packages for Swift + shell: bash + run: > + sudo apt-get -q update && + sudo apt-get install -y + binutils + git + gnupg2 + libc6-dev + libcurl4-openssl-dev + libedit2 + libgcc-9-dev + libpython3.8 + libsqlite3-0 + libstdc++-9-dev + libxml2-dev + libz3-dev + pkg-config + tzdata + unzip + zlib1g-dev + curl + + - name: Download Swift + shell: bash + run: curl -fLO https://download.swift.org/${{ inputs.swift-dir }}/${{ inputs.swift-version }}/${{ inputs.swift-version }}-ubuntu22.04.tar.gz + working-directory: ${{ env.RUNNER_TEMP }} + + - name: Unarchive and Install Swift + shell: bash + run: sudo tar -xf ${{ inputs.swift-version }}-ubuntu22.04.tar.gz --strip-components=2 -C /usr/local + working-directory: ${{ env.RUNNER_TEMP }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1767b138..51277f35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,19 @@ jobs: - { os: ubuntu-20.04, toolchain: wasm-5.7.3-RELEASE, wasi-backend: MicroWASI } - { os: ubuntu-20.04, toolchain: wasm-5.8.0-RELEASE, wasi-backend: MicroWASI } - { os: ubuntu-20.04, toolchain: wasm-5.9.1-RELEASE, wasi-backend: MicroWASI } - - { os: ubuntu-22.04, toolchain: wasm-DEVELOPMENT-SNAPSHOT-2024-05-02-a, wasi-backend: Node } + - os: ubuntu-22.04 + toolchain: DEVELOPMENT-SNAPSHOT-2024-05-01-a + swift-sdk: + id: DEVELOPMENT-SNAPSHOT-2024-05-25-a-wasm32-unknown-wasi + 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" + wasi-backend: Node + # TODO: Enable this once we support threads in JavaScriptKit + # - os: ubuntu-22.04 + # toolchain: DEVELOPMENT-SNAPSHOT-2024-05-01-a + # swift-sdk: + # id: DEVELOPMENT-SNAPSHOT-2024-05-25-a-wasm32-unknown-wasip1-threads + # 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" + # wasi-backend: Node runs-on: ${{ matrix.entry.os }} env: @@ -34,8 +46,19 @@ jobs: if: ${{ matrix.entry.xcode }} run: sudo xcode-select -s /Applications/${{ matrix.entry.xcode }} - uses: swiftwasm/setup-swiftwasm@v1 + if: ${{ matrix.entry.swift-sdk == null }} with: swift-version: ${{ matrix.entry.toolchain }} + - uses: ./.github/actions/install-swift + if: ${{ matrix.entry.swift-sdk }} + with: + swift-dir: development + swift-version: swift-${{ matrix.entry.toolchain }} + - name: Install Swift SDK + if: ${{ matrix.entry.swift-sdk }} + run: | + swift sdk install "${{ matrix.entry.swift-sdk.download-url }}" + echo "SWIFT_SDK_ID=${{ matrix.entry.swift-sdk.id }}" >> $GITHUB_ENV - run: make bootstrap - run: make test - run: make unittest diff --git a/IntegrationTests/Makefile b/IntegrationTests/Makefile index 3329225f..30ffef29 100644 --- a/IntegrationTests/Makefile +++ b/IntegrationTests/Makefile @@ -8,7 +8,6 @@ FORCE: TestSuites/.build/$(CONFIGURATION)/%.wasm: FORCE swift build --package-path TestSuites \ --product $(basename $(notdir $@)) \ - --triple wasm32-unknown-wasi \ --configuration $(CONFIGURATION) \ -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor \ -Xlinker --export-if-defined=main -Xlinker --export-if-defined=__main_argc_argv \ diff --git a/Makefile b/Makefile index e71734a5..4714d915 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,11 @@ MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +ifeq ($(SWIFT_SDK_ID),) +SWIFT_BUILD_FLAGS := --triple wasm32-unknown-wasi +else +SWIFT_BUILD_FLAGS := --swift-sdk $(SWIFT_SDK_ID) +endif + .PHONY: bootstrap bootstrap: npm ci @@ -13,24 +19,24 @@ build: test: @echo Running integration tests cd IntegrationTests && \ - CONFIGURATION=debug make test && \ - CONFIGURATION=debug SWIFT_BUILD_FLAGS="-Xswiftc -DJAVASCRIPTKIT_WITHOUT_WEAKREFS" make test && \ - CONFIGURATION=release make test && \ - CONFIGURATION=release SWIFT_BUILD_FLAGS="-Xswiftc -DJAVASCRIPTKIT_WITHOUT_WEAKREFS" make test + CONFIGURATION=debug SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS)" $(MAKE) test && \ + CONFIGURATION=debug SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS) -Xswiftc -DJAVASCRIPTKIT_WITHOUT_WEAKREFS" $(MAKE) test && \ + CONFIGURATION=release SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS)" $(MAKE) test && \ + CONFIGURATION=release SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS) -Xswiftc -DJAVASCRIPTKIT_WITHOUT_WEAKREFS" $(MAKE) test .PHONY: unittest unittest: @echo Running unit tests - 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 + 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) node --experimental-wasi-unstable-preview1 scripts/test-harness.mjs ./.build/wasm32-unknown-wasi/debug/JavaScriptKitPackageTests.wasm .PHONY: benchmark_setup benchmark_setup: - cd IntegrationTests && CONFIGURATION=release make benchmark_setup + SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS)" CONFIGURATION=release $(MAKE) -C IntegrationTests benchmark_setup .PHONY: run_benchmark run_benchmark: - cd IntegrationTests && CONFIGURATION=release make -s run_benchmark + SWIFT_BUILD_FLAGS="$(SWIFT_BUILD_FLAGS)" CONFIGURATION=release $(MAKE) -s -C IntegrationTests run_benchmark .PHONY: perf-tester perf-tester: