Skip to content

Rewatch paths - windows support #7477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
21ee039
change config
jfrolich May 3, 2025
6387cde
still need -make-runtime
jfrolich May 3, 2025
6ae8350
add make lib-rewatch
jfrolich May 4, 2025
f891af5
update rewatch
jfrolich May 4, 2025
b0a5cd9
test rewatch in Makefile
jfrolich May 4, 2025
479a86c
test
jfrolich May 4, 2025
c974b28
add install state
jfrolich May 4, 2025
1b645c7
upstream new version of rewatch
jfrolich May 5, 2025
d52ac23
make it work!
jfrolich May 5, 2025
24cd5bf
make rewatch default for building the runtime
jfrolich May 5, 2025
d484249
run rewatch tests
jfrolich May 5, 2025
7d9c130
see error
jfrolich May 5, 2025
6e5c845
install packages as part of the ci test suite
jfrolich May 5, 2025
db00716
cat the changes
jfrolich May 5, 2025
e21e6b6
empty commit
jfrolich May 5, 2025
45132ac
immutable install
jfrolich May 5, 2025
f011285
remove install state
jfrolich May 5, 2025
41bfb43
install state ignore
jfrolich May 5, 2025
5ef4604
run on mac os due to subtle diffs
jfrolich May 5, 2025
403eefb
fix
jfrolich May 5, 2025
fd97afb
use ci version of rescript
jfrolich May 5, 2025
87a7ef2
fix diff
jfrolich May 5, 2025
bb1fe78
trigger
jfrolich May 5, 2025
195d972
fix
jfrolich May 5, 2025
331afd3
show rescript version
jfrolich May 5, 2025
0c7d727
update snapshots
jfrolich May 5, 2025
49b892f
end to end tests
jfrolich May 5, 2025
42b102f
fix
jfrolich May 5, 2025
5397b1b
fix
jfrolich May 5, 2025
8e378ed
fix
jfrolich May 5, 2025
c9ff3a9
propagate bsc path
jfrolich May 5, 2025
0da306b
fix
jfrolich May 5, 2025
61e1b96
empty commit
jfrolich May 5, 2025
c1ed1f5
don't run unit tests if we don't build a new rewatch binary
jfrolich May 5, 2025
bf60a11
other instance
jfrolich May 5, 2025
7393c10
empty commit
jfrolich May 5, 2025
92333e5
find correct bsc
jfrolich May 8, 2025
10073f0
if the lockfile is deleted, stop running the watcher
jfrolich May 8, 2025
b39e3da
fix lock tests
jfrolich May 8, 2025
74f6f2a
More informative test
jfrolich May 8, 2025
1e3950f
fix watch
jfrolich May 8, 2025
d849de7
make tests work correctly
jfrolich May 8, 2025
db3a126
fix
jfrolich May 8, 2025
87c9be5
upstream changes
jfrolich May 8, 2025
4f7e570
test
jfrolich May 14, 2025
bcc0144
fix
jfrolich May 14, 2025
aba648e
commit
jfrolich May 14, 2025
6af05af
fix js
jfrolich May 14, 2025
ddd7672
fix diff
jfrolich May 14, 2025
76af929
remove deps
jfrolich May 14, 2025
f7ef758
add core dep
jfrolich May 14, 2025
45ebda5
fix lockfile
jfrolich May 14, 2025
64f84ea
Build runtime with rewatch in CI
cknitt May 15, 2025
f1fc607
Fix CI, move rewatch build steps into main compiler build job
cknitt May 15, 2025
0e8c36f
Revert "Build runtime with rewatch in CI"
jfrolich May 16, 2025
b543fdc
paths wip - windows support
jfrolich May 16, 2025
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
122 changes: 59 additions & 63 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,10 @@ env:
OCAMLRUNPARAM: b

jobs:
build-rewatch:
strategy:
fail-fast: false
matrix:
include:
- os: macos-13 # x64
rust-target: x86_64-apple-darwin
node-target: darwin-x64
- os: macos-14 # ARM
rust-target: aarch64-apple-darwin
node-target: darwin-arm64
- os: ubuntu-24.04 # x64
rust-target: x86_64-unknown-linux-musl
node-target: linux-x64
- os: ubuntu-24.04-arm # ARM
rust-target: aarch64-unknown-linux-musl
node-target: linux-arm64
- os: windows-latest
rust-target: x86_64-pc-windows-gnu
node-target: win32-x64

