Skip to content

Commit f563538

Browse files
committed
Introduce OpenTelemetry in rewatch and setup new test infrastructure
Add optional OTLP tracing export to rewatch, controlled by the OTEL_EXPORTER_OTLP_ENDPOINT environment variable. When set, rewatch exports spans via HTTP OTLP; when unset, tracing is a no-op. Instrument key build system functions (initialize_build, incremental_build, compile, parse, clean, format, packages) with tracing spans and attributes such as module counts and package names. Restructure main.rs to support telemetry lifecycle (init/flush/shutdown) and fix show_progress to use >= LevelFilter::Info so -v/-vv don't suppress progress messages. Also print 'Finished compilation' in plain_output mode during watch full rebuilds. Introduce a new Vitest-based test infrastructure in tests/rewatch_tests/ that replaces the bash integration tests. Tests spawn rewatch with an OTLP endpoint pointing to an in-process HTTP receiver, collect spans, and snapshot the resulting span tree for deterministic assertions. Update CI, Makefile, and scripts/test.js to use the new test runner.
1 parent e55c5e4 commit f563538

49 files changed

Lines changed: 5599 additions & 109 deletions

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,6 @@ jobs:
324324
if: runner.os != 'Windows'
325325
run: make -C tests/gentype_tests/typescript-react-example clean test
326326

327-
# On Windows, after running setup-ocaml (if it wasn't cached yet or the cache couldn't be restored),
328-
# Cygwin bash is used instead of Git Bash for Windows, breaking the rewatch tests.
329-
# So we need to adjust the path to bring back Git Bash for Windows.
330-
- name: Rewatch tests need Git Bash for Windows
331-
if: ${{ runner.os == 'Windows' }}
332-
run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
333-
shell: bash
334-
335-
- name: Run rewatch tests
336-
run: ./rewatch/tests/suite.sh rewatch/target/release/rescript
337-
shell: bash
338-
339327
- name: Run syntax benchmarks
340328
if: matrix.benchmarks
341329
run: |
@@ -645,15 +633,18 @@ jobs:
645633
# Run integration tests with the oldest supported node version.
646634
node-version: 20
647635

648-
- name: Install ReScript package in rewatch/testrepo
636+
- name: Install npm packages
637+
run: yarn install
638+
639+
- name: Install ReScript package in test fixture
649640
run: |
650641
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
651642
yarn add "rescript@https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA::7}"
652643
shell: bash
653-
working-directory: rewatch/testrepo
644+
working-directory: tests/rewatch_tests/fixture
654645

655646
- name: Run rewatch integration tests
656-
run: ./rewatch/tests/suite.sh rewatch/testrepo/node_modules/.bin/rescript
647+
run: node scripts/test.js -rewatch
657648
shell: bash
658649

659650
publish:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ test-gentype: lib
174174
make -C tests/gentype_tests/stdlib-no-shims clean test
175175

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

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"tests/gentype_tests/**",
106106
"tests/tools_tests",
107107
"tests/commonjs_tests",
108+
"tests/rewatch_tests",
108109
"scripts/res"
109110
],
110111
"packageManager": "yarn@4.12.0",

0 commit comments

Comments
 (0)