Use SwiftSyntax prebuilt action in CI #2726
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: Run unit tests | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }} | |
| cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }} | |
| jobs: | |
| test: | |
| if: false # TEMP: narrow CI while debugging SwiftSyntax prebuilt consumption. | |
| name: Build and Test | |
| strategy: | |
| matrix: | |
| entry: | |
| - os: ubuntu-24.04 | |
| toolchain: | |
| download-url: https://download.swift.org/development/ubuntu2404/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu24.04.tar.gz | |
| swift-syntax-version: "603.0.2" | |
| wasi-backend: Node | |
| target: "wasm32-unknown-wasip1" | |
| env: | | |
| JAVASCRIPTKIT_DISABLE_TRACING_TRAIT=1 | |
| - os: ubuntu-24.04 | |
| toolchain: | |
| download-url: https://download.swift.org/swift-6.3-branch/ubuntu2404/swift-6.3-DEVELOPMENT-SNAPSHOT-2026-03-05-a/swift-6.3-DEVELOPMENT-SNAPSHOT-2026-03-05-a-ubuntu24.04.tar.gz | |
| swift-syntax-version: "603.0.2" | |
| wasi-backend: Node | |
| target: "wasm32-unknown-wasip1" | |
| - os: ubuntu-22.04 | |
| toolchain: | |
| download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz | |
| swift-syntax-version: "603.0.2" | |
| wasi-backend: Node | |
| target: "wasm32-unknown-wasip1-threads" | |
| runs-on: ${{ matrix.entry.os }} | |
| env: | |
| JAVASCRIPTKIT_WASI_BACKEND: ${{ matrix.entry.wasi-backend }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Export matrix env | |
| if: ${{ matrix.entry.env != '' && matrix.entry.env != null }} | |
| run: | | |
| cat <<'EOF' >> "$GITHUB_ENV" | |
| ${{ matrix.entry.env }} | |
| EOF | |
| - uses: ./.github/actions/install-swift | |
| with: | |
| download-url: ${{ matrix.entry.toolchain.download-url }} | |
| - uses: swiftwasm/setup-swiftwasm@v2 | |
| id: setup-swiftwasm | |
| with: | |
| target: ${{ matrix.entry.target }} | |
| - name: Configure environment variables | |
| run: | | |
| echo "SWIFT_SDK_ID=${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" >> $GITHUB_ENV | |
| echo "SWIFT_BIN_PATH=$(dirname $(which swiftc))" >> $GITHUB_ENV | |
| - uses: swiftwasm/setup-swift-syntax-prebuilts@yt/support-swiftpm-triple-build-dir | |
| id: swiftsyntax-prebuilts | |
| with: | |
| swift-syntax-version: ${{ matrix.entry.swift-syntax-version }} | |
| - run: make bootstrap | |
| - run: make unittest | |
| # Skip unit tests with uwasi because its proc_exit throws | |
| # unhandled promise rejection. | |
| if: ${{ matrix.entry.wasi-backend != 'MicroWASI' }} | |
| env: | |
| SWIFT_PACKAGE_FLAGS: ${{ steps.swiftsyntax-prebuilts.outputs.swift-flags }} | |
| - name: Check if SwiftPM resources are stale | |
| run: | | |
| make regenerate_swiftpm_resources | |
| git diff --exit-code Sources/JavaScriptKit/Runtime | |
| - run: swift test ${{ steps.swiftsyntax-prebuilts.outputs.swift-flags }} --package-path ./Plugins/PackageToJS | |
| - run: swift test ${{ steps.swiftsyntax-prebuilts.outputs.swift-flags }} --package-path ./Plugins/BridgeJS | |
| env: | |
| BRIDGEJS_OVERRIDE_SWIFT_SYNTAX_VERSION: ${{ matrix.entry.swift-syntax-version }} | |
| - name: Validate BridgeJS TypeScript declarations | |
| run: npm run check:bridgejs-dts | |
| test-bridgejs-against-swift-versions: | |
| if: false # TEMP: narrow CI while debugging SwiftSyntax prebuilt consumption. | |
| name: Test BridgeJS against Swift versions | |
| strategy: | |
| matrix: | |
| entry: | |
| - image: "swift:6.3" | |
| swift-syntax-version: "603.0.2" | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ${{ matrix.entry.image }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| - name: Install TypeScript | |
| run: npm install | |
| - name: Validate BridgeJS TypeScript declarations | |
| run: npm run check:bridgejs-dts | |
| - name: Run BridgeJS tests | |
| # NOTE: This job runs in the swift Docker image, whose compiler tag is | |
| # swift-6.3.2-RELEASE. No matching release asset is currently published | |
| # for the setup action, so using it falls back to a local SwiftSyntax | |
| # prebuild and makes the job slower than building normally. | |
| run: swift test --disable-experimental-prebuilts --package-path ./Plugins/BridgeJS | |
| env: | |
| BRIDGEJS_OVERRIDE_SWIFT_SYNTAX_VERSION: ${{ matrix.entry.swift-syntax-version }} | |
| native-build: | |
| if: false # TEMP: narrow CI while debugging SwiftSyntax prebuilt consumption. | |
| # Check native build to make it easy to develop applications by Xcode | |
| name: Build for native target | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-15 | |
| xcode: Xcode_26.0.1 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: swift build --product BridgeJSTool | |
| env: | |
| DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer/ | |
| - run: swift build --package-path ./Examples/Basic | |
| env: | |
| DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer/ | |
| prettier: | |
| if: false # TEMP: narrow CI while debugging SwiftSyntax prebuilt consumption. | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| - run: npm install | |
| - run: npx prettier --check Runtime/src | |
| format: | |
| if: false # TEMP: narrow CI while debugging SwiftSyntax prebuilt consumption. | |
| runs-on: ubuntu-latest | |
| container: | |
| image: swift:6.3 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: ./Utilities/format.swift | |
| - name: Check for formatting changes | |
| run: | | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| git diff --exit-code || { | |
| echo "::error::The formatting changed some files. Please run \`./Utilities/format.swift\` and commit the changes." | |
| exit 1 | |
| } | |
| check-bridgejs-generated: | |
| if: false # TEMP: narrow CI while debugging SwiftSyntax prebuilt consumption. | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ./.github/actions/install-swift | |
| with: | |
| download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz | |
| - uses: swiftwasm/setup-swift-syntax-prebuilts@yt/support-swiftpm-triple-build-dir | |
| id: swiftsyntax-prebuilts | |
| with: | |
| swift-syntax-version: "600.0.1" | |
| - run: make bootstrap | |
| - run: ./Utilities/bridge-js-generate.sh | |
| env: | |
| SWIFT_PACKAGE_FLAGS: ${{ steps.swiftsyntax-prebuilts.outputs.swift-flags }} | |
| - name: Check if BridgeJS generated files are up-to-date | |
| run: | | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| git diff --exit-code || { | |
| echo "::error::BridgeJS generated files are out of date. Please run \`./Utilities/bridge-js-generate.sh\` and commit the changes." | |
| exit 1 | |
| } | |
| build-examples: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ./.github/actions/install-swift | |
| with: | |
| download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz | |
| - uses: swiftwasm/setup-swiftwasm@v2 | |
| id: setup-wasm32-unknown-wasip1 | |
| with: { target: wasm32-unknown-wasip1 } | |
| - uses: swiftwasm/setup-swiftwasm@v2 | |
| id: setup-wasm32-unknown-wasip1-threads | |
| with: { target: wasm32-unknown-wasip1-threads } | |
| - uses: swiftwasm/setup-swift-syntax-prebuilts@yt/support-swiftpm-triple-build-dir | |
| id: swiftsyntax-prebuilts | |
| with: | |
| swift-syntax-version: "603.0.2" | |
| - run: | | |
| swift --version | |
| echo "SwiftSyntax restore source: ${{ steps.swiftsyntax-prebuilts.outputs.restore-source }}" | |
| echo "SwiftSyntax cache hit: ${{ steps.swiftsyntax-prebuilts.outputs.cache-hit }}" | |
| echo "SwiftSyntax prebuilts path: ${{ steps.swiftsyntax-prebuilts.outputs.prebuilts-path }}" | |
| find "${{ steps.swiftsyntax-prebuilts.outputs.prebuilts-path }}" -maxdepth 3 -type f | sort | |
| swift package --verbose ${SWIFT_PACKAGE_FLAGS} --package-path Examples/ActorOnWebWorker resolve | |
| find Examples/ActorOnWebWorker/.build/prebuilts -maxdepth 5 -print 2>/dev/null | sort || true | |
| find Examples/ActorOnWebWorker/.build -name workspace-state.json -print -exec sed -n '1,240p' {} \; || true | |
| cd Examples/ActorOnWebWorker | |
| swift package --verbose ${SWIFT_PACKAGE_FLAGS} \ | |
| --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1_threads:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}}" \ | |
| plugin --allow-writing-to-package-directory \ | |
| js --use-cdn --output ./Bundle -c release | |
| env: | |
| SWIFT_SDK_ID_wasm32_unknown_wasip1_threads: ${{ steps.setup-wasm32-unknown-wasip1-threads.outputs.swift-sdk-id }} | |
| SWIFT_SDK_ID_wasm32_unknown_wasip1: ${{ steps.setup-wasm32-unknown-wasip1.outputs.swift-sdk-id }} | |
| SWIFT_PACKAGE_FLAGS: ${{ steps.swiftsyntax-prebuilts.outputs.swift-flags }} | |
| - if: false # TEMP: skip pages packaging while debugging one example. | |
| run: ./Utilities/prepare-gh-pages.sh | |
| - name: Upload static files as artifact | |
| if: false # TEMP: skip pages artifact upload while debugging one example. | |
| id: deployment | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: ./_site | |
| deploy-examples: | |
| runs-on: ubuntu-latest | |
| if: false # TEMP: narrow CI while debugging SwiftSyntax prebuilt consumption. | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| needs: build-examples | |
| permissions: | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |