-
Notifications
You must be signed in to change notification settings - Fork 484
592 lines (512 loc) · 19.3 KB
/
Copy pathci.yml
File metadata and controls
592 lines (512 loc) · 19.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
name: CI
on:
push:
branches: [master, 11.0_release]
pull_request:
branches: [master, 11.0_release]
# Release builds are started by publish.yml after a maintainer indicates
# whether the package version is current stable. The npm tag is derived from
# that choice and package.json.
workflow_call:
inputs:
release-version:
description: Version being released, or empty for a normal CI run.
required: false
type: string
default: ""
concurrency:
group: ci-${{ github.ref }}-1
# Cancel previous builds for pull requests only.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
OCAMLRUNPARAM: b
RUST_BACKTRACE: "1"
RUSTFLAGS: "-Dwarnings"
jobs:
build-compiler:
outputs:
api-docs-artifact-id: ${{ steps.upload-api-docs.outputs.artifact-id }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04 # x64
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
upload_binaries: true
upload_libs: true
node-target: linux-x64
rust-target: x86_64-unknown-linux-musl
dune-profile: static
- 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
generate_api_docs: true
benchmarks: true
node-target: linux-arm64
rust-target: aarch64-unknown-linux-musl
dune-profile: static
- os: macos-15-intel # x64
ocaml_compiler: 5.3.0
upload_binaries: true
node-target: darwin-x64
rust-target: x86_64-apple-darwin
dune-profile: release
- os: macos-15 # ARM
ocaml_compiler: 5.3.0
upload_binaries: true
node-target: darwin-arm64
rust-target: aarch64-apple-darwin
dune-profile: release
- os: windows-2025
ocaml_compiler: 5.3.0
upload_binaries: true
node-target: win32-x64
rust-target: x86_64-pc-windows-gnu
exe-suffix: ".exe"
dune-profile: release
# Verify that the compiler still builds with the oldest OCaml version we support.
- 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
dune-profile: static
runs-on: ${{matrix.os}}
env:
DUNE_PROFILE: ${{ matrix.dune-profile }}
steps:
- name: "Windows: Set git config"
if: runner.os == 'Windows'
run: |
git config --system core.autocrlf false
git config --system core.eol lf
git config --system core.longpaths true
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node and dependencies
uses: ./.github/actions/setup-node
- name: Setup Linux dependencies
if: runner.os == 'Linux'
uses: ./.github/actions/setup-linux-dependencies
- name: Build rewatch
uses: ./.github/actions/build-rewatch
with:
cache-target: ${{ matrix.rust-target }}
rust-target: ${{ matrix.rust-target }}
exe-suffix: ${{ matrix.exe-suffix }}
run-quality-checks: "true"
- name: Setup OCaml ${{ matrix.ocaml_compiler }}
id: setup_ocaml
uses: ./.github/actions/setup-ocaml
with:
compiler: ${{ matrix.ocaml_compiler }}
os: ${{ matrix.os }}
cache-prefix: opam-env-v8
- name: Compiler build state key
id: compiler-build-state-key
shell: bash
run: |
echo "value=compiler-build-state-v1-${{ matrix.os }}-${{ steps.setup_ocaml.outputs.setup_version }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" \
| sed 's/,/-/g' >> "$GITHUB_OUTPUT"
- name: Restore compiler build state
if: github.base_ref == 'master' || github.ref == 'refs/heads/master'
id: compiler-build-state
uses: actions/cache/restore@v6
with:
path: |
C:\.cache\dune
~/.cache/dune
_build
key: ${{ steps.compiler-build-state-key.outputs.value }}
- name: Build compiler
run: opam exec -- dune build --display quiet
- name: Delete stable compiler build state
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
shell: bash
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ steps.compiler-build-state-key.outputs.value }} \
-R ${{ github.repository }} \
-B "$GITHUB_REF" \
--confirm || echo "not exist"
env:
GH_TOKEN: ${{ github.token }}
- name: Save compiler build state
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/cache/save@v6
with:
path: |
C:\.cache\dune
~/.cache/dune
_build
key: ${{ steps.compiler-build-state-key.outputs.value }}
- name: Copy compiler exes to platform bin dir
run: node scripts/copyExes.js --compiler
- name: "Syntax: Run tests"
env:
ROUNDTRIP_TEST: ${{ runner.os == 'Windows' && '0' || '1' }}
run: ./scripts/test_syntax.sh
shell: bash
- name: Build @rescript/runtime
run: yarn workspace @rescript/runtime build
shell: bash
- name: Check for changes in @rescript/runtime/lib
run: git diff --exit-code lib/js lib/es6
working-directory: packages/@rescript/runtime
- name: Version Check
run: yarn constraints
- name: Run tests
run: node scripts/test.js -all
- name: Check for diffs in tests folder
run: git diff --ignore-cr-at-eol --exit-code tests
- name: Run analysis / tools tests
if: runner.os != 'Windows' && runner.os != 'Linux'
run: opam exec -- make -C tests/analysis_tests test && make -C tests/tools_tests test
- name: Run gentype tests
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: |
set -o pipefail
./_build/install/default/bin/syntax_benchmarks | tee tests/benchmark-output.json
# Benchmarking is disabled for now because of inconsistent run times on different runners
#
# - name: Restore previous benchmark data
# if: matrix.benchmarks
# uses: actions/cache/restore@v6
# with:
# path: ./tests/benchmark-cache
# key: syntax-benchmark-v1
# - name: Create new benchmark data and comment on alert
# # Do not run for PRs created from other repos as those won't be able to write to the pull request
# if: ${{ matrix.benchmarks && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.repository.full_name) }}
# uses: benchmark-action/github-action-benchmark@v1
# with:
# name: Syntax Benchmarks
# tool: customSmallerIsBetter
# output-file-path: tests/benchmark-output.json
# external-data-json-path: ./tests/benchmark-cache/benchmark-data.json
# github-token: ${{ secrets.GITHUB_TOKEN }}
# alert-threshold: "105%"
# comment-always: false
# comment-on-alert: true
# - name: Save benchmark data as new baseline
# if: matrix.benchmarks && github.ref == 'refs/heads/master'
# uses: actions/cache/save@v6
# with:
# path: ./tests/benchmark-cache
# key: syntax-benchmark-v1
- name: Build playground compiler
if: matrix.build_playground
run: opam exec -- make playground
- name: Test playground compiler
if: matrix.build_playground
run: yarn workspace playground test
- name: Stage PR dev playground compiler bundle
if: ${{ matrix.build_playground && github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'master' && github.event.pull_request.head.repo.full_name == github.repository }}
env:
PLAYGROUND_PREVIEW_ID: pr-${{ github.event.pull_request.number }}
run: yarn workspace dev-playground stage-local-bundle "$PLAYGROUND_PREVIEW_ID"
- name: "Upload artifacts: PR dev playground compiler bundle"
if: ${{ matrix.build_playground && github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'master' && github.event.pull_request.head.repo.full_name == github.repository }}
uses: actions/upload-artifact@v7
with:
name: dev-playground-pr-${{ github.event.pull_request.number }}-bundle
path: packages/dev-playground/public/playground-bundles/pr-${{ github.event.pull_request.number }}
if-no-files-found: error
- name: Stage dev playground compiler bundle
if: ${{ matrix.build_playground && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: yarn workspace dev-playground stage-master-bundle
- name: "Upload artifacts: dev playground compiler bundle"
if: ${{ matrix.build_playground && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v7
with:
name: dev-playground-master-bundle
path: packages/dev-playground/public/playground-bundles/master
if-no-files-found: error
- name: "Upload artifacts: release playground compiler bundle"
if: ${{ matrix.build_playground && inputs.release-version != '' }}
uses: actions/upload-artifact@v7
with:
name: playground-release
path: |
packages/playground/compiler.js
packages/playground/packages
if-no-files-found: error
- name: "Upload artifacts: binaries"
if: matrix.upload_binaries
uses: actions/upload-artifact@v7
with:
name: binaries-${{ matrix.node-target }}
path: packages/@rescript/${{ matrix.node-target }}/bin
- name: "Upload artifacts: lib/ocaml"
if: matrix.upload_libs
uses: actions/upload-artifact@v7
with:
name: lib-ocaml
path: |
packages/@rescript/runtime/lib/ocaml
!packages/@rescript/runtime/lib/ocaml/*.ast
!packages/@rescript/runtime/lib/ocaml/*.iast
- name: Generate API Docs
if: ${{ matrix.generate_api_docs }}
run: yarn apidocs:generate
- name: "Upload artifacts: scripts/res/apiDocs"
id: upload-api-docs
if: ${{ matrix.generate_api_docs }}
uses: actions/upload-artifact@v7
with:
name: api
path: scripts/res/apiDocs/
dev-playground:
needs:
- build-compiler
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-24.04
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}dev-playground/
env:
VITE_DEFAULT_COMPILER_VERSION: master
VITE_COMPILER_VERSIONS: '[{"id":"master","label":"master"}]'
VITE_COMPILER_PREVIEW_ROOT: https://cdn.rescript-lang.org/dev-playground-bundles
GITHUB_PAGES_PATH: dev-playground
PLAYGROUND_BUNDLE_ID: master
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node and dependencies
uses: ./.github/actions/setup-node
- name: Download dev playground compiler bundle
uses: actions/download-artifact@v8
with:
name: dev-playground-master-bundle
path: packages/dev-playground/public/playground-bundles/master
- name: Configure GitHub Pages
id: pages
uses: actions/configure-pages@v6
- name: Build dev playground Pages site
env:
VITE_BASE: ${{ steps.pages.outputs.base_path }}/dev-playground/
run: |
yarn workspace dev-playground build
yarn workspace dev-playground prepare-pages-site
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: packages/dev-playground/pages-site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
pkg-pr-new:
needs:
- build-compiler
outputs:
commit_sha: ${{ steps.publish.outputs.sha }}
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Use Node.js
uses: actions/setup-node@v7
with:
cache: yarn
node-version-file: .nvmrc
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: "@(binaries-*|lib-ocaml)"
- name: Move artifacts into packages
run: .github/workflows/moveArtifacts.sh
shell: bash
- name: Check artifact list
run: |
node ./scripts/updateArtifactList.js
git diff --exit-code packages/artifacts.json
- name: Publish packages to pkg.pr.new
id: publish
run: |
yarn dlx pkg-pr-new publish "." "./packages/@rescript/*"
api-docs:
needs:
- build-compiler
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout rescript-lang.org
uses: actions/checkout@v7
with:
repository: rescript-lang/rescript-lang.org
- name: Download artifacts
uses: actions/download-artifact@v8
with:
artifact-ids: ${{ needs.build-compiler.outputs.api-docs-artifact-id }}
path: data/api
- name: Check if repo is clean
id: diffcheck
run: |
git status
if [ -z "$(git status --porcelain)" ]; then
echo "clean=true" >> $GITHUB_OUTPUT
else
echo "clean=false" >> $GITHUB_OUTPUT
fi
- name: Use Node.js
if: steps.diffcheck.outputs.clean == 'false'
uses: actions/setup-node@v7
with:
cache: yarn
node-version-file: .node-version
- name: Build website
if: steps.diffcheck.outputs.clean == 'false'
run: |
yarn
yarn build
test-devcontainer:
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Run make in dev container
uses: devcontainers/ci@v0.3
with:
push: never
runCmd: make
test-installation-npm:
needs:
- pkg-pr-new
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
- os: macos-15
- os: ubuntu-24.04
- os: ubuntu-24.04-arm
- os: windows-2025
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Use Node.js
uses: actions/setup-node@v7
with:
# Run integration tests with the oldest supported node version.
node-version: 20
- name: Make test directory
id: tmp-dir
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
dir=$(powershell -Command "[System.IO.Path]::GetTempPath() + [System.Guid]::NewGuid().ToString()" | tr -d '\r')
mkdir -p "$dir"
else
dir=$(mktemp -d)
fi
echo "path=$dir" >> "$GITHUB_OUTPUT"
cp -r tests/package_tests/installation_test/* "$dir"
- name: Install ReScript package
run: |
COMMIT_SHA="${{ needs.pkg-pr-new.outputs.commit_sha }}"
npm i --no-audit \
"https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA}"
shell: bash
working-directory: ${{ steps.tmp-dir.outputs.path }}
- name: Test installation
run: npx rescript -h && npx rescript build && cat src/Test.res.js
shell: bash
working-directory: ${{ steps.tmp-dir.outputs.path }}
test-installation-pnpm:
needs:
- pkg-pr-new
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
- os: macos-15
- os: ubuntu-24.04
- os: ubuntu-24.04-arm
- os: windows-2025
runs-on: ${{ matrix.os }}
steps:
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 10
- name: Use Node.js
uses: actions/setup-node@v7
with:
# Run integration tests with the oldest supported node version.
node-version: 22
- name: Checkout
uses: actions/checkout@v7
- name: Make test directory
id: tmp-dir
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
dir=$(powershell -Command "[System.IO.Path]::GetTempPath() + [System.Guid]::NewGuid().ToString()" | tr -d '\r')
mkdir -p "$dir"
else
dir=$(mktemp -d)
fi
echo "path=$dir" >> "$GITHUB_OUTPUT"
cp -r tests/package_tests/installation_test/* "$dir"
- name: Install ReScript package
run: |
COMMIT_SHA="${{ needs.pkg-pr-new.outputs.commit_sha }}"
# pnpm 10 blocks pkg.pr.new's URL-based platform subdependencies unless block-exotic-subdeps is disabled.
pnpm --config.block-exotic-subdeps=false i \
"https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA}"
shell: bash
working-directory: ${{ steps.tmp-dir.outputs.path }}
- name: Test installation
run: pnpm rescript -h && pnpm rescript build && cat src/Test.res.js
shell: bash
working-directory: ${{ steps.tmp-dir.outputs.path }}
test-integration-rewatch:
needs:
- pkg-pr-new
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
- os: macos-15
- os: ubuntu-24.04
- os: ubuntu-24.04-arm
- os: windows-2025
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Use Node.js
uses: actions/setup-node@v7
with:
# Run integration tests with the oldest supported node version.
node-version: 20
- name: Install ReScript package in rewatch/testrepo
run: |
COMMIT_SHA="${{ needs.pkg-pr-new.outputs.commit_sha }}"
yarn add "rescript@https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA}"
shell: bash
working-directory: rewatch/testrepo
- name: Run rewatch integration tests
run: ./rewatch/tests/suite.sh rewatch/testrepo/node_modules/.bin/rescript
shell: bash