Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 17 additions & 2 deletions .github/actions/setup-ocaml/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ runs:
run: |
dependency_flags_key="${DEPENDENCY_FLAGS//--/}"
dependency_flags_key="${dependency_flags_key// /_}"
key="$CACHE_PREFIX-$OS-3.9.0-$COMPILER-$dependency_flags_key-${{ hashFiles('*.opam') }}"
dependency_hash="${{ hashFiles('*.opam', '.github/opam-repository/repo', '.github/opam-repository/packages/**') }}"
key="$CACHE_PREFIX-$OS-3.9.0-$COMPILER-$dependency_flags_key-$dependency_hash"
echo "value=${key//,/-}" >> "$GITHUB_OUTPUT"
echo "setup-version=3.9.0" >> "$GITHUB_OUTPUT"

Expand All @@ -104,6 +105,11 @@ runs:
uses: ocaml/setup-ocaml@v3.9.0
with:
ocaml-compiler: ${{ inputs.compiler }}
# Use the HTTP repository to prevent intermittent CI setup failures:
# the Git-backed default can race with detached Git maintenance while
# OPAM scans it (https://github.com/ocaml/opam/issues/7031).
opam-repositories: |
default: https://opam.ocaml.org
opam-pin: false
cache: false

Expand All @@ -125,12 +131,21 @@ runs:
env:
DEPENDENCY_FLAGS: ${{ inputs.dependency-flags }}
run: |
opam repository add rescript-overrides "$GITHUB_WORKSPACE/.github/opam-repository"
read -ra dependency_flags <<< "$DEPENDENCY_FLAGS"
if [[ "$RUNNER_OS" == "Windows" ]]; then
export AR=x86_64-w64-mingw32-ar
export RANLIB=x86_64-w64-mingw32-ranlib
export STRIP=x86_64-w64-mingw32-strip
export NM=x86_64-w64-mingw32-nm
export DLLTOOL=x86_64-w64-mingw32-dlltool
export OBJDUMP=x86_64-w64-mingw32-objdump
fi
opam install . "${dependency_flags[@]}"

- name: Cache OPAM environment
# Caches created by pull_request runs are scoped to that PR's merge ref
# and cannot seed other PRs or branches. Only pushes create shared caches.
# and cannot seed other PRs or branches, so only push runs save them.
if: steps.cache.outputs.cache-hit != 'true' && github.event_name == 'push'
uses: actions/cache/save@v6
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/opam-repository/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ReScript opam overrides

This repository contains narrowly scoped dependency fixes needed by CI before
they are available from the main opam repository.

The Luv 0.5.14 override preserves the ARM64 musl compiler's
`-mno-outline-atomics` requirement while building vendored libuv. Without it,
the static executable fails to link because libuv refers to glibc's internal
`__getauxval` symbol. The patch should be contributed upstream and this
override removed once a fixed Luv release is available.

