Skip to content

Commit 6d7bb7a

Browse files
Merge master and align watcher recovery tests with both CLIs
Retain the overlapping-source regression, renumber the recovery scripts, and update parity checks for Rust recovery and dependency error exits. Preserve and document the existing OCaml differences. Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
2 parents fef2886 + 58f1bd2 commit 6d7bb7a

863 files changed

Lines changed: 43881 additions & 31884 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/skills/records/SKILL.md‎

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
name: records
3+
description: Commit records and review pages for the ReScript compiler repository. Use when committing a change, when an agent reports its work, and when someone asks to review a commit, a pull request or a branch. Every commit message is a structured record that answers the questions ReScript reviewers ask; review pages are rendered from records with scripts/commitRecords.js, never written by hand.
4+
---
5+
6+
# Commit records and review pages
7+
8+
A **record** is a commit message whose body has named prose sections and
9+
whose last block is git trailers. Its fields are the questions reviewers of
10+
this repository ask on pull requests, answered before they are asked. A
11+
review page is rendered from records: one card per commit, and for a range a
12+
summary, a changelog draft and the files more than one commit changes.
13+
14+
## The record
15+
16+
```
17+
<subject: present tense, what the compiler or tool now does>
18+
19+
<one paragraph: the change at the level of the language or the tool>
20+
21+
Example (rescript):
22+
<the ReScript source that shows the change, at most 15 lines>
23+
24+
Before (js):
25+
<generated JavaScript before, for that source>
26+
27+
After (js):
28+
<generated JavaScript after>
29+
30+
Source: <how the Before/After JavaScript was produced: compiler and revision,
31+
or the snapshot file in the diff>
32+
33+
Breaking: <what existing code or tooling stops working, and the migration>
34+
35+
Review: <a question a reviewer raised or will raise, and its answer; repeat>
36+
37+
Area: syntax printer frontend typechecker lambda codegen runtime rewatch
38+
analysis reanalyze gentype tools playground scripts ci docs tests
39+
Output: unchanged | changed <which programs>, <evidence>
40+
Formatting: unchanged | changed <which source shapes>
41+
Formats: none | <bumped magic numbers: ast cmi cmt cmj>
42+
PPX: unchanged | <effect on the frozen v0 PPX wire>
43+
Editor: unchanged | <effect on completion, hover, hints; fixtures>
44+
Errors: <ERROR_VARIANTS.md rows added, removed or relinked>
45+
Tests: +added/path ~updated/path -removed/path | none, because <reason>
46+
Measured: <quantity before -> after, and what produced it>; ...
47+
PR: #<number>
48+
Signed-off-by: <Name> <email>
49+
```
50+
51+
- **Prose sections** are a line `Name:` or `Name (lang):` followed by text or
52+
a block indented by 4 spaces. `lang` is `rescript`, `js`, `ts`, `sh`,
53+
`rust`, `ocaml` or `text`; the renderer highlights ReScript and JavaScript.
54+
`Before` and `After` sections of one language render side by side with
55+
changed lines marked. Use `Before (rescript)` / `After (rescript)` for a
56+
formatter change and `Diagnostic (text)` for compiler output. Any other
57+
name is allowed and renders as prose or code.
58+
- **The final block is git trailers**: `Key: value` lines, continuation lines
59+
indented by one space, nothing after them. `git interpret-trailers --parse`
60+
must read every key. `Signed-off-by` (DCO) is required on every commit.
61+
- **No changelog in the record**: the `changes/<name>.<category>.md`
62+
fragment the commit adds is the single source of truth for its changelog
63+
category and entry (see `changes/README.md`). The record repeats neither;
64+
the review page reads the fragment from the diff.
65+
- **Required keys**: `Area`, `Output`, `Tests`. `Formatting`, `Formats`,
66+
`PPX` and `Editor` are required whenever the change touches the syntax
67+
library, the parsetree, the typed tree or Lambda. Omit the others when they
68+
do not apply.
69+
- **Wording** follows the writing rules: present facts, positive statements,
70+
claims as strong as their evidence, every number labelled by what produced
71+
it. A JavaScript `Before`/`After` pair says where it came from in a
72+
`Source:` paragraph (compiler run, or a snapshot file in the diff).
73+
- **Lists in trailers**: `Measured` separates items with `; `
74+
(outside parentheses); each item renders on its own line. `Output` and the
75+
other state trailers start with their state word (`unchanged`, `changed`,
76+
`none`), followed by the detail.
77+
78+
## What each field states
79+
80+
| Field | What the record states |
81+
| --- | --- |
82+
| `Area` | The layers the change touches. They decide who reviews it and which suites apply; a parsetree or typed-tree change also reaches editor analysis. |
83+
| `Output` + `Before`/`After (js)` | The generated JavaScript for the example before and after, and which existing programs compile differently. `unchanged` holds when no committed generated JS changes, or when a rebuild of the test suites is byte-identical. |
84+
| `Formatting` + `Before`/`After (rescript)` | Whether `rescript format` rewrites existing code, and whether formatted output parses back to the same tree with its comments. |
85+
| `Formats` | The magic numbers bumped in `compiler/ext/config.ml`. Any change to the marshaled parsetree, typed tree (`.cmi`, `.cmt`) or `.cmj` layout, constructor order included, bumps the matching number. |
86+
| `PPX` | The effect on the frozen v0 PPX wire: `parsetree0.ml` is unchanged, and a change to the v0 mapping comes with an ast-mapping fixture. |
87+
| `Editor` | Completion, hover and inlay hints on new or changed nodes, and the analysis fixtures that cover them. |
88+
| `Errors` | The `tests/ERROR_VARIANTS.md` rows added, removed or relinked for changed error variants or fixtures. |
89+
| `Tests` | The tests added, changed or removed, each observing the effect the record claims, so that it fails without the change. `none, because …` gives the reason when no test changes. |
90+
| `Measured` | Performance before and after, with the input and the command that produced each number. |
91+
| `Breaking` | What existing code or tooling stops working, and the migration. |
92+
| `Review` | Questions a reviewer raised or will raise, with their answers. |
93+
| `PR` | The pull request; the renderer links it. |
94+
| `Signed-off-by` | The DCO sign-off, with the commit author's name and email, as the last trailer. |
95+
96+
## Rendering
97+
98+
```sh
99+
node scripts/commitRecords.js --out review.html <rev>...
100+
node scripts/commitRecords.js --out review.html <base>..<branch>...
101+
node scripts/commitRecords.js --fragment --out part.html <rev>...
102+
node scripts/commitRecords.js --out review.html --pr 1234 --title "<PR title>" <base>..<branch>
103+
```
104+
105+
- `--pr` and `--title` head the page with the pull request's number (linked)
106+
and title; without them the page is headed "Semantic Diff".
107+
108+
- A revision renders one card. A range renders a summary row, a changelog
109+
draft grouped by category, its commits as cards, and the files more than
110+
one commit (or more than one range) changes. The changelog category, the
111+
entries and the draft come from the `changes/` fragments in the diff: a
112+
card shows the fragments its commit adds or changes, and a range's draft
113+
shows the fragments the range leaves, in their last version.
114+
- Each card checks the record against its diff: a `changes/` fragment that
115+
`yarn changelog:check` rejects (such as one still carrying the placeholder
116+
PR link), an edit to `CHANGELOG.md`, modified generated `.mjs`, `.cjs` and `.res.js` files under
117+
`Output: unchanged` (new ones from new tests are counted, not flagged), a
118+
magic number bumped in `compiler/ext/config.ml` that
119+
`Formats` does not name, a parsetree change with no ast-mapping fixture, a
120+
new `super_errors` fixture with no `ERROR_VARIANTS.md` change, a missing
121+
`Tests` trailer, `Tests: none` on a diff that changes tests. A failed
122+
check is shown on the card. The DCO app checks `Signed-off-by`.
123+
- The page is one self-contained HTML file: no script, no external data
124+
(fonts fall back to system faces), light and dark themes, phone width.
125+
`--fragment` omits the document skeleton for embedding.
126+
- A note on `refs/notes/records` replaces the commit message's record. Use it
127+
for commits that exist already (history, a squash merge) and for review
128+
outcomes added later; a new commit carries its record in its message.
129+
130+
## When to use
131+
132+
- Every commit an agent makes carries a record in its message.
133+
- An agent's report lists its commits and the rendered page; the records are
134+
the description of the work. A pull request description is a rendering of
135+
its range.
136+
- Before review or merge: render `master..<branch>` and hand over the page.
137+
- On GitHub, `.github/workflows/semantic_diff.yml` renders each pull
138+
request's range when it is opened or pushed, and comments the page's link
139+
(`Semantic diff: https://cdn.rescript-lang.org/semantic-diff/pr-<N>/…`).

