Skip to content

Check stable-line pull requests with Patch QA and Patch provenance - #9196

Open
craigmichaelmartin wants to merge 13 commits into
mainfrom
patch-qa-and-provenance
Open

craigmichaelmartin wants to merge 13 commits into
mainfrom
patch-qa-and-provenance

Conversation

@craigmichaelmartin

@craigmichaelmartin craigmichaelmartin commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Patch releases ship from stable/X.Y as 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:

  • that the line only takes changes main already has, plus its own version bumps;
  • that the tarball a release would publish installs and runs on the platforms users have, and ships the same files as the line's last release.

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 into stable/**, including ones retargeted there:

    • builds the @shopify/cli tarball 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 from main still builds lines that don't have it, such as stable/4.9;
    • installs it with npm install -g on ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm and macos-latest;
    • runs the checks that need no Shopify account (.github/scripts/smoke-test-cli.sh): version, help, the app, theme and Hydrogen topics, the JSON output schemas of hydrogen check and app info (which load those commands' code, as help doesn't), and theme init (from a pinned Skeleton release), theme check and theme package;
    • compares the tarball's files with the line's last release on npm, in a job of its own. Different files fail. A different number of hashed bundle chunks only warns, since a real patch can split the bundle differently.
  • Patch provenance (patch-provenance.yml), on pull_request for stable/**. 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:

    • a backport that builds on the line's head, adds only patch changesets for the fixed version group, changes no path outside main's mirrored files, and whose tree is exactly what landed on main when 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 from main, main must still have each changeset as a patch (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 changeset main added 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;
    • the line's Version Packages pull request, when it's one commit on the line's head that moves every package in the fixed group up one patch version within the line's own X.Y, consumes the line's pending changesets, all of them patch, sets version.ts and 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.cjs writes 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.yml installs 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 into stable/**). They land here first so new stable lines inherit them, then on stable/5.1.

How to manually test your changes?

  • Run the smoke checks against a published CLI: npm install -g @shopify/cli@5.1.0 --prefix /tmp/shopify-cli-smoke, put /tmp/shopify-cli-smoke/bin first on PATH, then bash .github/scripts/smoke-test-cli.sh 5.1.0.
  • The provenance rules were run locally against past and constructed pull requests:
  • The file comparison: 4.9.2 against 4.9.1 warns about one fewer chunk, and 5.1.0 against 5.0.2 fails.
  • The backport of this pull request to stable/5.1 runs Patch QA on its own head. Patch provenance fails there, as it should for a change that isn't a backport of main.

🤖 Generated with Claude Code

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>
@craigmichaelmartin
craigmichaelmartin requested a review from a team as a code owner November 25, 2026 13:29
@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Nov 25, 2026
craigmichaelmartin and others added 2 commits November 25, 2026 08:31
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>
Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-qa.yml Resolved
Comment thread .github/scripts/smoke-test-cli.sh Resolved
Comment thread .github/workflows/patch-qa.yml Resolved
Comment thread .github/scripts/smoke-test-cli.sh Resolved
Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-qa.yml Resolved
Comment thread .github/workflows/release.yml Resolved
craigmichaelmartin and others added 4 commits November 30, 2026 08:49
- 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 gonzaloriestra 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.

Thanks for fixing the previous suggestions! But my agent found a few more 😅

Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-provenance.yml Resolved
craigmichaelmartin and others added 3 commits December 2, 2026 07:43
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 gonzaloriestra 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.

Thanks! A few more comments 🫣

Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/workflows/patch-provenance.yml Resolved
Comment thread .github/scripts/smoke-test-cli.sh Resolved
craigmichaelmartin and others added 2 commits December 3, 2026 11:33
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>
Comment thread .github/workflows/patch-provenance.yml Outdated
for (const {path} of changesets) {
const text = fileAt(mainHead, path)
if (text === undefined) {
checkConsumedByRelease(path, origin, mainHead)

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.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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`)) {

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.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants