Skip to content

Commit db917c6

Browse files
committed
Merge branch 'master' into group-jsx-modules
2 parents b76f466 + 352fa02 commit db917c6

File tree

936 files changed

+16241
-10382
lines changed

Some content is hidden

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

936 files changed

+16241
-10382
lines changed

.github/workflows/ci.yml

Lines changed: 92 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -20,76 +20,6 @@ env:
2020
OCAMLRUNPARAM: b
2121

2222
jobs:
23-
build-rewatch:
24-
strategy:
25-
fail-fast: false
26-
matrix:
27-
include:
28-
- os: macos-13 # x64
29-
rust-target: x86_64-apple-darwin
30-
node-target: darwin-x64
31-
- os: macos-14 # ARM
32-
rust-target: aarch64-apple-darwin
33-
node-target: darwin-arm64
34-
- os: ubuntu-24.04 # x64
35-
rust-target: x86_64-unknown-linux-musl
36-
node-target: linux-x64
37-
- os: ubuntu-24.04-arm # ARM
38-
rust-target: aarch64-unknown-linux-musl
39-
node-target: linux-arm64
40-
- os: windows-latest
41-
rust-target: x86_64-pc-windows-gnu
42-
node-target: win32-x64
43-
44-
runs-on: ${{matrix.os}}
45-
46-
env:
47-
RUST_BACKTRACE: "1"
48-
49-
steps:
50-
- name: Checkout
51-
uses: actions/checkout@v4
52-
53-
- name: Use Node.js
54-
uses: actions/setup-node@v4
55-
with:
56-
node-version-file: .nvmrc
57-
58-
- name: Restore build cache
59-
id: build-cache
60-
uses: actions/cache@v4
61-
with:
62-
path: rewatch/target
63-
key: rewatch-build-v2-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}
64-
65-
- name: Install musl gcc
66-
if: steps.build-cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
67-
run: sudo apt-get install -y --no-install-recommends musl-tools
68-
69-
- name: Install rust toolchain
70-
if: steps.build-cache.outputs.cache-hit != 'true'
71-
uses: dtolnay/rust-toolchain@master
72-
with:
73-
toolchain: stable
74-
targets: ${{ matrix.rust-target }}
75-
76-
- name: Build rewatch
77-
if: steps.build-cache.outputs.cache-hit != 'true'
78-
run: |
79-
cargo build --manifest-path rewatch/Cargo.toml --target ${{ matrix.rust-target }} --release
80-
81-
- name: Copy rewatch binary
82-
run: |
83-
cp rewatch/target/${{ matrix.rust-target }}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch.exe
84-
shell: bash
85-
86-
- name: "Upload artifact: rewatch binary"
87-
uses: actions/upload-artifact@v4
88-
with:
89-
name: rewatch-${{ matrix.node-target }}
90-
path: rewatch.exe
91-
if-no-files-found: error
92-
9323
build-compiler:
9424
strategy:
9525
fail-fast: false
@@ -100,33 +30,44 @@ jobs:
10030
upload_binaries: true
10131
upload_libs: true
10232
node-target: linux-x64
33+
rust-target: x86_64-unknown-linux-musl
10334
- os: ubuntu-24.04-arm # ARM
10435
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
10536
upload_binaries: true
10637
# Build the playground compiler and run the benchmarks on the fastest runner
10738
build_playground: true
10839
benchmarks: true
10940
node-target: linux-arm64
41+
rust-target: aarch64-unknown-linux-musl
11042
- os: macos-13 # x64
11143
ocaml_compiler: 5.3.0
11244
upload_binaries: true
11345
node-target: darwin-x64
46+
rust-target: x86_64-apple-darwin
11447
- os: macos-14 # ARM
11548
ocaml_compiler: 5.3.0
11649
upload_binaries: true
11750
node-target: darwin-arm64
51+
rust-target: aarch64-apple-darwin
11852
- os: windows-latest
11953
ocaml_compiler: 5.3.0
12054
upload_binaries: true
12155
node-target: win32-x64
56+
rust-target: x86_64-pc-windows-gnu
12257

12358
# Verify that the compiler still builds with older OCaml versions
12459
- os: ubuntu-24.04
12560
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
61+
node-target: linux-x64
62+
rust-target: x86_64-unknown-linux-musl
12663
- os: ubuntu-24.04
12764
ocaml_compiler: ocaml-variants.5.0.0+options,ocaml-option-static
65+
node-target: linux-x64
66+
rust-target: x86_64-unknown-linux-musl
12867
- os: ubuntu-24.04
12968
ocaml_compiler: ocaml-variants.4.14.2+options,ocaml-option-static
69+
node-target: linux-x64
70+
rust-target: x86_64-unknown-linux-musl
13071

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

@@ -135,6 +76,7 @@ jobs:
13576
# we do track its version manually
13677
OPAM_VERSION: 2.3.0
13778
DUNE_PROFILE: release
79+
RUST_BACKTRACE: "1"
13880

