Repository navigation
Check stable-line pull requests with Patch QA and Patch provenance - #9196
craigmichaelmartin wants to merge 13 commits into
Conversation
Patch QA builds the @shopify/cli tarball a release of the pull request's head would publish, installs it on Linux, Windows and macOS (x64 and arm64), runs the checks that need no Shopify account, and fails if its files differ from the line's last release. Patch provenance passes only for a backport whose changes main already has (pinned to the main commit that added its patch changesets) and for the line's Version Packages pull request when it only versions the packages on top of the line's head. It runs from the stable line's own copy of the workflow and reads commits without running the pull request's code. After a release publishes, release.yml installs it from npm on Linux, Windows and macOS and runs the same checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A JSON comparison of package.json and oclif manifests misses changes that parsing normalizes away, such as a duplicated key. Require the same lines, with only version lines changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A backport now has to build on the line's head, and each file it changes has to be, whole, what the main commit that added its changesets does to that file when applied to the line. That commit must have reached main after the line's cut. Before, a backport could reuse an old changeset to bring back old main code, or apply only part of a main commit's change. A Version Packages pull request's new changelog section may only hold the consumed changesets' entries and dependency updates, and no versioned file may change mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Patch QA also runs when a pull request is edited, so a pull request retargeted to a stable line gets it. It runs in full on every edit: a skipped run would count as passing. - The file comparison runs in its own job, so a difference no longer stops the platform installs. A difference only in the number of hashed bundle chunks warns instead of failing. - Patch QA and Release QA package build the tarball through one composite action. - The smoke test pins the Skeleton theme release instead of following its latest tag, and no longer turns off auto-upgrade, which CI=1 already skips. - The release smoke job gets 60 minutes: the wait for npm alone can take 30. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tter Patch provenance now builds each package's new changelog section with the changelog formatter at the line's head, never the pull request's, and requires the section to match it, apart from the order of entries. A missing entry, an extra line, a wrong dependency version or an entry in the wrong package fails. A line whose changesets config doesn't use ./changelog.cjs isn't supported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pull_request_target always loads the workflow from main, whatever the pull request's base, and from December 2, 2026 public repositories block it unless an Actions event policy allows it. On pull_request each stable line runs its own copy. The check still only reads the pull request's commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A backport passed when every file it changed matched main's commit, so one that left files out could ship a changeset without its fix, or one change of a batched commit without the changeset that makes it a minor. Its tree must now be exactly main's commit applied to the line's head, so a fix that reached main together with other changes goes to a maintainer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gonzaloriestra
left a comment
There was a problem hiding this comment.
Thanks for fixing the previous suggestions! But my agent found a few more 😅
Release QA package ran the shared build action from the commit it builds, and stable/4.9 and stable/5.0 don't have it, so a run from main for those lines stopped there. It now checks out the action from the workflow's own commit, and still builds the requested commit with that commit's own dependency setup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A backport fails when the line has had one of its changesets since its cut, or when main's commit changes anything the line already has, so a fix backported before, by hand or under another changeset, isn't released twice. - A Version Packages pull request fails when it consumes a minor or major changeset, or releases a version outside the line's own X.Y. - Every workspace package's pins of a released package must move to the new version, whether or not its package.json changed, and pnpm-lock.yaml must link each workspace package at the version its dependents pin. - The header says that a pull request that changes .github/ runs its own version of these checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A changeset can reach main on its own, for example when it's added after the fix that landed without it. A backport of that commit alone passed as all of main's commit, and would release a changelog entry for code the line may not have. It now fails, and a maintainer backports the fix together with its changeset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gonzaloriestra
left a comment
There was a problem hiding this comment.
Thanks! A few more comments 🫣
Topic help comes from the oclif manifest, so `shopify hydrogen --help` passed without importing Hydrogen. The smoke test now also prints the JSON output schemas of `shopify hydrogen check` and `shopify app info`, which load those commands' code from the plugins that provide them and need no account, and checks that each is the command's own schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed versions - A backport's origin is the landing on main that added its changesets: the commit on main's first-parent chain since the line's cut, compared with its first parent. A merged pull request's own commits no longer count, since one of them can carry a changeset that the merge changed. - main must still have each of the backport's changesets as a patch for the fixed group, unless a release's catch-up consumed it, and a changeset main added more than once since the cut (a revert and a reland) fails. - A Version Packages bump must set version.ts and every oclif manifest to the new version, whether or not it changed them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| for (const {path} of changesets) { | ||
| const text = fileAt(mainHead, path) | ||
| if (text === undefined) { | ||
| checkConsumedByRelease(path, origin, mainHead) |
There was a problem hiding this comment.
In a local replay, changing a changeset from patch to minor on main correctly failed provenance. Once a release consumed it, the same backport passed. Could we read the changeset from the deleting commit’s first parent and apply the patch-only check to that final version?
There was a problem hiding this comment.
Thanks, that reproduces. Fixed in a2ba047: when a release's catch-up consumed the changeset, the check reads main's last copy, at the deleting commit's first parent, and applies the same patch-only check to it. Your replay, a minor on main that a catch-up then consumed, now fails with "main's last copy of .changeset/mfa-required-error.md, before the release in d0b03a5d49 consumed it, bumps @shopify/cli minor".
| .split('\n') | ||
| .find((commit) => commit !== '' && fileAt(commit, path) === undefined) | ||
| const cliKitVersion = (commit) => JSON.parse(fileAt(commit, 'packages/cli-kit/package.json') ?? '{}').version | ||
| if (!deletion || cliKitVersion(deletion) === cliKitVersion(`${deletion}^1`)) { |
There was a problem hiding this comment.
I also replayed a patch that main released and then reverted. The original backport still passed because the version changed when the changeset was consumed. Could we verify that main still contains the fix and leave ambiguous cases for a maintainer?
There was a problem hiding this comment.
Thanks, that reproduces too. Fixed in a2ba047: every backport now needs main's head to still contain the landing's change. Applying the landing to main's head must change nothing outside its changesets, and every file it added must still be there, whatever main has since done to it. A revert fails, and so does a later change to the same lines. That's the ambiguous case, and the message says a maintainer decides whether the line takes the fix. Your replay, released by a catch-up and then reverted, fails. So does a revert that keeps the changeset. A later edit elsewhere in a file the fix changed, or in a file it added, still passes.
I measured how often this applies. Of the 35 patch landings on main since stable/5.0's cut, checked against main today, 18 are ambiguous and none are reverts: later landings changed the same lines. On stable/5.0, 13 of those 18 already fail other rules, so the new rule sends 5 more to a maintainer. The release bot backports within minutes of a landing, so it rarely meets this.
…s last bump - A changeset a release's catch-up consumed must have been a patch for the fixed group in main's last copy before that release. - main's head must still have all of the landing's change: applying it to main's head changes nothing outside its changesets, and every file it added is still there. A revert, or a later change to the same lines, fails, and a maintainer decides whether the line takes the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WHY are these changes introduced?
Patch releases ship from
stable/X.Yas fixes land, instead of waiting for the next minor. Two things then need checking on every pull request into a stable line, by machine rather than by memory:mainalready has, plus its own version bumps;Today a stable line's pull requests run unit tests, but nothing installs the packed CLI or checks where a backport's changes come from. After a release publishes, nothing checks the published package either.
WHAT is this pull request doing?
Patch QA (
patch-qa.yml), on pull requests intostable/**, including ones retargeted there:@shopify/clitarball the way a release does, through.github/actions/build-cli-tarball, which Release QA package now uses too. Release QA package loads the action from its own commit, so a run frommainstill builds lines that don't have it, such asstable/4.9;npm install -gonubuntu-latest,ubuntu-24.04-arm,windows-latest,windows-11-armandmacos-latest;.github/scripts/smoke-test-cli.sh): version, help, the app, theme and Hydrogen topics, the JSON output schemas ofhydrogen checkandapp info(which load those commands' code, as help doesn't), andtheme init(from a pinned Skeleton release),theme checkandtheme package;Patch provenance (
patch-provenance.yml), onpull_requestforstable/**. Each stable line runs its own copy, and the check never checks out or runs the pull request's code: it only reads commits. It passes only for:patchchangesets for the fixed version group, changes no path outside main's mirrored files, and whose tree is exactly what landed onmainwhen its changesets first did, applied to the line's head: the landing's diff against its first parent, so a pull request's own earlier commits never count. That landing must come after the line's cut frommain,mainmust still have each changeset as apatch(or have had, when a release consumed it), and still contain all of the landing's change: a revert, or a later change to the same lines, goes to a maintainer. A changesetmainadded more than once since the cut (a revert and a reland) fails, and none of the landing can be on the line already: a changeset the line has had since its cut, or a change of that commit the line already has, fails, so a fix is never released twice. A commit that batches a fix with other changes therefore goes to a maintainer;X.Y, consumes the line's pending changesets, all of thempatch, setsversion.tsand every oclif manifest to the new version, and otherwise changes only package versions and pins, the lockfile's workspace specifiers, and changelog sections exactly as the line's own.changeset/changelog.cjswrites them for the consumed changesets and dependency updates. Every pin of a released package must move to its new version, and the lockfile must link each workspace package at the version its dependents pin. Only lines that use that formatter are supported.Any other pull request into a stable line fails it, and a maintainer reviews and merges it. A pull request that changes
.github/runs its own version of these checks, so they vouch for nothing on it: a maintainer reviews it either way.Release smoke test: after Publish to npm succeeds,
release.ymlinstalls the published version from npm on Linux, Windows and macOS and runs the same checks.Both workflows are inert on
main(they only trigger for pull requests intostable/**). They land here first so new stable lines inherit them, then onstable/5.1.How to manually test your changes?
npm install -g @shopify/cli@5.1.0 --prefix /tmp/shopify-cli-smoke, put/tmp/shopify-cli-smoke/binfirst onPATH, thenbash .github/scripts/smoke-test-cli.sh 5.1.0.stable/5.1's head, a0c9f53 applied whole passes. Only its changeset fails, and so does a9f1d13 without itsminorchangeset, or with only one of the fixes it batches. Hand backports such as [5.0] Backport: fetch the app client secret only in commands that use it #9145 and Fix Cloudflare tunnel shutdown errors on Windows (5.0) #9066 fail. a23c474 replayed ontostable/4.9, which released that fix in 4.9.4, fails, and so does a0c9f53 onto a line that already has its code under another changeset. Support JSON flags for the theme language server #9006's first commit, replayed onto a line cut at its base, fails: its changeset became aminorbefore the pull request merged. So do backports whose changesetmainlater removed, made aminor(before or after a release consumed it), or removed and added again, and backports of a fixmainlater reverted, while Update from World (5.0.0) #9164 ontostable/5.0, whose changeset the 5.1.0 catch-up consumed, passes.changeset versionpasses. Versions of it with an entry dropped, a line added, a dependency version changed, an entry in the wrong package,@shopify/plugin-cloudflare's@shopify/cli-kitpin or its lockfile specifier left at 5.1.0, orversion.tsor both oclif manifests left at 5.1.0, fail, and so do a 5.1.1 bump that consumes aminorchangeset and the same 5.1.1 bump proposed into astable/5.2. Version Packages - stable/5.1 #9186 (5.1.0, a minor) fails, and Version Packages - stable/5.0 #9064 and Version Packages - stable/5.0 #9158 fail becausestable/5.0uses another changelog formatter.4.9.2against4.9.1warns about one fewer chunk, and5.1.0against5.0.2fails.stable/5.1runs Patch QA on its own head. Patch provenance fails there, as it should for a change that isn't a backport ofmain.🤖 Generated with Claude Code