Merge pull request #868 from kkebo/refactor-ci-script #1343
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SwiftWasm | |
| on: | |
| push: | |
| branches: ["wasm32-wasi"] | |
| pull_request: | |
| branches: ["wasm32-wasi"] | |
| env: | |
| SWIFT_VERSION: main-snapshot-2026-07-11 | |
| WASMTIME_VERSION: 46.0.1 | |
| permissions: {} | |
| defaults: | |
| run: | |
| shell: bash -euo pipefail {0} | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| target: | |
| - sdk: | |
| url: https://download.swift.org/development/wasm-sdk/swift-DEVELOPMENT-SNAPSHOT-2026-07-11-a/swift-DEVELOPMENT-SNAPSHOT-2026-07-11-a_wasm.artifactbundle.tar.gz | |
| checksum: 6a6e928fdd939d1120aa36a5b54085835137d682c1d4c0c3a1e49a8f7ea7d977 | |
| artifact-name: swift-format.wasm | |
| other-wasmopt-flags: | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| - name: Install tools | |
| run: sudo apt-get update && sudo apt-get install --no-install-recommends -y wabt binaryen | |
| - run: ./.github/scripts/ci-install-swiftly.sh | |
| - run: swiftly install -y --use "$SWIFT_VERSION" | |
| - run: swift --version | |
| - env: | |
| SDK_URL: ${{ matrix.target.sdk.url }} | |
| SDK_CHECKSUM: ${{ matrix.target.sdk.checksum }} | |
| run: swift sdk install "$SDK_URL" --checksum "$SDK_CHECKSUM" | |
| - name: Build | |
| env: | |
| WASMOPT_FLAGS: ${{ matrix.target.other-wasmopt-flags }} | |
| ARTIFACT_NAME: ${{ matrix.target.artifact-name }} | |
| run: | | |
| swift build --product swift-format --swift-sdk "$(swiftc -print-target-info | jq -r '.swiftCompilerTag')_wasm" -c release --build-system native | |
| wasm-strip .build/release/swift-format.wasm | |
| wasm-opt -Oz --enable-bulk-memory --enable-sign-ext --enable-nontrapping-float-to-int $WASMOPT_FLAGS .build/release/swift-format.wasm -o "$ARTIFACT_NAME" | |
| - name: Upload ${{ matrix.target.artifact-name }} | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: ${{ matrix.target.artifact-name }} | |
| path: ${{ matrix.target.artifact-name }} | |
| test-binary: | |
| needs: build | |
| strategy: | |
| matrix: | |
| target: | |
| - artifact-name: swift-format.wasm | |
| other-wasmkit-flags: | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| - run: ./.github/scripts/ci-install-swiftly.sh | |
| - run: swiftly install -y --use "$SWIFT_VERSION" | |
| - name: Download ${{ matrix.target.artifact-name }} | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| name: ${{ matrix.target.artifact-name }} | |
| - env: | |
| WASMKIT_FLAGS: ${{ matrix.target.other-wasmkit-flags }} | |
| ARTIFACT_NAME: ${{ matrix.target.artifact-name }} | |
| run: wasmkit run --dir . $WASMKIT_FLAGS "$ARTIFACT_NAME" --version | |
| - env: | |
| WASMKIT_FLAGS: ${{ matrix.target.other-wasmkit-flags }} | |
| ARTIFACT_NAME: ${{ matrix.target.artifact-name }} | |
| run: wasmkit run --dir . $WASMKIT_FLAGS "$ARTIFACT_NAME" lint -r . | |
| test: | |
| strategy: | |
| matrix: | |
| target: | |
| - sdk: | |
| url: https://download.swift.org/development/wasm-sdk/swift-DEVELOPMENT-SNAPSHOT-2026-07-11-a/swift-DEVELOPMENT-SNAPSHOT-2026-07-11-a_wasm.artifactbundle.tar.gz | |
| checksum: 6a6e928fdd939d1120aa36a5b54085835137d682c1d4c0c3a1e49a8f7ea7d977 | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| - run: ./.github/scripts/ci-install-swiftly.sh | |
| - run: swiftly install -y --use "$SWIFT_VERSION" | |
| - uses: bytecodealliance/actions/wasmtime/setup@6aecabac1eb1dcf7ed94ba9471974415ee2ebef2 # v1.1.2 | |
| with: | |
| version: ${{ env.WASMTIME_VERSION }} | |
| - run: swift --version | |
| - run: wasmtime -V | |
| - env: | |
| SDK_URL: ${{ matrix.target.sdk.url }} | |
| SDK_CHECKSUM: ${{ matrix.target.sdk.checksum }} | |
| run: swift sdk install "$SDK_URL" --checksum "$SDK_CHECKSUM" | |
| - run: swift test --swift-sdk "$(swiftc -print-target-info | jq -r '.swiftCompilerTag')_wasm" --toolset wasi-test-toolset.json --build-system native | |
| results: | |
| if: ${{ always() }} | |
| runs-on: ubuntu-24.04-arm | |
| needs: [build, test-binary, test] | |
| steps: | |
| - run: exit 1 | |
| if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} |