diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dffb42706..0c7de7220 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,9 @@ permissions: on: workflow_dispatch: pull_request: - types: [opened, synchronize] + # `labeled` reruns CI when a pull request gets the `ci: full` label, which + # adds the jobs that pull requests otherwise skip. + types: [opened, synchronize, labeled] push: branches: - main @@ -70,9 +72,10 @@ jobs: if: needs.detect-changes.outputs.code-changed == 'true' name: Test (${{ matrix.shard }}) env: - # Playwright detects the physical Apple Silicon CPU under Rosetta. Force - # its x64 browser for the x86_64 shard so fspy can inject its x64 preload. - PLAYWRIGHT_HOST_PLATFORM_OVERRIDE: ${{ matrix.target == 'x86_64-apple-darwin' && 'mac15' || '' }} + # The steps, shared with `test-macos-x64`, read these instead of `matrix`. + TEST_TARGET: ${{ matrix.target }} + TEST_CARGO_CMD: ${{ matrix.cargo_cmd }} + TEST_BUILD_TARGET: ${{ matrix.build_target }} strategy: fail-fast: false matrix: @@ -87,13 +90,8 @@ jobs: cargo_cmd: cargo build_target: aarch64-apple-darwin shard: macos-arm64 - - os: namespace-profile-mac-default - target: x86_64-apple-darwin - cargo_cmd: cargo - build_target: x86_64-apple-darwin - shard: macos-x64 runs-on: ${{ matrix.os }} - steps: + steps: &test-steps - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 - name: Update submodules @@ -104,37 +102,37 @@ jobs: save-cache: ${{ github.ref_name == 'main' }} cache-key: test - - run: rustup target add ${{ matrix.target }} + - run: rustup target add $TEST_TARGET - run: rustup target add x86_64-unknown-linux-musl - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} + if: env.TEST_TARGET == 'x86_64-unknown-linux-gnu' - run: pipx install cargo-zigbuild - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} + if: env.TEST_TARGET == 'x86_64-unknown-linux-gnu' # pipx isolates cargo-zigbuild in its own venv, so its ziglang dependency # (which bundles zig) isn't on PATH. Install zig separately. - uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} + if: env.TEST_TARGET == 'x86_64-unknown-linux-gnu' - name: Build tests - run: ${{ matrix.cargo_cmd }} test --no-run --target ${{ matrix.build_target }} + run: $TEST_CARGO_CMD test --no-run --target $TEST_BUILD_TARGET # Default `cargo test` runs only tests that need nothing beyond the # Rust toolchain; this step verifies that contract before Node.js # and pnpm enter the picture. - name: Run tests - run: ${{ matrix.cargo_cmd }} test --target ${{ matrix.build_target }} + run: $TEST_CARGO_CMD test --target $TEST_BUILD_TARGET # x86_64-apple-darwin runs on arm64 runner under Rosetta; install x64 Node # so fspy's x86_64 preload dylib can be injected into spawned node procs. - uses: oxc-project/setup-node@f46a72f95efdc55273fcd042d61c84e723b2892c # v1.4.1 with: - architecture: ${{ matrix.target == 'x86_64-apple-darwin' && 'x64' || '' }} + architecture: ${{ env.TEST_TARGET == 'x86_64-apple-darwin' && 'x64' || '' }} - name: Install runtime binaries run: | - if [[ '${{ matrix.target }}' == 'x86_64-apple-darwin' ]]; then + if [[ "$TEST_TARGET" == 'x86_64-apple-darwin' ]]; then # Bun normally prefers the native arm64 binary under Rosetta, but # this job needs x64 Bun so the x64 preload dylib can be injected. PATH="$(dirname "$(command -v node)"):$PNPM_HOME:/usr/bin:/bin" \ @@ -144,13 +142,32 @@ jobs: fi - name: Install Chromium system dependencies - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} + if: env.TEST_TARGET == 'x86_64-unknown-linux-gnu' run: pnpm --filter vite-task-tools exec playwright install-deps chromium - name: Run ignored tests run: | pnpm --filter vite-task-tools test - ${{ matrix.cargo_cmd }} test --target ${{ matrix.build_target }} -- --ignored + $TEST_CARGO_CMD test --target $TEST_BUILD_TARGET -- --ignored + + # Running x64 binaries under Rosetta makes this the slowest job, so pull + # requests run it only with the `ci: full` label. + test-macos-x64: + needs: detect-changes + if: >- + needs.detect-changes.outputs.code-changed == 'true' && + (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci: full')) + # No matrix: a skipped matrix job is listed under its unexpanded name. + name: Test (macos-x64) + runs-on: namespace-profile-mac-default + env: + TEST_TARGET: x86_64-apple-darwin + TEST_CARGO_CMD: cargo + TEST_BUILD_TARGET: x86_64-apple-darwin + # Playwright detects the physical Apple Silicon CPU under Rosetta. Force + # its x64 browser so fspy can inject its x64 preload. + PLAYWRIGHT_HOST_PLATFORM_OVERRIDE: mac15 + steps: *test-steps # Windows tests are cross-compiled on a fast Linux runner with cargo-xwin # (clang-cl + lld-link against the xwin-downloaded MSVC CRT/Windows SDK) @@ -287,9 +304,13 @@ jobs: pnpm --filter vite-task-tools test cargo-nextest nextest run --archive-file windows-tests.tar.zst --workspace-remap . --run-ignored ignored-only + # Building without a Rust cache inside the Alpine container makes this one of + # the slowest jobs, so pull requests run it only with the `ci: full` label. test-musl: needs: detect-changes - if: needs.detect-changes.outputs.code-changed == 'true' + if: >- + needs.detect-changes.outputs.code-changed == 'true' && + (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci: full')) name: Test (musl) runs-on: namespace-profile-linux-x64-default container: @@ -389,6 +410,7 @@ jobs: needs: - clippy - test + - test-macos-x64 - test-musl - build-windows-tests - test-windows