Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,6 @@ jobs:
if: runner.os != 'Windows'
run: make -C tests/gentype_tests/typescript-react-example clean test

# On Windows, after running setup-ocaml (if it wasn't cached yet or the cache couldn't be restored),
# Cygwin bash is used instead of Git Bash for Windows, breaking the rewatch tests.
# So we need to adjust the path to bring back Git Bash for Windows.
- name: Rewatch tests need Git Bash for Windows
if: ${{ runner.os == 'Windows' }}
run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
shell: bash

- name: Run rewatch tests
run: ./rewatch/tests/suite.sh rewatch/target/release/rescript
shell: bash

- name: Run syntax benchmarks
if: matrix.benchmarks
run: |
Expand Down Expand Up @@ -645,15 +633,18 @@ jobs:
# Run integration tests with the oldest supported node version.
node-version: 20

- name: Install ReScript package in rewatch/testrepo
- name: Install npm packages
run: yarn install

- name: Install ReScript package in test fixture
run: |
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
yarn add "rescript@https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA::7}"
shell: bash
working-directory: rewatch/testrepo
working-directory: tests/rewatch_tests/fixture

- name: Run rewatch integration tests
run: ./rewatch/tests/suite.sh rewatch/testrepo/node_modules/.bin/rescript
run: node scripts/test.js -rewatch
shell: bash

publish:
Expand Down
38 changes: 21 additions & 17 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,21 +387,7 @@ make test-rewatch # Run integration tests

**Note**: The rewatch project is located in the `rewatch/` directory with its own `Cargo.toml` file. All cargo commands should be run from the project root using the `--manifest-path rewatch/Cargo.toml` flag, as shown in the CI workflow.

**Integration Tests**: The `make test-rewatch` command runs bash-based integration tests located in `rewatch/tests/suite.sh`. These tests use the `rewatch/testrepo/` directory as a test workspace with various package configurations to verify rewatch's behavior across different scenarios.

**Running Individual Integration Tests**: You can run individual test scripts directly by setting up the environment manually:

```bash
cd rewatch/tests
export REWATCH_EXECUTABLE="$(realpath ../target/debug/rescript)"
eval $(node ./get_bin_paths.js)
export RESCRIPT_BSC_EXE
export RESCRIPT_RUNTIME
source ./utils.sh
bash ./watch/06-watch-missing-source-folder.sh
```

This is useful for iterating on a specific test without running the full suite.
**Integration Tests**: The `make test-rewatch` command runs Vitest-based integration tests located in `tests/rewatch_tests/`. These tests use a sandbox copy of `tests/rewatch_tests/fixture/` to verify rewatch's behavior across different scenarios (build, watch, clean, format, etc.).

#### Debugging

Expand All @@ -410,6 +396,26 @@ This is useful for iterating on a specific test without running the full suite.
- **Dependencies**: Inspect module dependency graph in `deps.rs`
- **File Watching**: Monitor file change events in `watcher.rs`

#### OpenTelemetry Tracing

Rewatch supports OpenTelemetry (OTEL) tracing for build and watch commands. To visualize traces locally, run a Jaeger all-in-one container:

```bash
docker run -d --name jaeger \
-p 4317:4317 -p 4318:4318 -p 16686:16686 \
jaegertracing/all-in-one
```

Then run rewatch with the OTLP endpoint set:

```bash
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 cargo run --manifest-path rewatch/Cargo.toml -- build
```

Open http://localhost:16686 to view traces in the Jaeger UI.

Note: Use `tracing::debug!` (not `log::debug!`) for events you want to appear in OTEL traces — they use separate logging systems.

#### Running Rewatch Directly

When running the rewatch binary directly (via `cargo run` or the compiled binary) during development, you need to set environment variables to point to the local compiler and runtime. Otherwise, rewatch will try to use the installed versions:
Expand Down Expand Up @@ -493,5 +499,3 @@ When clippy suggests refactoring that could impact performance, consider the tra
## CI Gotchas

- **`sleep` is fragile** — Prefer polling (e.g., `wait_for_file`) over fixed sleeps. CI runners are slower than local machines.
- **`exit_watcher` is async** — It only signals the watcher to stop (removes the lock file), it doesn't wait for the process to exit. Avoid triggering config-change events before exiting, as the watcher may start a concurrent rebuild.
- **`sed -i` differs across platforms** — macOS requires `sed -i '' ...`, Linux does not. Use the `replace` / `normalize_paths` helpers from `rewatch/tests/utils.sh` instead of raw `sed`.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
#### :nail_care: Polish

- Build system: Watch only source folders from build state instead of the entire project directory, and report missing configured source folders. https://github.com/rescript-lang/rescript/pull/8219
- Build system: Add OpenTelemetry tracing support for cli commands. https://github.com/rescript-lang/rescript/pull/8241

#### :house: Internal

- speed up dev container test by installing ocaml in docker image instead of in `postCreate.sh`. https://github.com/rescript-lang/rescript/pull/8230
- Migrate rewatch integration tests from bash scripts to Vitest and remove old test infrastructure. https://github.com/rescript-lang/rescript/pull/8241

# 13.0.0-alpha.1

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ test-gentype: lib
make -C tests/gentype_tests/stdlib-no-shims clean test

test-rewatch: lib
./rewatch/tests/suite.sh $(RESCRIPT_EXE)
node scripts/test.js -rewatch

test-all: test test-gentype test-analysis test-tools test-rewatch

Expand Down
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"!**/package.json",
"!**/packages/artifacts.json",
"!**/.mypy_cache",
"!**/.history"
"!**/.history",
"!**/noop-ppx"
]
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"tests/gentype_tests/**",
"tests/tools_tests",
"tests/commonjs_tests",
"tests/rewatch_tests",
"scripts/res"
],
"packageManager": "yarn@4.12.0",
Expand Down
Loading
Loading