Luv 0.5.14 also vendors libuv 1.48.0. Evaluating and contributing an update to
a current libuv 1.x release is a separate upstream follow-up; changing the
vendored library is intentionally outside the OCaml rewatch port.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/src/c/dune
+++ b/src/c/dune
@@ -82,8 +82,14 @@
(action (progn
(bash "cp -r vendor/configure/* vendor/libuv/")
(chdir vendor/libuv (progn
(bash
- "sh configure --host `ocamlc -config | awk '/^host:/ {print $NF}'` \
- 'CC=%{cc}' CFLAGS=-DNDEBUG --silent --enable-silent-rules")
+ "architecture=`ocamlc -config-var architecture`
+ c_compiler=`ocamlc -config-var c_compiler`
+ extra_cflags=
+ case \"$architecture:$c_compiler\" in
+ arm64:*musl*) extra_cflags=-mno-outline-atomics ;;
+ esac
+ sh configure --host `ocamlc -config | awk '/^host:/ {print $NF}'` \
+ 'CC=%{cc}' CFLAGS=\"-DNDEBUG $extra_cflags\" --silent --enable-silent-rules")
(ignore-outputs (bash
"$([ '%{os_type}' = Unix ] && echo %{make} || echo make) V=0 -j 4 \
-o aclocal.m4 -o Makefile.in -o configure \
42 changes: 42 additions & 0 deletions .github/opam-repository/packages/luv/luv.0.5.14/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
opam-version: "2.0"
name: "luv"
version: "0.5.14"
synopsis: "Binding to libuv: cross-platform asynchronous I/O"
description: """\
Luv is a binding to libuv, the cross-platform C library that does
asynchronous I/O in Node.js and runs its main loop.

Besides asynchronous I/O, libuv also supports multiprocessing and
multithreading. Multiple event loops can be run in different threads. libuv also
exposes a lot of other functionality, amounting to a full OS API, and an
alternative to the standard module Unix."""
maintainer: "Anton Bachin <antonbachin@yahoo.com>"
authors: "Anton Bachin <antonbachin@yahoo.com>"
license: "MIT"
homepage: "https://github.com/aantron/luv"
doc: "https://aantron.github.io/luv"
bug-reports: "https://github.com/aantron/luv/issues"
depends: [
"base-unix" {build}
"ctypes" {>= "0.14.0"}
"dune" {>= "2.7.0"}
"ocaml" {>= "4.03.0"}
"alcotest" {with-test & >= "0.8.1"}
"base-unix" {with-test}
"odoc" {with-doc & = "2.4.0"}
]
build: ["dune" "build" "-p" name "-j" jobs]
patches: ["arm64-musl-outline-atomics.patch"]
extra-files: [
[
"arm64-musl-outline-atomics.patch"
"sha256=c15c4c4d34c9b545197c5160e19c69a128cc186b65a54e0e9a779c2543528a4f"
]
]
dev-repo: "git+https://github.com/aantron/luv.git"
url {
src:
"https://github.com/aantron/luv/releases/download/0.5.14/luv-0.5.14.tar.gz"
checksum:
"sha256=8e01b4a50c8876cdd98d8e245c0687c4dc4d883aed161ad9c5ace1fb1fdaae99"
}
1 change: 1 addition & 0 deletions .github/opam-repository/repo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opam-version: "2.0"
63 changes: 60 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,61 @@ jobs:
run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
shell: bash

- name: Run rewatch tests
run: ./rewatch/tests/suite.sh rewatch/target/release/rescript
- name: Run OCaml rewatch parity tests
timeout-minutes: 20
run: |
bash rewatch-ocaml/tests/check_rust_test_coverage.sh --require-complete
bash rewatch-ocaml/tests/check_canonical_test_coverage.sh
bash rewatch-ocaml/tests/check_config_acceptance.sh \
packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe \
packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
bash rewatch-ocaml/tests/check_command_validation.sh \
packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe \
packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
shell: bash

- name: Run OCaml rewatch interactive output tests
# Terminal rendering depends on the host OS, not the CPU architecture.
# Use the faster ARM runners for one Linux and one macOS check. Windows
# does not provide a reliable native equivalent of the `script` PTY.
if: matrix.node-target == 'linux-arm64' || matrix.node-target == 'darwin-arm64'
timeout-minutes: 15
run: |
bash rewatch-ocaml/tests/check_interactive_output.sh \
packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe \
packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
shell: bash

- name: Run OCaml rewatch verbose output tests
timeout-minutes: 10
run: |
bash rewatch-ocaml/tests/check_verbose_output.sh \
packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe \
packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
shell: bash

- name: Run OCaml rewatch unit tests
timeout-minutes: 10
run: |
opam exec -- dune build tests/rewatch_ounit_tests/rewatch_ounit_tests_main.exe
# Run the executable directly so a stuck test leaves live progress;
# dune otherwise buffers the test output until the action exits.
opam exec -- ./_build/default/tests/rewatch_ounit_tests/rewatch_ounit_tests_main.exe -runner sequential
shell: bash

- name: Run OCaml rewatch focused integration tests
timeout-minutes: 30
run: |
sh rewatch-ocaml/tests/run.sh packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
shell: bash

- name: Run OCaml rewatch canonical tests
run: ./rewatch/tests/suite.sh packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe
shell: bash

- name: Run Rust rewatch reference tests on Windows
if: runner.os == 'Windows'
run: ./rewatch/tests/suite.sh packages/@rescript/${{ matrix.node-target }}/bin/rescript-rust.exe
shell: bash

- name: Run syntax benchmarks
Expand Down Expand Up @@ -623,6 +676,10 @@ jobs:
shell: bash
working-directory: rewatch/testrepo

- name: Run rewatch integration tests
- name: Run installed default OCaml rewatch integration tests
run: ./rewatch/tests/suite.sh rewatch/testrepo/node_modules/.bin/rescript
shell: bash

- name: Run installed Rust rewatch reference integration tests
run: ./rewatch/tests/suite.sh rewatch/testrepo/node_modules/.bin/rescript-rust
shell: bash
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ $(YARN_INSTALL_STAMP): $(YARN_INSTALL_SOURCES)

REWATCH_SOURCES = $(shell find rewatch/src -name '*.rs') rewatch/Cargo.toml rewatch/Cargo.lock rewatch/rust-toolchain.toml
RESCRIPT_EXE = $(BIN_DIR)/rescript.exe
RESCRIPT_RUST_EXE := $(BIN_DIR)/rescript-rust.exe
PACKAGED_RUST_EXE := $(RESCRIPT_RUST_EXE)
ifdef CI
REWATCH_PROFILE := release
REWATCH_CARGO_FLAGS := --release
Expand All @@ -88,22 +90,22 @@ else
endif
REWATCH_TARGET := rewatch/target/$(REWATCH_PROFILE)/rescript$(PLATFORM_EXE_EXT)

rewatch: $(RESCRIPT_EXE)
rewatch: $(PACKAGED_RUST_EXE)

$(RESCRIPT_EXE): $(REWATCH_TARGET)
$(PACKAGED_RUST_EXE): $(REWATCH_TARGET)
$(call COPY_EXE,$<,$@)

$(REWATCH_TARGET): $(REWATCH_SOURCES)
cargo build --manifest-path rewatch/Cargo.toml $(REWATCH_CARGO_FLAGS)

clean-rewatch:
cargo clean --manifest-path rewatch/Cargo.toml && rm -rf rewatch/target && rm -f $(RESCRIPT_EXE)
cargo clean --manifest-path rewatch/Cargo.toml && rm -rf rewatch/target && rm -f $(PACKAGED_RUST_EXE)

# Compiler

COMPILER_SOURCE_DIRS := compiler tests analysis tools
COMPILER_SOURCES = $(shell find $(COMPILER_SOURCE_DIRS) -type f \( -name '*.ml' -o -name '*.mli' -o -name '*.dune' -o -name dune -o -name dune-project \))
COMPILER_BIN_NAMES := bsc rescript-editor-analysis rescript-tools
COMPILER_SOURCE_DIRS := compiler tests analysis tools rewatch-ocaml
COMPILER_SOURCES = $(shell find $(COMPILER_SOURCE_DIRS) -type f \( -name '*.ml' -o -name '*.mli' -o -name '*.c' -o -name '*.h' -o -name '*.dune' -o -name dune -o -name dune-project \))
COMPILER_BIN_NAMES := bsc rescript-editor-analysis rescript-tools rescript
COMPILER_EXES := $(addsuffix .exe,$(addprefix $(BIN_DIR)/,$(COMPILER_BIN_NAMES)))

compiler: $(COMPILER_EXES)
Expand Down Expand Up @@ -279,9 +281,13 @@ COVERAGE_TEST_ENV := BISECT_FILE=$(COVERAGE_BISECT_PREFIX) BISECT_SILENT=YES
.PHONY: coverage-build
coverage-build: | $(YARN_INSTALL_STAMP)
dune build --instrument-with bisect_ppx
@$(foreach bin,$(COMPILER_BIN_NAMES), \
@$(foreach bin,$(filter-out rescript,$(COMPILER_BIN_NAMES)), \
cp $(DUNE_BIN_DIR)/$(bin)$(PLATFORM_EXE_EXT) $(BIN_DIR)/$(bin).exe && \
chmod 755 $(BIN_DIR)/$(bin).exe;)
ifneq ($(OS),Windows_NT)
cp _build/default/rewatch-ocaml/rescript_ocaml.exe $(RESCRIPT_EXE)
chmod 755 $(RESCRIPT_EXE)
endif

.PHONY: coverage-prepare
coverage-prepare: clean-coverage coverage-build
Expand Down
Loading
Loading