Skip to content

Use reusable Claude Code workflow from test-infra#18525

Merged
JacobSzwejbka merged 1 commit into
mainfrom
zainr/use-reusable-claude-workflow
Mar 26, 2026
Merged

Use reusable Claude Code workflow from test-infra#18525
JacobSzwejbka merged 1 commit into
mainfrom
zainr/use-reusable-claude-workflow

Conversation

@ZainRizvi
Copy link
Copy Markdown
Contributor

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

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

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".

Switch to the centralized reusable workflow from pytorch/test-infra which
also provides additional features: ghstack PR detection, commit author
attribution, and write-access verification. The lintrunner setup is passed
via the setup_script input.

Also drops the pull_request_review_comment trigger which the reusable
workflow intentionally does not support for security reasons (PR branch
code could be injected when a maintainer comments).
Copilot AI review requested due to automatic review settings March 26, 2026 15:09
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Mar 26, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18525

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 1 Pending, 2 Unrelated Failures

As of commit 4300947 with merge base 59838fc (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 26, 2026
@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@ZainRizvi ZainRizvi requested a review from JacobSzwejbka March 26, 2026 15:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the repository’s Claude Code GitHub Actions workflow to use the centralized reusable workflow from pytorch/test-infra, aiming to fix the current lintrunner initialization failure and inherit standardized behavior (e.g., PR detection and access checks).

Changes:

  • Replace the in-repo “hand-rolled” Claude Code workflow steps with a reusable workflow invocation (pytorch/test-infra/.github/workflows/_claude-code.yml@main).
  • Provide a setup_script to install lintrunner, lintrunner-adapters, and requirements-lintrunner.txt before running lintrunner init.
  • Remove the pull_request_review_comment trigger.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 10 to +16
claude-code:
# Early exit conditions (fast gate — avoids spinning up a runner for unauthorized users):
# 1. Must be pytorch org
# 2. Must mention @claude
# 3. Must be org member/collaborator OR an allowed bot
# Note: issue_comment and pull_request_review_comment share the same payload paths
if: |
github.repository_owner == 'pytorch' &&
(
(github.event_name != 'issues' &&
contains(github.event.comment.body, '@claude') &&
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||
(github.event_name == 'issues' &&
contains(github.event.issue.body, '@claude') &&
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association))
)
runs-on: ubuntu-latest
timeout-minutes: 60
environment: bedrock
uses: pytorch/test-infra/.github/workflows/_claude-code.yml@main
with:
setup_script: |
pip install lintrunner==0.12.7 lintrunner-adapters==0.13.0
pip install -r requirements-lintrunner.txt
lintrunner init
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous workflow had a caller-side job if: gate (repo owner, @claude mention, and author_association) to avoid running for every new issue/issue_comment and to prevent unauthorized users from triggering a secrets-enabled job. With the reusable workflow call, that gate is gone, so this workflow will trigger on all issues: opened and issue_comment: created events unless the reusable workflow reintroduces an equivalent top-level guard.

Consider adding back a job-level if: in this caller (even if the reusable workflow also checks) to preserve the fast exit behavior and reduce both cost/noise and the blast radius if the called workflow’s checks ever regress.

Copilot uses AI. Check for mistakes.
types: [opened]

jobs:
claude-code:
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous job set environment: bedrock. That environment context is now removed in the caller. If that environment was relied on for protection rules (required reviewers) or for environment-scoped secrets/vars used by the Claude/BEDROCK setup, this change could either break the workflow or weaken the intended access controls.

If the reusable workflow supports specifying an environment, consider passing/setting it explicitly (or document why it’s no longer needed).

Suggested change
claude-code:
claude-code:
environment: bedrock

Copilot uses AI. Check for mistakes.
@JacobSzwejbka
Copy link
Copy Markdown
Contributor

Thank you

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Mar 26, 2026

@ZainRizvi has imported this pull request. If you are a Meta employee, you can view this in D98337905.

@JacobSzwejbka JacobSzwejbka merged commit 04414ab into main Mar 26, 2026
168 of 174 checks passed
@JacobSzwejbka JacobSzwejbka deleted the zainr/use-reusable-claude-workflow branch March 26, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants