Skip to content

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

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

craigmichaelmartin wants to merge 3 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/**:

    • builds the @shopify/cli tarball the way a release does;
    • 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, theme check and theme package;
    • fails if the tarball's files differ from the line's last release on npm. Bundle chunk names are compared without their content hashes.
  • Patch provenance (patch-provenance.yml), on pull_request_target for stable/**, so the workflow comes from the stable line and never runs the pull request's code. 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 in which every changed file is exactly what the main commit that first added its changesets does to that file when applied to the line's head. That commit must be newer than the line's cut from main;
    • 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 made of the consumed changesets' entries.

    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?

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

# 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

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

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?

# 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?

}

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.


# 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?

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

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?

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?

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?

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