‎.github/actions/setup-ocaml/action.yml‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ runs:
8282
run: |
8383
dependency_flags_key="${DEPENDENCY_FLAGS//--/}"
8484
dependency_flags_key="${dependency_flags_key// /_}"
85-
key="$CACHE_PREFIX-$OS-3.9.0-$COMPILER-$dependency_flags_key-${{ hashFiles('*.opam') }}"
85+
dependency_hash="${{ hashFiles('*.opam', '.github/opam-repository/repo', '.github/opam-repository/packages/**') }}"
86+
key="$CACHE_PREFIX-$OS-3.9.0-$COMPILER-$dependency_flags_key-$dependency_hash"
8687
echo "value=${key//,/-}" >> "$GITHUB_OUTPUT"
8788
echo "setup-version=3.9.0" >> "$GITHUB_OUTPUT"
8889
@@ -104,6 +105,11 @@ runs:
104105
uses: ocaml/setup-ocaml@v3.9.0
105106
with:
106107
ocaml-compiler: ${{ inputs.compiler }}
108+
# Use the HTTP repository to prevent intermittent CI setup failures:
109+
# the Git-backed default can race with detached Git maintenance while
110+
# OPAM scans it (https://github.com/ocaml/opam/issues/7031).
111+
opam-repositories: |
112+
default: https://opam.ocaml.org
107113
opam-pin: false
108114
cache: false
109115

