You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d91731f
Browse filesBrowse the repository at this point in the historyBrowse files
Bump the magic numbers at release time instead of in pull requests
Why:
Every pull request that changed a serialized type bumped the .cmi, .cmt
or .ast magic number, so parallel pull requests kept conflicting on the
same lines of config.ml. `yarn changelog:release` now bumps each counter
when compiler/ml, compiler/ext or compiler/flow_parser changed since the
previous release tag, and the changelog check rejects pull requests that
bump one. The .cmi and .cmt numbers switch to ResCmi/ResCmt prefixes:
with OCaml's Caml1999 prefix, they run into the numbers of OCaml
releases (OCaml 5.5 writes Caml1999I037), and OCaml tools would take our
files for theirs (#8947).
Diagnostic modified (.cmi from an earlier compiler):
Before (diagnostic):
A.cmi
is not a compiled interface for this version of OCaml.
It seems to be for an older version of OCaml.
After (diagnostic):
A.cmi
is not a compiled interface for this version of ReScript.
It seems to be for an older version of ReScript.
Review: Why not derive the magic numbers from a digest of the types? Tools that read .cmi files need a stable number per release that only changes when the format may have changed; a digest changes on every release and has no order.
Review: What about two dev builds that share a counter? Both build systems clean a package when the bsc hash changes, so only mixing files from different builds by hand reads a mismatched layout.
Breaking: Tools that check for Caml1999I/Caml1999T magic numbers have to look for ResCmi/ResCmt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QFCgV9acRwi6ohFaj9atR8
Signed-off-by: Christoph Knittel <ck@cca.io>
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -584,7 +584,7 @@ The repository's `npm-release` GitHub environment should have required reviewers
584
584
To build a new version and release it on NPM, follow these steps:
585
585
586
586
1. Verify that the version number is already set correctly for the release. (It should have been incremented after releasing the previous version.)
587
-
1. Run `yarn changelog:preview` to review pending notes, then`yarn changelog:release` to collect fragments into `CHANGELOG.md`, remove "(Unreleased)", and delete consumed fragments. Create a PR containing these changes, review the combined release notes, and apply the `changelog:release` label. Existing unreleased entries are preserved. If more fragments are merged before publishing, the `Publish` workflow refuses to run; repeat this step to add them to the same version. Don't run `yarn changelog:release` while a `Publish` run is in progress: it could add notes for changes that the run is not publishing.
587
+
1. Run `yarn changelog:preview` to review pending notes, then`yarn changelog:release` to collect fragments into `CHANGELOG.md`, remove "(Unreleased)", and delete consumed fragments. It also bumps the `.cmi`, `.cmt` and `.ast` magic numbers in`compiler/ext/config.ml` when their sources changed since the previous release tag, so fetch the tags first (`git fetch --tags`). Create a PR containing these changes, review the combined release notes, and apply the `changelog:release` label. Existing unreleased entries are preserved. If more fragments are merged before publishing, the `Publish` workflow refuses to run; repeat this step to add them to the same version. Don't run `yarn changelog:release` while a `Publish` run is in progress: it could add notes for changes that the run is not publishing.
588
588
1. Once that PR is merged and built successfully, run the `Publish` workflow from the GitHub Actions tab. Use the "Run workflow" branch dropdown to select the release branch (normally `master`, or the relevant maintenance branch) and indicate whether this is the current stable release. The version is read from that branch's `package.json`, and the npm tag is derived automatically:
589
589
- A current stable release is published as `latest`.
590
590
- A stable maintenance release for an older major is published as `latest-<major>`, for example `latest-12`.
Copy file name to clipboardExpand all lines: changes/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ A bullet needs no PR link: `yarn changelog:release` appends the link of the pull
23
23
24
24
`yarn changelog:preview` prints pending fragments grouped by category, newest PR first, without changing files. It does not include entries already in `CHANGELOG.md`.
25
25
26
-
During release preparation, run `yarn changelog:release`. It verifies that the first version heading matches `package.json` and is unreleased, validates every fragment before writing, adds fragments above the existing entries of each section, newest PR first, removes `(Unreleased)`, and deletes consumed files. Review and commit all changes in the release PR. Historical entries and existing unreleased notes are preserved. Releases with no fragments can still finalize existing notes. The publish workflow refuses to release while fragments remain in `changes/`. If fragments are merged after the release PR but before publishing, run `yarn changelog:release` again: as long as Publish has not created the version's `v<version>` tag, it adds them to the finalized version. Once the tag exists, it refuses, and the fragments wait for the next version after `yarn changelog:open`. With no fragments left, running it again fails. Don't run it while a Publish run is in progress, because the tag only appears once that run gets to tagging, and the notes could then describe changes the run is not publishing.
26
+
During release preparation, run `yarn changelog:release`. It verifies that the first version heading matches `package.json` and is unreleased, validates every fragment before writing, adds fragments above the existing entries of each section, newest PR first, removes `(Unreleased)`, and deletes consumed files. It also bumps the magic numbers in `compiler/ext/config.ml` whose sources changed since the previous release tag, unless they already differ from that tag, so running it again does not bump them twice. CI rejects pull requests without the `changelog:release` label that bump one. Review and commit all changes in the release PR. Historical entries and existing unreleased notes are preserved. Releases with no fragments can still finalize existing notes. The publish workflow refuses to release while fragments remain in `changes/`. If fragments are merged after the release PR but before publishing, run `yarn changelog:release` again: as long as Publish has not created the version's `v<version>` tag, it adds them to the finalized version. Once the tag exists, it refuses, and the fragments wait for the next version after `yarn changelog:open`. With no fragments left, running it again fails. Don't run it while a Publish run is in progress, because the tag only appears once that run gets to tagging, and the notes could then describe changes the run is not publishing.
27
27
28
28
After publishing, run `yarn changelog:open` once `package.json` has the next version. It adds an empty unreleased section with every category heading.
- Give `.cmi` and `.cmt` files ReScript magic numbers (`ResCmi…`, `ResCmt…`) instead of OCaml-style ones, and bump all magic numbers at release time instead of in pull requests.
Copy file name to clipboardExpand all lines: compiler/AGENTS.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,8 @@ commands below are relative to the repository root unless stated otherwise.
11
11
- Add a source fixture exercising the new syntax to `tests/syntax_tests/data/ast-mapping/`. Every file there is run through `res_parser -test-ast-conversion` (which round-trips the parsetree through the frozen v0 AST before printing) as part of `make test-syntax`; the printed output must match the snapshot in its `expected/` directory.
12
12
- For exact-identity invariants (locations, attributes) or the v0 wire shape itself, add cases to `tests/ounit_tests/ounit_ast_mapper0_tests.ml`, which tests `ast_mapper_to0`/`ast_mapper_from0` directly.
13
13
14
+
-**Don't bump magic numbers** - Changing a serialized type (parsetree, typed tree, `.cmi` signature) needs no edit of the magic numbers in `compiler/ext/config.ml`. `yarn changelog:release` bumps them when `compiler/ml`, `compiler/ext` or `compiler/flow_parser` changed since the previous release, and the changelog check rejects pull requests that bump them.
15
+
14
16
-**Missing test coverage** - Always add tests for syntax, lambda, and end-to-end behavior
15
17
16
18
-**Test early and often** - Add tests immediately after modifying each compiler layer to catch problems early, rather than waiting until all changes are complete
0 commit comments