Skip to content

Default test-infra-ref to "main" in reusable job workflows - #8472

Merged
huydhn merged 2 commits into
mainfrom
default-test-infra-ref-to-main
Aug 7, 2026
Merged

Default test-infra-ref to "main" in reusable job workflows#8472
huydhn merged 2 commits into
mainfrom
default-test-infra-ref-to-main

Conversation

@huydhn

@huydhn huydhn commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The reusable *_job* / build_wheels_* / _binary_upload workflows default test-infra-ref to "" and pass it to actions/checkout as ref:. An empty ref makes checkout do a "Determining the default branch" REST call per job, which under large fan-out exhausts the org GitHub App installation rate limit — the cause of the Checkout repository (pytorch/test-infra@) failures in pytorch-gha-infra#1375.

Default it to "main" instead. main is what an empty ref already resolves to, so no checkout behavior changes — checkout just skips the default-branch lookup, dropping that call from the quota path for consumers that don't pin their own ref.

Mitigation, not a full fix: it doesn't bound the fan-out or the separate runner-registration quota (see #1375), and explicit test-infra-ref: '' callers still override it. Draft for infra owners to confirm on CI.

Authored with assistance from Claude Code.

The reusable `*_job*` and `build_wheels_*` workflows default
`test-infra-ref` to an empty string and pass it straight to
`actions/checkout` as `ref:`. With an empty ref, checkout makes a
"Determining the default branch" REST call per job to resolve the ref.

Under a large CI fan-out (e.g. pytorch/executorch), those per-job calls
exhaust the org-scoped GitHub App installation rate limit, and the
`Checkout repository (pytorch/test-infra@)` step then fails with
`API rate limit exceeded for installation`
(meta-pytorch/pytorch-gha-infra#1375).

`main` is already the branch an empty ref resolves to, so this changes
no checkout behavior — it only lets checkout skip the default-branch
lookup, removing that call from the quota-consuming path for every
consumer that does not pin its own ref.

Draft: mitigates the checkout failures; bounding the fan-out
(concurrency on ciflow/ghstack runs) is the complementary fix and is
tracked separately.

Authored with assistance from Claude Code.
@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 Aug 7, 2026
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
torchci Ignored Ignored Aug 7, 2026 7:49pm

Request Review

@huydhn
huydhn requested a review from atalman August 7, 2026 18:54
@huydhn
huydhn marked this pull request as ready for review August 7, 2026 18:54

@atalman atalman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how this will affect release branches ?

@huydhn

huydhn commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

how this will affect release branches ?

I don't think it can't affect release branch in anyway. Leaving an empty ref here will use main branch anyway, but cost one more API call to GitHub

@huydhn
huydhn requested a review from atalman August 7, 2026 19:45
Now that the reusable workflows carry an explicit `default: "main"` for
test-infra-ref, the release-cutting script must switch that default to
the release branch too — otherwise a cut release/x.y branch would still
default to checking out test-infra@main.

The existing sed only rewrites caller-style `test-infra-ref: main` and
`@main` refs; the input default lives on a separate `default:` line. Add
a scoped sed that rewrites `default: "main"` only within a
`test-infra-ref:` input block (bounded by the next `type:`), so unrelated
inputs such as greenlight-review.yml's `ref:` default are left untouched.
@huydhn

huydhn commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Good catch — addressed in 8315dbf.

Two parts:

  1. Runtime behavior on release branches is unchanged by the default flip itself. An empty test-infra-ref already resolved to test-infra's default branch (main) via checkout's "determine default branch" call, so callers that don't set a ref were effectively on main before and after this change — the flip just makes that explicit and skips the extra API call.

  2. The release cut now rewrites this new default. The existing update_test_infra_branch() only rewrote @main and caller-style test-infra-ref: main; the input default: lives on its own line and was missed. Added a scoped sed that rewrites default: "main"default: "release/x.y" only inside a test-infra-ref: input block (bounded by the next type:), so unrelated inputs — e.g. greenlight-review.yml's ref: default — stay on main.

Simulated a release/2.9 cut over all workflows: 13 test-infra-ref defaults switch to release/2.9 (the 10 here + 3 generate_*_matrix.yml that already hardcoded main), greenlight-review.yml untouched, @main@release/2.9 still applied. So a cut release branch now checks out test-infra@release/x.y for unpinned callers, matching the intent of the existing rewrites.

@atalman atalman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@huydhn
huydhn merged commit b7742f8 into main Aug 7, 2026
144 of 155 checks passed
@huydhn
huydhn deleted the default-test-infra-ref-to-main branch August 7, 2026 20:35
huydhn added a commit to pytorch/executorch that referenced this pull request Aug 7, 2026
The mobile_job call passed `test-infra-ref: ''`, which makes
actions/checkout resolve the default branch via a REST call and, under CI
fan-out, contributes to GitHub App installation rate-limit exhaustion
(meta-pytorch/pytorch-gha-infra#1375). An explicit ref skips that lookup;
`main` is the branch the empty ref already resolved to.

This is the one call site that overrode pytorch/test-infra#8472's new
`main` default with an explicit empty string.
huydhn added a commit to pytorch/executorch that referenced this pull request Aug 7, 2026
Tag-triggered workflows key concurrency on `${{
github.event.pull_request.number || github.sha }}`. On a `ciflow/*` tag
push there is no PR number, so the group falls back to `github.sha` —
each re-push points at a new sha, gets its own group, and never cancels
the prior run. `cancel-in-progress` is dead for tag pushes.

On Aug 5 a burst of ciflow re-pushes fanned out to 46 shas / 117 runs,
buried the shared `macos-m1-stable` fleet, and drove `main` macOS
coverage to 0
([gha-infra#1391](meta-pytorch/pytorch-gha-infra#1391)).

## Fix

Fall back to `github.ref_name` (stable across re-pushes of the same tag)
and gate the sha term on `github.ref_type == 'branch'`, matching
`periodic.yml` in this repo and `pytorch/pytorch`'s `trunk.yml`:

```yaml
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-...
```

Applied to all 29 workflows carrying the old key (22 are tag-exposed;
the other 7 are fixed for uniformity). Also drops a stray `--` in the
nightly/test-backend group strings. `doc-build.yml` was already correct
(keys on `github.ref`) and is untouched.

## Also: apple.yml test-infra-ref

`apple.yml` passed `test-infra-ref: ''` to the `mobile_job` call,
forcing `actions/checkout` to resolve the default branch via a REST call
— a contributor to GitHub App installation rate-limit exhaustion
([gha-infra#1375](meta-pytorch/pytorch-gha-infra#1375)).
Set it to `main` (the branch the empty ref already resolved to). This is
the one executorch call site that overrode the new `main` default from
[pytorch/test-infra#8472](pytorch/test-infra#8472);
every other call site inherits that default.

## Review

`periodic.yml` (unchanged) is the template — verify `trunk.yml` matches
it; the other 28 are the identical one-line change. The `apple.yml` line
is independent.

---
Authored with assistance from Claude Code.
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.

2 participants