@@ -125,12 +131,21 @@ runs:
125131
env:
126132
DEPENDENCY_FLAGS: ${{ inputs.dependency-flags }}
127133
run: |
134+
opam repository add rescript-overrides "$GITHUB_WORKSPACE/.github/opam-repository"
128135
read -ra dependency_flags <<< "$DEPENDENCY_FLAGS"
136+
if [[ "$RUNNER_OS" == "Windows" ]]; then
137+
export AR=x86_64-w64-mingw32-ar
138+
export RANLIB=x86_64-w64-mingw32-ranlib
139+
export STRIP=x86_64-w64-mingw32-strip
140+
export NM=x86_64-w64-mingw32-nm
141+
export DLLTOOL=x86_64-w64-mingw32-dlltool
142+
export OBJDUMP=x86_64-w64-mingw32-objdump
143+
fi
129144
opam install . "${dependency_flags[@]}"
130145
131146
- name: Cache OPAM environment
132147
# Caches created by pull_request runs are scoped to that PR's merge ref
133-
# and cannot seed other PRs or branches. Only pushes create shared caches.
148+
# and cannot seed other PRs or branches, so only push runs save them.
134149
if: steps.cache.outputs.cache-hit != 'true' && github.event_name == 'push'
135150
uses: actions/cache/save@v6
136151
with:

