Skip to content

Fail the codegen check only on drift the pull request caused - #9216

Open
craigmichaelmartin wants to merge 1 commit into
mainfrom
codegen-check-pr-caused-drift
Open

craigmichaelmartin wants to merge 1 commit into
mainfrom
codegen-check-pr-caused-drift

Conversation

@craigmichaelmartin

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Check graphql-codegen has been run regenerates the GraphQL types from the latest schemas and fails on any difference. The schemas change on their own, so the check can fail on a pull request that doesn't touch GraphQL. Of the 38 times this job failed since 2026-11-16, 37 were schema changes that the pull request didn't make.

The upstream repository is about to stop failing its own pull requests on such differences. After that, a mirror pull request can bring a change while the generated files are behind a schema change made elsewhere. With the current step, that would block the mirror until the files are regenerated.

WHAT is this pull request doing?

It changes the last step of the Check graphql-codegen has been run job, and nothing else:

  • When nothing differs, it passes, as before.
  • On a mirror pull request (the world-mirror/main branch of this repository), it lists the differing files in a warning and passes. The upstream repository's CI has already checked those changes, so any difference comes from a schema change made since.
  • Otherwise it lists the files of the pull request, or of the merge group since its base, and runs bin/graphql-codegen/check-drift.js. That script fails when the change edits the operations or generated files of an API whose files differ, or something codegen reads for every API, such as graphql.config.ts, package.json or the lockfile. It also fails when it can't tell which files changed. The other differences pass with a warning.

bin/graphql-codegen/check-drift.js arrives with a later mirror update. Until then, a pull request that isn't a mirror pull request and has a difference fails as it does now, with a missing-module error instead of the hint. Release branches keep their own copy of this workflow, so only branches cut after this change get it.

How to manually test your changes?

Once bin/graphql-codegen/check-drift.js is on main:

  1. pnpm graphql-codegen:get-graphql-schemas && pnpm graphql-codegen
  2. Change a description in packages/app/src/cli/api/graphql/app-logs/app_logs_schema.graphql that packages/app/src/cli/api/graphql/app-logs/generated/types.d.ts repeats, such as the one on LogFilterField, and run pnpm graphql-codegen again.
  3. printf 'packages/theme/src/index.ts\n' > /tmp/changed-files && node bin/graphql-codegen/check-drift.js --changed-files /tmp/changed-files warns and exits 0.
  4. printf 'packages/app/src/cli/api/graphql/app-logs/queries/historical-logs.graphql\n' > /tmp/changed-files && node bin/graphql-codegen/check-drift.js --changed-files /tmp/changed-files exits 1.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

🤖 Generated with Claude Code

The check regenerates the GraphQL types from the latest schemas, which
change on their own, so the generated files can differ on a pull request
that doesn't touch GraphQL. The job's last step now fails only on
differences the pull request or merge group could have caused, using
bin/graphql-codegen/check-drift.js. A mirror pull request, whose changes
the upstream repository's CI has already checked, only gets a warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- name: Run git diff
run: git diff
- name: Fail if any changes were made
run: 'test -z "$(git status --porcelain)" || { echo -e "Run pnpm graphql-codegen when queries are changed, committing any fixes and generated files" ; exit 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 think we don't need to check this on Github anymore, this should only happen in World.

Once code reaches CLI; it doesn't matter if the schemas change as it is 100% unrelated to the mirrored code (otherwise it couldn't have been merged in World)

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants