ci: skip Claude-backed test jobs on fork PRs (#1655)

* ci: skip Claude-backed test jobs on fork PRs

Jobs that run the action against the Claude API authenticate via workload
identity federation, which fork PRs cannot mint an OIDC token for, so they
always failed on external contributions. Gate each such job on the PR head
repo matching the base repo; push and workflow_dispatch runs are unaffected.

No-Verification-Needed: CI workflow config only, exercised by Actions on the PR

* test: pin the bare remote's initial branch in fetch-depth test

The shallow-clone case created its bare remote with a plain git init, so
HEAD pointed at whatever init.defaultBranch resolves to (master on CI)
while the test only pushed main. git clone --depth=1 implies
--single-branch, and with a dangling remote HEAD it produces an empty,
non-shallow clone, so the is-shallow assertion failed on runners whose
default branch is not main.

No-Verification-Needed: test-only change
This commit is contained in:
Ashwin Bhat
2026-08-14 16:40:34 -07:00
committed by GitHub
parent b49813d0e7
commit a2cac87e27
7 changed files with 41 additions and 2 deletions
+2
View File
@@ -6,6 +6,8 @@ on:
jobs: jobs:
review: review:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
+4
View File
@@ -19,6 +19,8 @@ permissions:
jobs: jobs:
test-inline-prompt: test-inline-prompt:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -70,6 +72,8 @@ jobs:
fi fi
test-prompt-file: test-prompt-file:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -14,6 +14,8 @@ permissions:
jobs: jobs:
test-custom-executables: test-custom-executables:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+4
View File
@@ -14,6 +14,8 @@ permissions:
jobs: jobs:
test-mcp-integration: test-mcp-integration:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
@@ -94,6 +96,8 @@ jobs:
echo "✓ All MCP server checks passed!" echo "✓ All MCP server checks passed!"
test-mcp-config-flag: test-mcp-config-flag:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
+8
View File
@@ -14,6 +14,8 @@ permissions:
jobs: jobs:
test-settings-inline-allow: test-settings-inline-allow:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -65,6 +67,8 @@ jobs:
fi fi
test-settings-inline-deny: test-settings-inline-deny:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -99,6 +103,8 @@ jobs:
fi fi
test-settings-file-allow: test-settings-file-allow:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -155,6 +161,8 @@ jobs:
fi fi
test-settings-file-deny: test-settings-file-deny:
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+11 -1
View File
@@ -15,6 +15,8 @@ permissions:
jobs: jobs:
test-basic-types: test-basic-types:
name: Test Basic Type Conversions name: Test Basic Type Conversions
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -76,6 +78,8 @@ jobs:
test-complex-types: test-complex-types:
name: Test Arrays and Objects name: Test Arrays and Objects
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -129,6 +133,8 @@ jobs:
test-edge-cases: test-edge-cases:
name: Test Edge Cases name: Test Edge Cases
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -190,6 +196,8 @@ jobs:
test-name-sanitization: test-name-sanitization:
name: Test Output Name Sanitization name: Test Output Name Sanitization
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -232,6 +240,8 @@ jobs:
test-execution-file-structure: test-execution-file-structure:
name: Test Execution File Format name: Test Execution File Format
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -284,7 +294,7 @@ jobs:
- test-edge-cases - test-edge-cases
- test-name-sanitization - test-name-sanitization
- test-execution-file-structure - test-execution-file-structure
if: always() if: ${{ always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
steps: steps:
- name: Generate Summary - name: Generate Summary
run: | run: |
+10 -1
View File
@@ -28,7 +28,16 @@ describe("setupBranch fetch depth", () => {
repoDir = join(tempDir, "repo"); repoDir = join(tempDir, "repo");
const remoteDir = join(tempDir, "origin.git"); const remoteDir = join(tempDir, "origin.git");
execFileSync("git", ["init", "--bare", remoteDir], { stdio: "pipe" }); // Pin the remote's HEAD to main: with the default init.defaultBranch of
// master it would dangle, and `git clone --depth=1` (which implies
// --single-branch) then produces an empty, non-shallow clone.
execFileSync(
"git",
["init", "--bare", "--initial-branch=main", remoteDir],
{
stdio: "pipe",
},
);
execFileSync("git", ["init", repoDir], { stdio: "pipe" }); execFileSync("git", ["init", repoDir], { stdio: "pipe" });
git(["checkout", "-b", "main"]); git(["checkout", "-b", "main"]);
git(["config", "user.email", "test@example.com"]); git(["config", "user.email", "test@example.com"]);