‎.github/opam-repository/README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ReScript opam overrides
2+
3+
This repository contains narrowly scoped dependency fixes needed by CI before
4+
they are available from the main opam repository.
5+
6+
The Luv 0.5.14 override preserves the ARM64 musl compiler's
7+
`-mno-outline-atomics` requirement while building vendored libuv. Without it,
8+
the static executable fails to link because libuv refers to glibc's internal
9+
`__getauxval` symbol. The patch should be contributed upstream and this
10+
override removed once a fixed Luv release is available.
11+
12+
Luv 0.5.14 also vendors libuv 1.48.0. Evaluating and contributing an update to
13+
a current libuv 1.x release is a separate upstream follow-up; changing the
14+
vendored library is intentionally outside the OCaml rewatch port.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--- a/src/c/dune
2+
+++ b/src/c/dune
3+
@@ -82,8 +82,14 @@
4+
(action (progn
5+
(bash "cp -r vendor/configure/* vendor/libuv/")
6+
(chdir vendor/libuv (progn
7+
(bash
8+
- "sh configure --host `ocamlc -config | awk '/^host:/ {print $NF}'` \
9+
- 'CC=%{cc}' CFLAGS=-DNDEBUG --silent --enable-silent-rules")
10+
+ "architecture=`ocamlc -config-var architecture`
11+
+ c_compiler=`ocamlc -config-var c_compiler`
12+
+ extra_cflags=
13+
+ case \"$architecture:$c_compiler\" in
14+
+ arm64:*musl*) extra_cflags=-mno-outline-atomics ;;
15+
+ esac
16+
+ sh configure --host `ocamlc -config | awk '/^host:/ {print $NF}'` \
17+
+ 'CC=%{cc}' CFLAGS=\"-DNDEBUG $extra_cflags\" --silent --enable-silent-rules")
18+
(ignore-outputs (bash
19+
"$([ '%{os_type}' = Unix ] && echo %{make} || echo make) V=0 -j 4 \
20+
-o aclocal.m4 -o Makefile.in -o configure \
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
opam-version: "2.0"
2+
name: "luv"
3+
version: "0.5.14"
4+
synopsis: "Binding to libuv: cross-platform asynchronous I/O"
5+
description: """\
6+
Luv is a binding to libuv, the cross-platform C library that does
7+
asynchronous I/O in Node.js and runs its main loop.
8+
9+
Besides asynchronous I/O, libuv also supports multiprocessing and
10+
multithreading. Multiple event loops can be run in different threads. libuv also
11+
exposes a lot of other functionality, amounting to a full OS API, and an
12+
alternative to the standard module Unix."""
13+
maintainer: "Anton Bachin <antonbachin@yahoo.com>"
14+
authors: "Anton Bachin <antonbachin@yahoo.com>"
15+
license: "MIT"
16+
homepage: "https://github.com/aantron/luv"
17+
doc: "https://aantron.github.io/luv"
18+
bug-reports: "https://github.com/aantron/luv/issues"
19+
depends: [
20+
"base-unix" {build}
21+
"ctypes" {>= "0.14.0"}
22+
"dune" {>= "2.7.0"}
23+
"ocaml" {>= "4.03.0"}
24+
"alcotest" {with-test & >= "0.8.1"}
25+
"base-unix" {with-test}
26+
"odoc" {with-doc & = "2.4.0"}
27+
]
28+
build: ["dune" "build" "-p" name "-j" jobs]
29+
patches: ["arm64-musl-outline-atomics.patch"]
30+
extra-files: [
31+
[
32+
"arm64-musl-outline-atomics.patch"
33+
"sha256=c15c4c4d34c9b545197c5160e19c69a128cc186b65a54e0e9a779c2543528a4f"
34+
]
35+
]
36+
dev-repo: "git+https://github.com/aantron/luv.git"
37+
url {
38+
src:
39+
"https://github.com/aantron/luv/releases/download/0.5.14/luv-0.5.14.tar.gz"
40+
checksum:
41+
"sha256=8e01b4a50c8876cdd98d8e245c0687c4dc4d883aed161ad9c5ace1fb1fdaae99"
42+
}

‎.github/opam-repository/repo‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
opam-version: "2.0"

‎.github/workflows/ci.yml‎

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
dune-profile: release
7575

7676
# Verify that the compiler still builds with the oldest OCaml version we support.
77+
# Steps comparing OCaml and Rust rewatch are skipped on this job; the
78+
# first linux-x64 job runs them.
7779
- os: ubuntu-24.04
7880
ocaml_compiler: ocaml-variants.5.0.0+options,ocaml-option-static
7981
node-target: linux-x64
@@ -190,6 +192,9 @@ jobs:
190192
- name: Version Check
191193
run: yarn constraints
192194

195+
- name: Type check JS
196+
run: yarn typecheck
197+
193198
- name: Test release plan
194199
run: yarn test-release-plan
195200

@@ -215,8 +220,64 @@ jobs:
215220
run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
216221
shell: bash
217222

218-
- name: Run rewatch tests
219-
run: ./rewatch/tests/suite.sh rewatch/target/release/rescript
223+
- name: Run OCaml rewatch parity tests
224+
if: ${{ !contains(matrix.ocaml_compiler, '5.0.0') }}
225+
timeout-minutes: 20
226+
run: |
227+
bash rewatch-ocaml/tests/check_canonical_test_coverage.sh
228+
bash rewatch-ocaml/tests/check_config_acceptance.sh \
229+
packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe \
230+
packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
231+
bash rewatch-ocaml/tests/check_command_validation.sh \
232+
packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe \
233+
packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
234+
shell: bash
235+
236+
- name: Run OCaml rewatch interactive output tests
237+
# Terminal rendering depends on the host OS, not the CPU architecture.
238+
# Use the faster ARM runners for one Linux and one macOS check. Windows
239+
# does not provide a reliable native equivalent of the `script` PTY.
240+
if: matrix.node-target == 'linux-arm64' || matrix.node-target == 'darwin-arm64'
241+
timeout-minutes: 15
242+
run: |
243+
bash rewatch-ocaml/tests/check_interactive_output.sh \
244+
packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe \
245+
packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
246+
shell: bash
247+
248+
- name: Run OCaml rewatch verbose output tests
249+
if: ${{ !contains(matrix.ocaml_compiler, '5.0.0') }}
250+
timeout-minutes: 10
251+
run: |
252+
bash rewatch-ocaml/tests/check_verbose_output.sh \
253+
packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe \
254+
packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
255+
shell: bash
256+
257+
- name: Run OCaml rewatch unit tests
258+
timeout-minutes: 10
259+
run: |
260+
opam exec -- dune build tests/rewatch_ounit_tests/rewatch_ounit_tests_main.exe
261+
# Run the executable directly so a stuck test leaves live progress;
262+
# dune otherwise buffers the test output until the action exits.
263+
opam exec -- ./_build/default/tests/rewatch_ounit_tests/rewatch_ounit_tests_main.exe -runner sequential
264+
shell: bash
265+
266+
- name: Run OCaml rewatch focused integration tests
267+
timeout-minutes: 30
268+
run: |
269+
sh rewatch-ocaml/tests/run.sh packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
270+
shell: bash
271+
272+
- name: Run OCaml rewatch canonical tests
273+
run: ./rewatch/tests/suite.sh packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
274+
shell: bash
275+
276+
# The Rust implementation is kept for comparison. One platform runs its
277+
# shared suite; the parity steps exercise it on every platform.
278+
- name: Run Rust rewatch reference tests
279+
if: matrix.node-target == 'linux-arm64'
280+
run: ./rewatch/tests/suite.sh packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe
220281
shell: bash
221282

222283
- name: Run syntax benchmarks

0 commit comments

Comments
 (0)