Skip to content

ci: verify generated error codes stay in sync with errors.config.ts#1214

Open
msluszniak wants to merge 1 commit into
mainfrom
@ms/ci-verify-error-codes-1209
Open

ci: verify generated error codes stay in sync with errors.config.ts#1214
msluszniak wants to merge 1 commit into
mainfrom
@ms/ci-verify-error-codes-1209

Conversation

@msluszniak
Copy link
Copy Markdown
Member

Description

scripts/generate-errors.ts (yarn codegen:errors) is the single source of truth for error codes, emitting src/errors/ErrorCodes.ts and common/rnexecutorch/ErrorCodes.h. Nothing in CI verified the committed generated files match errors.config.ts, so a contributor editing the config (or a generated file) without rerunning codegen could commit sources that silently disagree across the JSI boundary.

This adds a lint-job step that reruns codegen and diffs both generated files against what's committed, failing CI on drift. No native toolchain needed.

While wiring this up, the committed ErrorCodes.h is now stored verbatim as the generator emits it. The clang-format pre-commit hook previously rewrapped its comments, which would have made the raw diff fail in CI, so the generated header is excluded from that hook.

Introduces a breaking change?

  • Yes
  • No

Type of change

  • Other (chores, tests, code style improvements etc.)

Tested on

  • iOS
  • Android

Testing instructions

  1. Edit scripts/errors.config.ts (e.g. rename a code) without running codegen.
  2. The new "Verify error codes are up to date" CI step fails with a stale-codes error.
  3. Run yarn codegen:errors, commit the result — the step passes.

Related issues

Closes #1209

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Add a lint-job step that reruns `yarn codegen:errors` and diffs the two
generated files (ErrorCodes.ts / ErrorCodes.h) against the committed
versions, failing CI when they drift. The numeric codes cross the JSI
boundary, so drift can silently resolve a C++ code to the wrong TS enum
member.

ErrorCodes.h is committed verbatim as the generator emits it. The
clang-format pre-commit hook previously rewrapped its comments, which
would have made the raw diff fail in CI, so the generated header is now
excluded from that hook.

Closes #1209
@msluszniak msluszniak self-assigned this Jun 1, 2026
@msluszniak msluszniak added the chore PRs that are chores label Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore PRs that are chores

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] Verify generated error codes stay in sync with errors.config.ts

1 participant