From 79851bbf1ab7efe2d9371c20ceb3fabce06a3727 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 11 Nov 2026 13:09:13 +0100 Subject: [PATCH 1/3] Skip build and test jobs for Markdown-only pushes to a passing PR --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 504772d8c..09d36c3ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,39 @@ jobs: with: access_token: ${{ github.token }} + # A push to a PR that changes only Markdown files since a head that already passed CI skips the build and test jobs. + changes: + name: Check for code changes + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + outputs: + run: ${{ steps.check.outputs.run }} + steps: + - id: check + shell: bash + env: + GH_TOKEN: ${{ github.token }} + BEFORE: ${{ github.event.action == 'synchronize' && github.event.before || '' }} + HEAD: ${{ github.event.pull_request.head.sha }} + run: | + run=true + if [[ -n "$BEFORE" ]]; then + passed=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$BEFORE&event=pull_request&status=success" --jq '.total_count') + if [[ "$passed" -gt 0 ]]; then + # The compare API lists at most 300 files; "ahead" rules out force-pushes that dropped commits. + run=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BEFORE...$HEAD" --jq ' + if .status == "ahead" and (.files | length) > 0 and (.files | length) < 300 + and all(.files[]; (.filename | endswith(".md")) and ((.previous_filename // ".md") | endswith(".md"))) + then "false" else "true" end') + fi + fi + echo "run=$run" >> "$GITHUB_OUTPUT" + if [[ "$run" == "false" ]]; then + echo "Only Markdown files changed since $BEFORE, which passed CI. Skipping the build and test jobs." >> "$GITHUB_STEP_SUMMARY" + fi + create-unity-matrix: uses: ./.github/workflows/create-unity-matrix.yml with: @@ -34,6 +67,8 @@ jobs: head-ref: ${{ github.head_ref }} sdk: + needs: [changes] + if: ${{ needs.changes.outputs.run == 'true' }} strategy: matrix: include: @@ -66,6 +101,8 @@ jobs: build-unity-sdk: name: Build Unity SDK + needs: [changes] + if: ${{ needs.changes.outputs.run == 'true' }} secrets: UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} permissions: @@ -83,6 +120,8 @@ jobs: package-validation: name: UPM Package validation + needs: [changes] + if: ${{ needs.changes.outputs.run == 'true' }} runs-on: ubuntu-latest steps: - name: Checkout @@ -127,8 +166,8 @@ jobs: # This produces the `samples/IntegrationTest` as `test-${{ matrix.unity-version }}`. test-create: name: Create ${{ matrix.unity-version }} Test Project - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [create-unity-matrix] + if: ${{ needs.changes.outputs.run == 'true' && !startsWith(github.ref, 'refs/heads/release/') }} + needs: [changes, create-unity-matrix] secrets: UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} strategy: From 6b278f6169edb5b400d868cafa91207e4a341d21 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 11 Nov 2026 13:11:54 +0100 Subject: [PATCH 2/3] Run CI when the change check fails or touches packaged Markdown --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09d36c3ef..7835c0e67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,13 +46,14 @@ jobs: run: | run=true if [[ -n "$BEFORE" ]]; then - passed=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$BEFORE&event=pull_request&status=success" --jq '.total_count') + passed=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$BEFORE&event=pull_request&status=success" --jq '.total_count') || passed=0 if [[ "$passed" -gt 0 ]]; then # The compare API lists at most 300 files; "ahead" rules out force-pushes that dropped commits. + # Markdown under package*/ ships in the UPM package, so it counts as code. run=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BEFORE...$HEAD" --jq ' if .status == "ahead" and (.files | length) > 0 and (.files | length) < 300 - and all(.files[]; (.filename | endswith(".md")) and ((.previous_filename // ".md") | endswith(".md"))) - then "false" else "true" end') + and all(.files[]; [.filename, .previous_filename // empty] | all(endswith(".md") and (startswith("package") | not))) + then "false" else "true" end') || run=true fi fi echo "run=$run" >> "$GITHUB_OUTPUT" From ca09ac34ed8a2d3d926e0369114deda503ee39a3 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 11 Nov 2026 14:37:58 +0100 Subject: [PATCH 3/3] Move the code-change check into its own reusable workflow --- .github/workflows/check-changes.yml | 43 +++++++++++++++++++++++++++++ .github/workflows/ci.yml | 30 +------------------- 2 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/check-changes.yml diff --git a/.github/workflows/check-changes.yml b/.github/workflows/check-changes.yml new file mode 100644 index 000000000..558a07c16 --- /dev/null +++ b/.github/workflows/check-changes.yml @@ -0,0 +1,43 @@ +name: Check for Code Changes + +# A push to a PR that changes only Markdown files since a head that already passed CI skips the build and test jobs. +on: + workflow_call: + outputs: + run: + description: "'true' when CI should run the build and test jobs" + value: ${{ jobs.check.outputs.run }} + +jobs: + check: + name: Check for code changes + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + outputs: + run: ${{ steps.check.outputs.run }} + steps: + - id: check + shell: bash + env: + GH_TOKEN: ${{ github.token }} + BEFORE: ${{ github.event.action == 'synchronize' && github.event.before || '' }} + HEAD: ${{ github.event.pull_request.head.sha }} + run: | + run=true + if [[ -n "$BEFORE" ]]; then + passed=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$BEFORE&event=pull_request&status=success" --jq '.total_count') || passed=0 + if [[ "$passed" -gt 0 ]]; then + # The compare API lists at most 300 files; "ahead" rules out force-pushes that dropped commits. + # Markdown under package*/ ships in the UPM package, so it counts as code. + run=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BEFORE...$HEAD" --jq ' + if .status == "ahead" and (.files | length) > 0 and (.files | length) < 300 + and all(.files[]; [.filename, .previous_filename // empty] | all(endswith(".md") and (startswith("package") | not))) + then "false" else "true" end') || run=true + fi + fi + echo "run=$run" >> "$GITHUB_OUTPUT" + if [[ "$run" == "false" ]]; then + echo "Only Markdown files changed since $BEFORE, which passed CI. Skipping the build and test jobs." >> "$GITHUB_STEP_SUMMARY" + fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7835c0e67..15a033997 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,39 +27,11 @@ jobs: with: access_token: ${{ github.token }} - # A push to a PR that changes only Markdown files since a head that already passed CI skips the build and test jobs. changes: - name: Check for code changes - runs-on: ubuntu-latest + uses: ./.github/workflows/check-changes.yml permissions: actions: read contents: read - outputs: - run: ${{ steps.check.outputs.run }} - steps: - - id: check - shell: bash - env: - GH_TOKEN: ${{ github.token }} - BEFORE: ${{ github.event.action == 'synchronize' && github.event.before || '' }} - HEAD: ${{ github.event.pull_request.head.sha }} - run: | - run=true - if [[ -n "$BEFORE" ]]; then - passed=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$BEFORE&event=pull_request&status=success" --jq '.total_count') || passed=0 - if [[ "$passed" -gt 0 ]]; then - # The compare API lists at most 300 files; "ahead" rules out force-pushes that dropped commits. - # Markdown under package*/ ships in the UPM package, so it counts as code. - run=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BEFORE...$HEAD" --jq ' - if .status == "ahead" and (.files | length) > 0 and (.files | length) < 300 - and all(.files[]; [.filename, .previous_filename // empty] | all(endswith(".md") and (startswith("package") | not))) - then "false" else "true" end') || run=true - fi - fi - echo "run=$run" >> "$GITHUB_OUTPUT" - if [[ "$run" == "false" ]]; then - echo "Only Markdown files changed since $BEFORE, which passed CI. Skipping the build and test jobs." >> "$GITHUB_STEP_SUMMARY" - fi create-unity-matrix: uses: ./.github/workflows/create-unity-matrix.yml