runs-on: ${{matrix.os}}

test-rewatch-integration:
needs:
- pkg-pr-new
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: "1"

Expand All @@ -54,41 +35,16 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Restore build cache
id: build-cache
uses: actions/cache@v4
with:
path: rewatch/target
key: rewatch-build-v2-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}

- name: Install musl gcc
if: steps.build-cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
run: sudo apt-get install -y --no-install-recommends musl-tools

- name: Install rust toolchain
if: steps.build-cache.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.rust-target }}

- name: Build rewatch
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
cargo build --manifest-path rewatch/Cargo.toml --target ${{ matrix.rust-target }} --release

- name: Copy rewatch binary
- name: Install ReScript package
run: |
cp rewatch/target/${{ matrix.rust-target }}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch.exe
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

- name: "Upload artifact: rewatch binary"
uses: actions/upload-artifact@v4
with:
name: rewatch-${{ matrix.node-target }}
path: rewatch.exe
if-no-files-found: error
- name: Run rewatch integration tests
run: |
make test-rewatch-ci

build-compiler:
strategy:
Expand All @@ -100,33 +56,44 @@ jobs:
upload_binaries: true
upload_libs: true
node-target: linux-x64
rust-target: x86_64-unknown-linux-musl
- os: ubuntu-24.04-arm # ARM
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
upload_binaries: true
# Build the playground compiler and run the benchmarks on the fastest runner
build_playground: true
benchmarks: true
node-target: linux-arm64
rust-target: aarch64-unknown-linux-musl
- os: macos-13 # x64
ocaml_compiler: 5.3.0
upload_binaries: true
node-target: darwin-x64
rust-target: x86_64-apple-darwin
- os: macos-14 # ARM
ocaml_compiler: 5.3.0
upload_binaries: true
node-target: darwin-arm64
rust-target: aarch64-apple-darwin
- os: windows-latest
ocaml_compiler: 5.3.0
upload_binaries: true
node-target: win32-x64
rust-target: x86_64-pc-windows-gnu

# Verify that the compiler still builds with older OCaml versions
- os: ubuntu-24.04
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
node-target: linux-x64
rust-target: x86_64-unknown-linux-musl
- os: ubuntu-24.04
ocaml_compiler: ocaml-variants.5.0.0+options,ocaml-option-static
node-target: linux-x64
rust-target: x86_64-unknown-linux-musl
- os: ubuntu-24.04
ocaml_compiler: ocaml-variants.4.14.2+options,ocaml-option-static
node-target: linux-x64
rust-target: x86_64-unknown-linux-musl

runs-on: ${{matrix.os}}

Expand All @@ -135,6 +102,7 @@ jobs:
# we do track its version manually
OPAM_VERSION: 2.3.0
DUNE_PROFILE: release
RUST_BACKTRACE: "1"

steps:
- name: "Windows: Set git config"
Expand All @@ -153,6 +121,9 @@ jobs:
cache: yarn
node-version-file: .nvmrc

- name: Install npm packages
run: yarn install

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
uses: awalsh128/[email protected]
Expand All @@ -161,6 +132,36 @@ jobs:
packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync
version: v3

- name: Restore rewatch build cache
id: rewatch-build-cache
uses: actions/cache@v4
with:
path: rewatch/target
key: rewatch-build-v2-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}

- name: Install rust toolchain
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.rust-target }}

- name: Build rewatch
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
run: |
cargo build --manifest-path rewatch/Cargo.toml --target ${{ matrix.rust-target }} --release

- name: Run rewatch unit tests
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
run: |
cargo test --manifest-path rewatch/Cargo.toml

- name: Copy rewatch binary
run: |
cp rewatch/target/${{ matrix.rust-target }}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch
./scripts/copyExes.js --rewatch
shell: bash

# matrix.ocaml_compiler may contain commas
- name: Get OPAM cache key
shell: bash
Expand Down Expand Up @@ -305,9 +306,6 @@ jobs:
_build
key: ${{ steps.compiler-build-state-key.outputs.value }}

- name: Install npm packages
run: yarn install

- name: Copy compiler exes to platform bin dir
run: node scripts/copyExes.js --compiler

Expand Down Expand Up @@ -440,8 +438,7 @@ jobs:
path: lib/ocaml

