ci: verify generated error codes stay in sync with errors.config.ts#1214
Open
msluszniak wants to merge 1 commit into
Open
ci: verify generated error codes stay in sync with errors.config.ts#1214msluszniak wants to merge 1 commit into
msluszniak wants to merge 1 commit into
Conversation
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
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.
Description
scripts/generate-errors.ts(yarn codegen:errors) is the single source of truth for error codes, emittingsrc/errors/ErrorCodes.tsandcommon/rnexecutorch/ErrorCodes.h. Nothing in CI verified the committed generated files matcherrors.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.his now stored verbatim as the generator emits it. Theclang-formatpre-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?
Type of change
Tested on
Testing instructions
scripts/errors.config.ts(e.g. rename a code) without running codegen.yarn codegen:errors, commit the result — the step passes.Related issues
Closes #1209
Checklist