13981
steps:
14082
- name: "Windows: Set git config"
@@ -153,6 +95,9 @@ jobs:
15395
cache: yarn
15496
node-version-file: .nvmrc
15597

98+
- name: Install npm packages
99+
run: yarn install
100+
156101
- name: Install dependencies (Linux)
157102
if: runner.os == 'Linux'
158103
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
@@ -161,10 +106,40 @@ jobs:
161106
packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync
162107
version: v3
163108

109+
- name: Restore rewatch build cache
110+
id: rewatch-build-cache
111+
uses: actions/cache@v4
112+
with:
113+
path: rewatch/target
114+
key: rewatch-build-v2-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}
115+
116+
- name: Install rust toolchain
117+
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
118+
uses: dtolnay/rust-toolchain@master
119+
with:
120+
toolchain: stable
121+
targets: ${{ matrix.rust-target }}
122+
123+
- name: Build rewatch
124+
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
125+
run: |
126+
cargo build --manifest-path rewatch/Cargo.toml --target ${{ matrix.rust-target }} --release
127+
128+
- name: Run rewatch unit tests
129+
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
130+
run: |
131+
cargo test --manifest-path rewatch/Cargo.toml
132+
133+
- name: Copy rewatch binary
134+
run: |
135+
cp rewatch/target/${{ matrix.rust-target }}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch
136+
./scripts/copyExes.js --rewatch
137+
shell: bash
138+
164139
# matrix.ocaml_compiler may contain commas
165140
- name: Get OPAM cache key
166141
shell: bash
167-
run: echo "opam_cache_key=opam-env-v7-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" | sed 's/,/-/g' >> $GITHUB_ENV
142+
run: echo "opam_cache_key=opam-env-v8-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" | sed 's/,/-/g' >> $GITHUB_ENV
168143

169144
- name: Restore OPAM environment
170145
id: cache-opam-env
@@ -180,7 +155,7 @@ jobs:
180155
key: ${{ env.opam_cache_key }}
181156

182157
- name: Use OCaml ${{matrix.ocaml_compiler}}
183-
uses: ocaml/setup-ocaml@v3.2.5
158+
uses: ocaml/setup-ocaml@v3.3.2
184159
if: steps.cache-opam-env.outputs.cache-hit != 'true'
185160
with:
186161
ocaml-compiler: ${{matrix.ocaml_compiler}}
@@ -305,9 +280,6 @@ jobs:
305280
_build
306281
key: ${{ steps.compiler-build-state-key.outputs.value }}
307282

308-
- name: Install npm packages
309-
run: yarn install
310-
311283
- name: Copy compiler exes to platform bin dir
312284
run: node scripts/copyExes.js --compiler
313285

@@ -352,15 +324,21 @@ jobs:
352324
if: ${{ runner.os == 'Windows' }}
353325
run: opam exec -- make test-syntax
354326

355-
- name: Build runtime/stdlib
327+
- name: Build runtime/stdlib with rewatch
328+
if: ${{ runner.os != 'Windows' }}
329+
run: ./scripts/buildRuntimeRewatch.sh
330+
shell: bash
331+
332+
- name: Build runtime/stdlib with bsb (Windows)
333+
if: ${{ runner.os == 'Windows' }}
356334
run: ./scripts/buildRuntime.sh
357335
shell: bash
358336

359337
- name: Check for changes in lib folder
360338
run: git diff --exit-code lib/js lib/es6
361339

362340
- name: Version Check
363-
run: ./scripts/prebuilt.js
341+
run: yarn constraints
364342

365343
- name: Run tests
366344
run: node scripts/test.js -all
@@ -418,11 +396,23 @@ jobs:
418396
if: matrix.build_playground
419397
run: yarn workspace playground test
420398

399+
- name: Setup Rclone
400+
if: ${{ matrix.build_playground && startsWith(github.ref, 'refs/tags/v') }}
401+
uses: cometkim/rclone-actions/setup-rclone@main
402+
403+
- name: Configure Rclone remote
404+
if: ${{ matrix.build_playground && startsWith(github.ref, 'refs/tags/v') }}
405+
uses: cometkim/rclone-actions/configure-remote/s3-provider@main
406+
with:
407+
name: rescript
408+
provider: Cloudflare
409+
endpoint: https://${{ vars.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
410+
access-key-id: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
411+
secret-access-key: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
412+
acl: private
413+
421414
- name: Upload playground compiler to CDN
422415
if: ${{ matrix.build_playground && startsWith(github.ref, 'refs/tags/v') }}
423-
env:
424-
KEYCDN_USER: ${{ secrets.KEYCDN_USER }}
425-
KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }}
426416
run: yarn workspace playground upload-bundle
427417

428418
- name: "Upload artifacts: binaries"
@@ -440,8 +430,7 @@ jobs:
440430
path: lib/ocaml
441431