pkg-pr-new:
needs:
- build-rewatch
needs:
- build-compiler
runs-on: ubuntu-24.04-arm
steps:
Expand All @@ -457,7 +454,7 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: "@(binaries-*|rewatch-*|lib-ocaml)"
pattern: "@(binaries-*|lib-ocaml)"

- name: Move artifacts into packages
run: .github/workflows/moveArtifacts.sh
Expand Down Expand Up @@ -523,7 +520,6 @@ jobs:

publish:
needs:
- build-rewatch
- build-compiler
- installationTest
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -542,7 +538,7 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: "@(binaries-*|rewatch-*|lib-ocaml)"
pattern: "@(binaries-*|lib-ocaml)"

- name: Move artifacts into packages
run: .github/workflows/moveArtifacts.sh
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/moveArtifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ check_statically_linked() {
mv lib-ocaml lib/ocaml

# @rescript/{target}
chmod +x binaries-*/*.exe rewatch-*/*.exe
mv -f binaries-darwin-x64/* rewatch-darwin-x64/* "packages/@rescript/darwin-x64/bin"
mv -f binaries-darwin-arm64/* rewatch-darwin-arm64/* "packages/@rescript/darwin-arm64/bin"
mv -f binaries-linux-x64/* rewatch-linux-x64/* "packages/@rescript/linux-x64/bin"
mv -f binaries-linux-arm64/* rewatch-linux-arm64/* "packages/@rescript/linux-arm64/bin"
mv -f binaries-win32-x64/* rewatch-win32-x64/* "packages/@rescript/win32-x64/bin"
chmod +x binaries-*/*.exe
mv -f binaries-darwin-x64/* "packages/@rescript/darwin-x64/bin"
mv -f binaries-darwin-arm64/* "packages/@rescript/darwin-arm64/bin"
mv -f binaries-linux-x64/* "packages/@rescript/linux-x64/bin"
mv -f binaries-linux-arm64/* "packages/@rescript/linux-arm64/bin"
mv -f binaries-win32-x64/* "packages/@rescript/win32-x64/bin"
check_statically_linked "packages/@rescript/linux-x64/bin"
check_statically_linked "packages/@rescript/linux-arm64/bin"

Expand Down
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ dce:
reanalyze.exe -dce-cmt _build/default/compiler

rewatch:
cargo build --manifest-path rewatch/Cargo.toml
cp rewatch/target/debug/rewatch rewatch
cargo build --manifest-path rewatch/Cargo.toml --release
cp rewatch/target/release/rewatch rewatch
./scripts/copyExes.js --rewatch

ninja/ninja:
Expand Down Expand Up @@ -46,15 +46,25 @@ test-syntax-roundtrip:
test-gentype:
make -C tests/gentype_tests/typescript-react-example clean test

test-all: test test-gentype test-analysis test-tools
test-rewatch:
bash ./rewatch/tests/suite-ci.sh

test-rewatch-ci:
bash ./rewatch/tests/suite-ci.sh node_modules/.bin/rewatch

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

reanalyze:
reanalyze.exe -set-exit-code -all-cmt _build/default/compiler _build/default/tests -exclude-paths compiler/outcome_printer,compiler/ml,compiler/frontend,compiler/ext,compiler/depends,compiler/core,compiler/common,compiler/cmij,compiler/bsb_helper,compiler/bsb

lib:
lib-bsb:
./scripts/buildRuntime.sh
./scripts/prebuilt.js

lib:
./scripts/buildRuntimeRewatch.sh
./scripts/prebuilt.js

artifacts: lib
./scripts/npmPack.js --updateArtifactList

Expand Down
6 changes: 4 additions & 2 deletions cli/rewatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
// @ts-check

import * as child_process from "node:child_process";
import { rewatch_exe } from "./common/bins.js";
import { rewatch_exe, bsc_exe } from "./common/bins.js";

const args = process.argv.slice(2);

child_process.spawnSync(rewatch_exe, args, { stdio: "inherit" });
child_process.spawnSync(rewatch_exe, [...args, "--bsc-path", bsc_exe], {
stdio: "inherit",
});
4 changes: 4 additions & 0 deletions rewatch/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[alias]
build-m1-release = "RUSTFLAGS=\"-C target-cpu=apple-m1\" cargo build --release"
build-docs = "cargo doc --no-deps --document-private-items --target-dir ./docs"

3 changes: 3 additions & 0 deletions rewatch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
.DS_Store
/docs
Loading
Loading