From 14b1137f5c0f7aa65ad207e1162ddbc20538004d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Fri, 28 Aug 2026 13:38:55 +0200 Subject: [PATCH] Skip CI build/test jobs on doc-only changes Add a `changes` gate (dorny/paths-filter) that checks whether a push/PR touches actual code (**/*.scala, project.scala, .scalafmt.conf, or ci.yml itself). Scalafmt, Test and Compile are gated behind it with a job-level `if`, so a PR that only touches README.md/renovate.json/.github/sync.yml etc. no longer spins up the full build+test matrix. A skipped job reports "Success" and satisfies a required status check, but skipping a *matrix* job at the top level leaves its required inner checks ("Test (scala-js)", "Test (scala-native)") pending forever instead (actions/runner#952). So test-cross-platform is split into two plain jobs, test-scala-js and test-scala-native, that can be individually skipped. `compile` stays a matrix (its per-platform checks aren't required, so a top-level skip there is harmless). Required status check names are unchanged: Scalafmt, Test, Test (scala-js), Test (scala-native). Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_019awuXm5QZgXajLw3PvGo1s --- .github/workflows/ci.yml | 75 ++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42b5641..2de8f7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,33 @@ on: branches: [ master ] jobs: + # Gate the build/test jobs so doc-only changes (README, renovate.json, + # sync config, …) don't run the suite. The gated jobs keep their names as + # required status checks; skipped via a job-level `if` they report Success. + # `test-cross-platform` is split into one job per platform on purpose: + # skipping a *matrix* job leaves its required inner checks pending forever + # (actions/runner#952). + changes: + name: Detect code changes + runs-on: ubuntu-latest + outputs: + code: ${{ steps.filter.outputs.code }} + steps: + - uses: actions/checkout@v7 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + code: + - '**/*.scala' + - 'project.scala' + - '.scalafmt.conf' + - '.github/workflows/ci.yml' + lint: name: Scalafmt + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -20,6 +45,8 @@ jobs: test: name: Test + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -51,6 +78,8 @@ jobs: compile: name: Compile (${{ matrix.platform }}) + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -77,19 +106,15 @@ jobs: - name: Compile run: scala-cli --power compile . --platform ${{ matrix.platform }} ${{ matrix.args }} - # JVM is covered by the `test` job above (with coverage/docs); this just runs - # the same suite on the other targets to catch platform-specific regressions. - test-cross-platform: - name: Test (${{ matrix.platform }}) + # JVM is covered by the `test` job above (with coverage/docs); these two just + # run the same suite on the other targets to catch platform-specific + # regressions. Kept as separate jobs (not a matrix) so they can be skipped + # individually without hanging their required checks. + test-scala-js: + name: Test (scala-js) + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - platform: scala-js - args: "--js-version 1.22.0" - - platform: scala-native - args: "--native-version 0.5.12" steps: - uses: actions/checkout@v7 - name: Setup coursier cache @@ -98,9 +123,29 @@ jobs: uses: actions/cache@v6 with: path: .scala-build - key: scala-build-${{ matrix.platform }}-${{ hashFiles('project.scala', '**/*.scala') }} + key: scala-build-scala-js-${{ hashFiles('project.scala', '**/*.scala') }} restore-keys: | - scala-build-${{ matrix.platform }}- + scala-build-scala-js- + - uses: VirtusLab/scala-cli-setup@v1 + - name: Run tests + run: scala-cli --power test . --platform scala-js --js-version 1.22.0 + + test-scala-native: + name: Test (scala-native) + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - name: Setup coursier cache + uses: coursier/cache-action@v8.1 + - name: Cache scala-cli/Bloop incremental build + uses: actions/cache@v6 + with: + path: .scala-build + key: scala-build-scala-native-${{ hashFiles('project.scala', '**/*.scala') }} + restore-keys: | + scala-build-scala-native- - uses: VirtusLab/scala-cli-setup@v1 - name: Run tests - run: scala-cli --power test . --platform ${{ matrix.platform }} ${{ matrix.args }} + run: scala-cli --power test . --platform scala-native --native-version 0.5.12