Single-source codegen freshness checks via pnpm codegen scripts#7732
Open
dmerand wants to merge 3 commits into
Open
Single-source codegen freshness checks via pnpm codegen scripts#7732dmerand wants to merge 3 commits into
dmerand wants to merge 3 commits into
Conversation
Contributor
Author
This was referenced Jun 5, 2026
09cebb5 to
5d90b53
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes “codegen freshness” (regenerate + verify working tree is clean) into pnpm scripts so local developer workflows and CI enforce the same steps without duplicating logic in GitHub Actions.
Changes:
- Adds
pnpm codegenplus two CI-aligned check scripts:pnpm codegen:check:graphqlandpnpm codegen:check:oclif. - Introduces
bin/check-codegen-clean.jsas the single source of truth for per-check pathspecs and failure messaging. - Updates
tests-pr.ymlto call the newpnpm codegen:check:*scripts instead of inlining regenerate-and-verify shell steps.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| package.json | Adds codegen and codegen:check:* scripts to standardize regeneration and cleanliness checks. |
| bin/check-codegen-clean.js | New helper script to assert codegen-owned paths are clean and emit a consistent remediation message/diff. |
| .github/workflows/tests-pr.yml | Simplifies CI gate jobs by invoking the new pnpm codegen:check:* scripts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "clean": "nx run-many --target=clean --all --skip-nx-cache && nx reset", | ||
| "codegen": "pnpm graphql-codegen:get-graphql-schemas && pnpm graphql-codegen && pnpm refresh-manifests && pnpm refresh-code-documentation && pnpm build-dev-docs", | ||
| "codegen:check:graphql": "pnpm graphql-codegen:get-graphql-schemas && pnpm graphql-codegen && node ./bin/check-codegen-clean.js graphql", | ||
| "codegen:check:oclif": "pnpm refresh-manifests && node ./bin/check-codegen-clean.js oclif:manifests && pnpm refresh-readme && node ./bin/check-codegen-clean.js oclif:readme && pnpm refresh-code-documentation && node ./bin/check-codegen-clean.js oclif:code-docs && pnpm build-dev-docs && node ./bin/check-codegen-clean.js oclif:dev-docs", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

About this stack
This stack came out of reviewing recent contributor and agent sessions in
Shopify/cli, where the same avoidable friction kept recurring: failures found only after pushing, generated files regenerated by hand, local checks drifting from what CI actually enforces, and setup conventions relearned every time. The goal is to make the local dev loop mirror CI and keep the two single-sourced so they can't drift — then document it so people and agents stop rediscovering it.WHY are these changes introduced?
Two of our PR checks —
Check graphql-codegen has been runandCheck OCLIF manifests & readme & docs— spell out their regenerate-and-verify steps right insidetests-pr.yml. There's no local command that does the same thing, so the usual way you learn a generated file is stale is by watching CI go red. Then you re-runrefresh-manifests,graphql-codegen, andbuild-dev-docsone at a time and push again. In effect the "what to regenerate" list lives in two heads — the workflow's and yours — and they drift.WHAT is this pull request doing?
Making
package.jsonthe one place that defines codegen freshness, for people and CI alike:pnpm codegenregenerates everything.pnpm codegen:check:graphql/:oclifregenerate, then check the tree came back clean.bin/check-codegen-clean.jsowns each check's paths and the message you see when it fails (now pointing you atpnpm codegen). The two gate jobs simply call these scripts instead of repeating the steps inline.It's deliberately a no-op in behavior — same generators, same order, same messages — and the job names, runners, and the oclif build step are untouched, so required checks and the merge queue don't notice the difference. Dev tooling only, nothing user-facing.
How to test your changes?
pnpm codegenshould produce no diff (it's idempotent).pnpm codegen:check:oclif— it fails and points you atpnpm codegen; running that puts you back to clean.Notes
codegen:check: the whole-repogit statuschecks step on each other in a single working tree, which is why CI keeps them as separate, fresh-checkout jobs.pnpm codegenisn't quite idempotent onmaintoday — it drops some orphanedconfig:autoupgradedocs that the OCLIF gate doesn't watch (it only checksgenerated/*.json). That's pre-existing and worth a separate fix.Post-release steps
None.