Skip to content

Commit 04414ab

Browse files
authored
Use reusable Claude Code workflow from test-infra (pytorch#18525)
## Summary - The hand-rolled `claude-code.yml` was failing because it only installed `lintrunner` but not `lintrunner-adapters` or the lintrunner requirements, causing `lintrunner init` to fail with `No module named lintrunner_adapters` - Switches to the centralized reusable workflow from `pytorch/test-infra` (`_claude-code.yml`), passing lintrunner setup via the `setup_script` input - This also picks up additional features from the reusable workflow: ghstack PR detection, commit author attribution, and write-access verification - Drops the `pull_request_review_comment` trigger which the reusable workflow intentionally does not support for [security reasons](https://github.com/orgs/community/discussions/55940#discussioncomment-5950832) Example of the failing job: https://github.com/pytorch/executorch/actions/runs/23601405262/job/68732162666 ## Test plan - Verify the workflow file is valid YAML and the `uses` reference resolves - After merge, trigger with `@claude` on a PR comment to confirm the job runs successfully
1 parent b6824d1 commit 04414ab

1 file changed

Lines changed: 7 additions & 55 deletions

File tree

.github/workflows/claude-code.yml

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,68 +3,20 @@ name: Claude Code
33
on:
44
issue_comment:
55
types: [created]
6-
pull_request_review_comment:
7-
types: [created]
86
issues:
97
types: [opened]
108

119
jobs:
1210
claude-code:
13-
# Early exit conditions (fast gate — avoids spinning up a runner for unauthorized users):
14-
# 1. Must be pytorch org
15-
# 2. Must mention @claude
16-
# 3. Must be org member/collaborator OR an allowed bot
17-
# Note: issue_comment and pull_request_review_comment share the same payload paths
18-
if: |
19-
github.repository_owner == 'pytorch' &&
20-
(
21-
(github.event_name != 'issues' &&
22-
contains(github.event.comment.body, '@claude') &&
23-
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||
24-
(github.event_name == 'issues' &&
25-
contains(github.event.issue.body, '@claude') &&
26-
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association))
27-
)
28-
runs-on: ubuntu-latest
29-
timeout-minutes: 60
30-
environment: bedrock
11+
uses: pytorch/test-infra/.github/workflows/_claude-code.yml@main
12+
with:
13+
setup_script: |
14+
pip install lintrunner==0.12.7 lintrunner-adapters==0.13.0
15+
pip install -r requirements-lintrunner.txt
16+
lintrunner init
3117
permissions:
3218
contents: read
3319
pull-requests: write
3420
issues: write
3521
id-token: write
36-
steps:
37-
# Fork PR support enabled by using izaitsevfb/claude-code-action@forked-pr-fix
38-
39-
- uses: actions/checkout@v4
40-
with:
41-
fetch-depth: 1
42-
43-
- name: Set up Python
44-
uses: actions/setup-python@v5
45-
with:
46-
python-version: '3.12'
47-
48-
- name: Install lintrunner
49-
run: |
50-
pip install lintrunner==0.12.5
51-
lintrunner init
52-
53-
- name: Configure AWS credentials via OIDC
54-
uses: aws-actions/configure-aws-credentials@v4
55-
with:
56-
role-to-assume: arn:aws:iam::308535385114:role/gha_workflow_claude_code
57-
aws-region: us-east-1
58-
59-
- name: Run Claude Code
60-
uses: izaitsevfb/claude-code-action@forked-pr-fix
61-
with:
62-
# We filter by github.actor at workflow level, there is no point of filtering here as well
63-
allowed_bots: "*"
64-
claude_args: "--model global.anthropic.claude-opus-4-6-v1"
65-
settings: '{"alwaysThinkingEnabled": true}'
66-
use_bedrock: "true"
67-
68-
- name: Upload usage metrics
69-
if: always()
70-
uses: pytorch/test-infra/.github/actions/upload-claude-usage@main
22+
secrets: inherit

0 commit comments

Comments
 (0)