442432
pkg-pr-new:
443-
needs:
444-
- build-rewatch
433+
needs:
445434
- build-compiler
446435
runs-on: ubuntu-24.04-arm
447436
steps:
@@ -457,7 +446,7 @@ jobs:
457446
- name: Download artifacts
458447
uses: actions/download-artifact@v4
459448
with:
460-
pattern: "@(binaries-*|rewatch-*|lib-ocaml)"
449+
pattern: "@(binaries-*|lib-ocaml)"
461450

462451
- name: Move artifacts into packages
463452
run: .github/workflows/moveArtifacts.sh
@@ -467,27 +456,23 @@ jobs:
467456
run: |
468457
yarn dlx pkg-pr-new publish "." "./packages/@rescript/*"
469458
470-
installationTest:
459+
test-integration:
471460
needs:
472461
- pkg-pr-new
473462
strategy:
474463
fail-fast: false
475464
matrix:
476465
include:
477466
- os: macos-13
478-
node-target: darwin-x64
479467
- os: macos-14
480-
node-target: darwin-arm64
481468
- os: ubuntu-24.04
482-
node-target: linux-x64
483469
- os: ubuntu-24.04-arm
484-
node-target: linux-arm64
485470
- os: windows-latest
486-
node-target: win32-x64
487471
runs-on: ${{ matrix.os }}
472+
env:
473+
RUST_BACKTRACE: "1"
488474
steps:
489475
- name: Checkout
490-
id: checkout
491476
uses: actions/checkout@v4
492477

493478
- name: Use Node.js
@@ -521,11 +506,22 @@ jobs:
521506
shell: bash
522507
working-directory: ${{ steps.tmp-dir.outputs.path }}
523508

509+
- name: Install ReScript package in rewatch/testrepo
510+
if: runner.os == 'Linux'
511+
run: |
512+
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
513+
yarn add "rescript@https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA::7}"
514+
shell: bash
515+
working-directory: rewatch/testrepo
516+
517+
- name: Run rewatch integration tests
518+
# Currently failing on Windows and intermittently on macOS
519+
if: runner.os == 'Linux'
520+
run: make test-rewatch-ci
521+
524522
publish:
525523
needs:
526-
- build-rewatch
527-
- build-compiler
528-
- installationTest
524+
- test-integration
529525
if: startsWith(github.ref, 'refs/tags/v')
530526
runs-on: ubuntu-24.04-arm
531527
steps:
@@ -542,7 +538,7 @@ jobs:
542538
- name: Download artifacts
543539
uses: actions/download-artifact@v4
544540
with:
545-
pattern: "@(binaries-*|rewatch-*|lib-ocaml)"
541+
pattern: "@(binaries-*|lib-ocaml)"
546542

547543
- name: Move artifacts into packages
548544
run: .github/workflows/moveArtifacts.sh
@@ -553,10 +549,8 @@ jobs:
553549
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
554550
run: |
555551
yarn workspaces foreach -W --no-private \
556-
npm publish --tag ci
552+
npm publish --tolerate-republish --tag ci
557553
558554
- name: Update Website Playground
559-
env:
560-
NEXT_REVALIDATE_SECRET_TOKEN: ${{ secrets.NEXT_REVALIDATE_SECRET_TOKEN }}
561-
run: yarn workspace playground revalidate
555+
run: curl -X POST "${{ secrets.CLOUDFLARE_PAGES_DEPLOYMENT_HOOK }}"
562556
shell: bash

.github/workflows/moveArtifacts.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ check_statically_linked() {
2929
mv lib-ocaml lib/ocaml
3030

3131
# @rescript/{target}
32-
chmod +x binaries-*/*.exe rewatch-*/*.exe
33-
mv -f binaries-darwin-x64/* rewatch-darwin-x64/* "packages/@rescript/darwin-x64/bin"
34-
mv -f binaries-darwin-arm64/* rewatch-darwin-arm64/* "packages/@rescript/darwin-arm64/bin"
35-
mv -f binaries-linux-x64/* rewatch-linux-x64/* "packages/@rescript/linux-x64/bin"
36-
mv -f binaries-linux-arm64/* rewatch-linux-arm64/* "packages/@rescript/linux-arm64/bin"
37-
mv -f binaries-win32-x64/* rewatch-win32-x64/* "packages/@rescript/win32-x64/bin"
32+
chmod +x binaries-*/*.exe
33+
mv -f binaries-darwin-x64/* "packages/@rescript/darwin-x64/bin"
34+
mv -f binaries-darwin-arm64/* "packages/@rescript/darwin-arm64/bin"
35+
mv -f binaries-linux-x64/* "packages/@rescript/linux-x64/bin"
36+
mv -f binaries-linux-arm64/* "packages/@rescript/linux-arm64/bin"
37+
mv -f binaries-win32-x64/* "packages/@rescript/win32-x64/bin"
3838
check_statically_linked "packages/@rescript/linux-x64/bin"
3939
check_statically_linked "packages/@rescript/linux-arm64/bin"
4040

0 commit comments

Comments
 (0)