Skip to content

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

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

craigmichaelmartin wants to merge 7 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;
    • 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, 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 the main commit that first added its changesets, applied to the line's head. That commit must be newer than the line's cut from main. 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, consumes the line's pending changesets, and changes nothing but versions, version.ts, oclif manifest versions, 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. 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.

  • 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>
if (merged.status !== 0 && merged.status !== 1) fail(`Couldn't apply main's ${origin} to ${BASE_REF}: ${merged.stderr.trim()}`)
const [mergedTree, ...conflicted] = merged.stdout.trim().split('\n')
const changedByOrigin = new Set(changedFiles(`${origin}^1`, origin).map(({path}) => path))
for (const {path} of changes) {

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.

This loop only visits files the PR changed. A backport that omits a source file can pass and ship an incomplete fix. Could we compare the PR tree with the expected merge-tree result and flag partial backports for manual review?

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 ran the script against candidates built on stable/5.1's head, and two more cases pass besides an omitted source file:

  • a pull request with only .changeset/mfa-required-error.md from a0c9f53, and none of the fix;
  • a9f1d13 with every file except .changeset/app-client-secret-variable.md. That commit adds one minor and one patch changeset, and the patch-only rule on line 339 reads only the changesets the pull request includes, so the SHOPIFY_CLI_APP_CLIENT_SECRET feature passes as a patch.

Comparing whole trees closes both. It also means a mirror commit that bundles a minor change with a fix, like a9f1d13, always goes to manual review.

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 for building those. Both cases reproduce, and so does the omitted file. Fixed in 989388d: a backport's tree must now be exactly main's commit applied to the line's head, so a changeset without its fix fails, and so does a9f1d13 without its minor changeset. As you say, a commit on main that batches a fix with other changes now goes to manual review. The bot gets the same rule in its own pull request: it holds such a fix and comments that it waits for the next minor.

Comment thread .github/workflows/patch-provenance.yml Outdated
# It runs on pull_request_target, so this file comes from the stable line, not from the pull request,
# and it never checks out or runs the pull request's code: it only reads commits.
on:
pull_request_target:

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.

GitHub loads this workflow from main for every stable/** target. Starting December 2, public repos also need an explicit policy to allow this event. Could we configure that policy before rollout and update the comment above? Event reference · December 2 change

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.

You're right on both counts. In 1b13f65, Patch provenance moves to pull_request, so each stable line runs its own copy and the December 2 default doesn't affect it. It still only reads the pull request's commits and never checks out or runs its code, and the comment now says that. A pull request that edits this workflow runs its edited copy. The backports and Version Packages pull requests never touch .github/, and any other change to it gets a maintainer's review.

Comment thread .github/workflows/patch-provenance.yml Outdated
if (!gitSucceeds('merge-base', lineHead, HEAD_SHA)) fail(`${HEAD_SHA} doesn't share history with ${BASE_REF}.`)

if (HEAD_REF === `changeset-release/${BASE_REF}`) {
checkVersionPackages()

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.

Changesets opens and updates Version Packages PRs with GITHUB_TOKEN. GitHub documents its approval exception for pull_request, so we can’t rely on pull_request_target to run this check. Could the versioning job dispatch provenance and report the result on the generated head SHA? GitHub token rules

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.

Moving to pull_request (see the thread above) covers this. When Changesets updates the pull request with GITHUB_TOKEN, provenance now gets the same approval-required run as the other checks, and closing and reopening the pull request starts them all. The bot already does that close and reopen, but it skipped it whenever another app, such as Graphite, had reported on the commit. Its own pull request now counts only GitHub Actions runs there.

Comment thread .github/workflows/patch-provenance.yml Outdated
if (!title || !next.startsWith(title) || !next.endsWith(rest) || !added.startsWith(`## ${version}\n`)) {
fail(`${path} must only gain a "## ${version}" section at the top.`)
}
const headings = new Set(['', '### Patch Changes', '- Updated dependencies'])

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.

Replaying #9064 fails here on - Updated dependencies [3895769], which the stable/5.0 formatter generated. The loop also accepts missing release notes because it only checks lines that are present. Could we compare each package’s section with the entries its stable-line formatter generates?

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.

Fixed in c8fe61c. checkChangelog now rebuilds each package's new section with the line's own .changeset/changelog.cjs, read from the line's head and never from the pull request, and requires an exact match. Only the order of entries is free, since Changesets orders them as it reads them from disk. Missing entries, extra lines, wrong dependency versions, entries in the wrong package and missing bare sections all fail now. A line that still uses @changesets/cli/changelog, like stable/5.0, fails with a message saying the line isn't supported. The check is required only from stable/5.1. One known gap: of Prettier's rewrites, it reproduces only the blank line after headings. So a changeset that Prettier rewrites, for example one with a blank line in its summary, fails and needs a maintainer. That's 22 of the 1,611 changesets in main's history.

# head would publish: installs it on each supported platform, runs the checks that need no Shopify
# account, and compares its files with the line's last release. Nothing is published.
on:
pull_request:

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.

Retargeting a PR from main to stable/5.1 emits edited, so Patch QA misses it until another push or reopen. Could we handle edited when github.event.changes.base is present?

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.

Fixed in 3a795af. Patch QA now runs on edited too, and in full on every edit. A job skipped on title or body edits would report a skipped "Patch QA", which a required check counts as passing.

Comment thread .github/scripts/smoke-test-cli.sh Outdated
}

start_case "Turn off auto-upgrade"
shopify config autoupgrade off

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.

Could we remove this command? CI=1 already skips auto-upgrade. Running the documented smoke test locally otherwise leaves auto-upgrade disabled in the developer’s CLI config.

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.

Removed in 3a795af. versionToAutoUpgrade() returns early when CI is set, and the script sets CI=1.

Comment thread .github/workflows/patch-qa.yml Outdated

# A patch release should ship the same files as the release before it. Bundle chunk names carry
# a content hash, which changes with any code change, so they're compared by count only.
- name: Compare the files with the line's last release

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.

Replaying this comparison on the 15 patch releases from 4.6 to 5.0, 14 match and 4.9.1 → 4.9.2 fails: it has one fewer chunk-[hash].js and no other difference. A failure here also fails package, so install is skipped on every platform. Could this run in its own job that gate also needs, and treat a difference in chunk count alone as a warning?

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.

Done in 3a795af. The comparison now runs in its own job, which gate needs, so a difference no longer skips the installs. A difference only in hashed bundle chunks is a warning: 4.9.1 to 4.9.2 now warns about its one fewer chunk, and 5.0.2 to 5.1.0 still fails.

Comment thread .github/scripts/smoke-test-cli.sh Outdated
# Git-only path: the default Skeleton URL looks up its release through the GitHub API, whose
# unauthenticated rate limit is shared by every machine behind the same address.
start_case "shopify theme init"
shopify theme init qa-theme --clone-url https://github.com/Shopify/skeleton-theme --latest

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.

--latest follows skeleton-theme's newest tag, while a stable line keeps the theme-check it shipped with. A later theme release could then fail theme check on an older line for reasons unrelated to the patch. Could we pin a tag with --clone-url https://github.com/Shopify/skeleton-theme#<tag> and drop --latest? Reading theme init, that URL still skips the GitHub API lookup.

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.

Done in 3a795af. It's pinned to v1.0.0, Skeleton's only release so far, through the #tag URL without --latest. That still takes the Git-only path, and the smoke script passes with it against the published 5.1.0.

git('config', 'maintenance.auto', 'false')
git('config', 'gc.auto', '0')
git('remote', 'add', 'origin', `https://github.com/${repository}`)
const lineHead = git('ls-remote', 'origin', `refs/heads/${BASE_REF}`).split('\t')[0]

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.

A backport is checked against the line's head at the time of this run. If another pull request merges first, nothing runs this again, so the pass describes a base that has moved and the merged result was never checked. release.yml covers this for Version Packages with its tree check; backports have nothing equivalent. Could stable/* require branches to be up to date once this check is required?

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.

Yes. The ruleset we plan for stable/5.1 and later lines, which makes these checks required, also requires branches to be up to date before merging. The bot builds each backport on the line's current head and merges only while that is still the head.

Comment thread .github/workflows/patch-qa.yml Outdated
node-version: 24.22.1

# The same build the release runs, before it publishes.
- name: Bundle

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.

nit: the bundle, pack and upload steps are a copy of the ones in release-qa-package.yml. Could both use one composite action, so the two tarballs can't drift apart?

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.

Done in 3a795af. Both workflows now build through .github/actions/build-cli-tarball.

Comment thread .github/workflows/release.yml Outdated
needs: [check, publish]
if: ${{ !cancelled() && needs.publish.result == 'success' }}
runs-on: ${{ matrix.os }}
timeout-minutes: 40

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.

nit: the wait for npm below can take 30 minutes, which leaves 10 for the install and the smoke tests. Could the timeout be higher, or the wait shorter?

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.

Done in 3a795af. The smoke job now has 60 minutes.

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>

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