Repository navigation
Read the class of an @instanceOf type from its @module and @scope
#13219
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [master, maintenance/*] | |
| pull_request: | |
| branches: [master, maintenance/*] | |
| # 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 | |
| jobs: | |
| build-compiler: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-26.04 # x64 | |
| ocaml_compiler: ocaml-variants.5.5.2+options,ocaml-option-static | |
| upload_binaries: true | |
| upload_libs: true | |
| node-target: linux-x64 | |
| dune-profile: static | |
| - os: ubuntu-26.04-arm # ARM | |
| ocaml_compiler: ocaml-variants.5.5.2+options,ocaml-option-static | |
| upload_binaries: true | |
| # Build the playground compiler on the fastest runner | |
| build_playground: true | |
| generate_api_docs: true | |
| test_commit_records: true | |
| node-target: linux-arm64 | |
| dune-profile: static | |
| - os: macos-26 # ARM | |
| ocaml_compiler: 5.5.2 | |
| upload_binaries: true | |
| node-target: darwin-arm64 | |
| dune-profile: release | |
| - os: windows-2025 | |
| ocaml_compiler: 5.5.2 | |
| upload_binaries: true | |
| node-target: win32-x64 | |
| exe-suffix: ".exe" | |
| dune-profile: release | |
| # Verify that the compiler still builds with the oldest OCaml version we support. | |
| # It runs only the build system's unit tests; the other build system | |
| # tests repeat the linux-x64 job's. OCaml 5.0 does not build with | |
| # GCC 15 (C23 by default), so this job stays on Ubuntu 24.04. | |
| - os: ubuntu-24.04 | |
| ocaml_compiler: ocaml-variants.5.0.0+options,ocaml-option-static | |
| node-target: linux-x64 | |
| dune-profile: static | |
| skip_rewatch_integration_tests: true | |
| 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 | |
| git config --system core.symlinks 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: 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-v9 | |
| - name: Compiler build state key | |
| id: compiler-build-state-key | |
| shell: bash | |
| run: | | |
| echo "value=compiler-build-state-v2-${{ matrix.os }}-${{ steps.setup_ocaml.outputs.setup_version }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" \ | |
| | sed 's/,/-/g' >> "$GITHUB_OUTPUT" | |
| # Only _build: dune's shared cache under ~/.cache/dune would grow with | |
| # every master push that restores, extends and saves it again. | |
| - 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: _build | |
| key: ${{ steps.compiler-build-state-key.outputs.value }} | |
| - name: Build compiler | |
| run: opam exec -- dune build --display quiet | |
| # Reads the linked libraries, versions, and license texts from this | |
| # job's opam switch, the one the linux-x64 release binaries come from. | |
| - name: Check third-party licenses | |
| if: matrix.upload_libs | |
| run: opam exec -- node scripts/generateThirdPartyLicenses.js --check | |
| - 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: _build | |
| key: ${{ steps.compiler-build-state-key.outputs.value }} | |
| - name: Verify promoted compiler exes | |
| run: node scripts/checkCompilerExes.js | |
| - name: "Syntax: Run tests" | |
| env: | |
| ROUNDTRIP_TEST: 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: Build @rescript/belt | |
| run: yarn workspace @rescript/belt build | |
| shell: bash | |
| - name: Check for changes in @rescript/belt/lib | |
| run: git diff --exit-code lib/js lib/es6 | |
| working-directory: packages/@rescript/belt | |
| - name: Version Check | |
| run: yarn constraints | |
| - name: Type check JS | |
| run: yarn typecheck | |
| - name: Test release plan | |
| run: yarn test-release-plan | |
| - name: Test commit records | |
| if: matrix.test_commit_records | |
| run: yarn test-commit-records | |
| - name: Test the pull request comment action | |
| if: matrix.test_commit_records | |
| run: yarn test-upsert-comment | |
| # The format check gives the same result everywhere; it runs on Linux | |
| # only, where it is fastest. | |
| - name: Run tests | |
| run: node scripts/test.js ${{ runner.os == 'Linux' && '-all' || '-ounit -mocha -build -docstrings' }} | |
| - name: Check for diffs in tests folder | |
| run: git diff --ignore-cr-at-eol --exit-code tests | |
| # 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 test scripts below. | |
| # So we need to adjust the path to bring back Git Bash for Windows. | |
| # Cygwin's make would also hand /cygdrive paths to yarn, so put the | |
| # runner's MinGW make (used on a cache hit) in front of it as well, and | |
| # stop Git Bash from sourcing Cygwin's bash_env. | |
| - name: "Windows: Use Git Bash" | |
| if: ${{ runner.os == 'Windows' }} | |
| run: | | |
| echo "C:\mingw64\bin" >> $GITHUB_PATH | |
| echo "C:\Program Files\Git\bin" >> $GITHUB_PATH | |
| echo "BASH_ENV=" >> $GITHUB_ENV | |
| shell: bash | |
| # Git Bash does not include make. | |
| - name: "Windows: Install make" | |
| if: ${{ runner.os == 'Windows' }} | |
| run: command -v make || choco install make --no-progress | |
| shell: bash | |
| # Linux runs these tests in the coverage workflow. | |
| - name: Run analysis / tools tests | |
| if: runner.os != 'Linux' | |
| run: opam exec -- make -C tests/analysis_tests test && make -C tests/tools_tests test | |
| shell: bash | |
| - name: Run gentype tests | |
| run: make -C tests/gentype_tests/typescript-react-example clean test | |
| shell: bash | |
| - name: Run rewatch snapshot tests | |
| if: ${{ !matrix.skip_rewatch_integration_tests }} | |
| timeout-minutes: 20 | |
| run: | | |
| . rewatch-ocaml/tests/process_watchdog.sh | |
| start_process_watchdog | |
| bash rewatch-ocaml/tests/check_canonical_test_coverage.sh | |
| bash rewatch-ocaml/tests/check_config_acceptance.sh \ | |
| packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe | |
| bash rewatch-ocaml/tests/check_command_validation.sh \ | |
| packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe | |
| shell: bash | |
| - name: Run 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.exe | |
| shell: bash | |
| - name: Run rewatch verbose output tests | |
| if: ${{ !matrix.skip_rewatch_integration_tests }} | |
| timeout-minutes: 10 | |
| run: | | |
| bash rewatch-ocaml/tests/check_verbose_output.sh \ | |
| packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe | |
| shell: bash | |
| - name: Run 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 | |
| # The canonical suite works in rewatch/testrepo and the focused one in | |
| # directories of its own, so they run side by side; each takes one to | |
| # three and a half minutes. The canonical suite fails when another | |
| # process runs its executable as it starts, so it runs a copy. Its | |
| # output is shown once both are done. | |
| - name: Run rewatch focused integration and canonical tests | |
| if: ${{ !matrix.skip_rewatch_integration_tests }} | |
| timeout-minutes: 30 | |
| run: | | |
| bin=packages/@rescript/${{ matrix.node-target }}/bin | |
| rm -rf tmp/canonical-bin | |
| mkdir -p tmp | |
| cp -R "$bin" tmp/canonical-bin | |
| canonical_log=tmp/canonical-tests.log | |
| ./rewatch/tests/suite.sh tmp/canonical-bin/rescript.exe >"$canonical_log" 2>&1 & | |
| canonical=$! | |
| focused_status=0 | |
| sh rewatch-ocaml/tests/run.sh "$bin/rescript.exe" || focused_status=$? | |
| canonical_status=0 | |
| wait "$canonical" || canonical_status=$? | |
| if [ "$canonical_status" -eq 0 ]; then | |
| echo "::group::Canonical tests" | |
| cat "$canonical_log" | |
| echo "::endgroup::" | |
| else | |
| cat "$canonical_log" | |
| echo "::error::The canonical tests failed with status $canonical_status" | |
| fi | |
| if [ "$focused_status" -ne 0 ]; then | |
| echo "::error::The focused integration tests failed with status $focused_status" | |
| fi | |
| [ "$focused_status" -eq 0 ] && [ "$canonical_status" -eq 0 ] | |
| shell: bash | |
| - name: Build playground compiler | |
| if: matrix.build_playground | |
| run: opam exec -- make playground | |
| # Runs after the playground build, whose browser-profile tree it | |
| # analyzes together with the native one. reanalyze is a test | |
| # dependency, installed with the switch. | |
| - name: Check for dead code | |
| if: matrix.build_playground | |
| run: opam exec -- make dead-code | |
| - name: Test playground compiler | |
| if: matrix.build_playground | |
| run: yarn workspace playground test | |
| - name: Test dev playground | |
| if: matrix.build_playground | |
| run: yarn workspace dev-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/rescript" | |
| if: matrix.upload_libs | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: lib-rescript | |
| path: | | |
| packages/@rescript/runtime/lib/rescript | |
| !packages/@rescript/runtime/lib/rescript/*.ast | |
| !packages/@rescript/runtime/lib/rescript/*.iast | |
| !packages/@rescript/runtime/lib/rescript/compiler-info.json | |
| - name: Select API docs website branch | |
| id: api-docs-plan | |
| if: ${{ matrix.generate_api_docs }} | |
| run: node scripts/releasePlan.js --github-output "$GITHUB_OUTPUT" | |
| - name: Generate API Docs | |
| if: ${{ matrix.generate_api_docs }} | |
| run: yarn apidocs:generate | |
| # Release builds publish this artifact to the website (publish.yml). | |
| - name: "Upload artifacts: scripts/res/apiDocs" | |
| if: ${{ matrix.generate_api_docs }} | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: api | |
| path: scripts/res/apiDocs/ | |
| # Checks that the website builds with the generated API docs. These | |
| # steps stay in this job rather than in one that needs build-compiler, | |
| # which would wait for the slowest platform before starting. The build | |
| # depends only on the docs and the website commit, so an empty cache | |
| # entry keyed on both records each pair that built, and a pull request | |
| # whose docs match an earlier build skips it. | |
| - name: Website build key | |
| id: website-build-key | |
| if: ${{ matrix.generate_api_docs }} | |
| env: | |
| WEBSITE_BRANCH: ${{ steps.api-docs-plan.outputs.website-branch }} | |
| run: | | |
| sha=$(git ls-remote https://github.com/rescript-lang/rescript-lang.org.git "refs/heads/$WEBSITE_BRANCH" | cut -f1) | |
| if [ -z "$sha" ]; then | |
| echo "::error::The website has no branch $WEBSITE_BRANCH" | |
| exit 1 | |
| fi | |
| echo "sha=$sha" >> "$GITHUB_OUTPUT" | |
| echo "value=website-build-v1-$sha-${{ hashFiles('scripts/res/apiDocs/**') }}" >> "$GITHUB_OUTPUT" | |
| shell: bash | |
| - name: Look up website build | |
| id: website-build | |
| if: ${{ matrix.generate_api_docs }} | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: tmp/website-build | |
| key: ${{ steps.website-build-key.outputs.value }} | |
| lookup-only: true | |
| - name: Checkout rescript-lang.org | |
| if: ${{ matrix.generate_api_docs && steps.website-build.outputs.cache-hit != 'true' }} | |
| uses: actions/checkout@v7 | |
| with: | |
| repository: rescript-lang/rescript-lang.org | |
| ref: ${{ steps.website-build-key.outputs.sha }} | |
| path: rescript-lang.org | |
| # The website is checked out inside this repository, so its Yarn also | |
| # reads this repository's .yarnrc.yml and rejects the settings it does | |
| # not know yet. The steps that need this config are done. | |
| - name: Hide the compiler's Yarn config from the website | |
| if: ${{ matrix.generate_api_docs && steps.website-build.outputs.cache-hit != 'true' }} | |
| run: mv .yarnrc.yml "$RUNNER_TEMP/rescript.yarnrc.yml" | |
| shell: bash | |
| - name: Use Node.js for website | |
| if: ${{ matrix.generate_api_docs && steps.website-build.outputs.cache-hit != 'true' }} | |
| uses: actions/setup-node@v7 | |
| with: | |
| cache: yarn | |
| cache-dependency-path: rescript-lang.org/yarn.lock | |
| node-version-file: rescript-lang.org/.node-version | |
| - name: Build website with the API docs | |
| if: ${{ matrix.generate_api_docs && steps.website-build.outputs.cache-hit != 'true' }} | |
| run: | | |
| cp -R ../scripts/res/apiDocs/. data/api/ | |
| yarn | |
| yarn build | |
| working-directory: rescript-lang.org | |
| shell: bash | |
| - name: Record website build | |
| if: ${{ matrix.generate_api_docs && steps.website-build.outputs.cache-hit != 'true' }} | |
| run: mkdir -p tmp/website-build && echo "$KEY" > tmp/website-build/key | |
| env: | |
| KEY: ${{ steps.website-build-key.outputs.value }} | |
| shell: bash | |
| - name: Save website build record | |
| if: ${{ matrix.generate_api_docs && steps.website-build.outputs.cache-hit != 'true' }} | |
| uses: actions/cache/save@v6 | |
| with: | |
| path: tmp/website-build | |
| key: ${{ steps.website-build-key.outputs.value }} | |
| # Compares the words the compiler allocates on fixed inputs, and the | |
| # instructions it executes on some of them, with the base branch | |
| # (scripts/compilerBenchmarks.js). Neither count depends on the runner's | |
| # speed, so this can fail on a growth of 1%. It is not needed by ci-ok: a | |
| # deliberate growth shouldn't block a merge. The report goes to the job | |
| # summary and, for a pull request from a branch of this repository, to a | |
| # comment on it; a fork's pull request gets a token that can't comment. | |
| benchmarks: | |
| if: github.event_name == 'pull_request' | |
| # x64, since bsc doesn't run under valgrind on arm64. | |
| runs-on: ubuntu-26.04 | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| # The same build as the first linux-x64 build-compiler job, so that the | |
| # OPAM environment and the build state are shared. | |
| DUNE_PROFILE: static | |
| OCAML_COMPILER: ocaml-variants.5.5.2+options,ocaml-option-static | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| # The merge commit and its first parent, the base branch. | |
| fetch-depth: 2 | |
| - name: Setup Node and dependencies | |
| uses: ./.github/actions/setup-node | |
| - name: Test the benchmark script | |
| run: yarn test-compiler-benchmarks | |
| - name: Setup Linux dependencies | |
| uses: ./.github/actions/setup-linux-dependencies | |
| - name: Install valgrind | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y -qq --no-install-recommends valgrind | |
| valgrind --version | |
| - name: Setup OCaml | |
| id: setup_ocaml | |
| uses: ./.github/actions/setup-ocaml | |
| with: | |
| compiler: ${{ env.OCAML_COMPILER }} | |
| os: ubuntu-26.04 | |
| cache-prefix: opam-env-v9 | |
| - name: Compiler build state key | |
| id: compiler-build-state-key | |
| run: | | |
| echo "value=compiler-build-state-v2-ubuntu-26.04-${{ steps.setup_ocaml.outputs.setup_version }}-$OCAML_COMPILER-${{ hashFiles('*.opam') }}" \ | |
| | sed 's/,/-/g' >> "$GITHUB_OUTPUT" | |
| - name: Restore compiler build state | |
| uses: actions/cache/restore@v6 | |
| with: | |
| # The paths are part of the cache's version, so they must be the | |
| # ones build-compiler saves. | |
| path: _build | |
| key: ${{ steps.compiler-build-state-key.outputs.value }} | |
| - name: Build the compiler | |
| run: opam exec -- dune build --display quiet | |
| - name: Build the base branch's compiler | |
| run: | | |
| git worktree add --detach "$RUNNER_TEMP/base" HEAD^1 | |
| opam exec -- dune build --root "$RUNNER_TEMP/base" --display quiet | |
| # For the size of the bundle only; the playground is tested elsewhere. | |
| - name: Build the playground compilers | |
| run: | | |
| opam exec -- make playground-compiler | |
| opam exec -- make -C "$RUNNER_TEMP/base" playground-compiler | |
| - name: Measure and compare | |
| env: | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| run: | | |
| # Both checkouts are measured from the same path, one after the | |
| # other: the paths in the compiler's arguments change its counts a | |
| # little, and the instructions of the runtime and Belt files by up | |
| # to 0.2%. The runtime and Belt are built there too, since the | |
| # replayed builds would otherwise write interfaces that don't | |
| # match those of the files they don't replay yet. Both build the | |
| # base's tests/tests, which the base's compiler builds already. | |
| measure() { | |
| sudo mkdir -p /bench | |
| sudo mount --bind "$1" /bench | |
| node scripts/compilerBenchmarks.js prepare /bench | |
| node scripts/compilerBenchmarks.js measure /bench "$2" --instructions \ | |
| --project "$RUNNER_TEMP/base" --playground | |
| sudo umount /bench | |
| } | |
| measure "$RUNNER_TEMP/base" "$RUNNER_TEMP/base.json" | |
| measure "$GITHUB_WORKSPACE" "$RUNNER_TEMP/head.json" | |
| status=0 | |
| report="$RUNNER_TEMP/benchmarks-report.md" | |
| node scripts/compilerBenchmarks.js compare "$RUNNER_TEMP/base.json" "$RUNNER_TEMP/head.json" \ | |
| --threshold 1 --summary "$report" || status=$? | |
| cat "$report" >> "$GITHUB_STEP_SUMMARY" | |
| printf '\nPull request %s compared with base %s in [this run](%s).\n' \ | |
| "$(git rev-parse --short=9 HEAD^2)" "$(git rev-parse --short=9 HEAD^1)" "$RUN_URL" \ | |
| >> "$report" | |
| exit "$status" | |
| # When a step failed before the comparison, the comment says so instead | |
| # of keeping the report of an earlier commit. | |
| - name: Report a failure to run the benchmarks | |
| if: ${{ !cancelled() }} | |
| env: | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| report="$RUNNER_TEMP/benchmarks-report.md" | |
| if [ ! -f "$report" ]; then | |
| { | |
| echo "## ⚠️ Compiler benchmarks" | |
| echo | |
| echo "The benchmarks couldn't run for pull request ${HEAD_SHA:0:9}; [the run]($RUN_URL) shows why." | |
| } > "$report" | |
| cat "$report" >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| # The pull request's one comment, edited in place on each push, also | |
| # when nothing changed, so that it shows the comparison ran. | |
| - name: Comment on the pull request | |
| if: >- | |
| !cancelled() && | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| uses: ./.github/actions/upsert-comment | |
| with: | |
| pr-number: ${{ github.event.pull_request.number }} | |
| tag: compiler-benchmarks | |
| body-path: ${{ runner.temp }}/benchmarks-report.md | |
| dev-playground: | |
| needs: | |
| - build-compiler | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
| runs-on: ubuntu-26.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-26.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-rescript)" | |
| - 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 --yarn "." "./packages/@rescript/*" | |
| test-devcontainer: | |
| runs-on: ubuntu-26.04-arm | |
| steps: | |
| # Building the dev container takes about 10 minutes. On pull requests it | |
| # runs only when the container's inputs change: its definition, the opam | |
| # and yarn dependencies its setup installs, the Makefile, or this | |
| # workflow. If the changed files can't be listed, it runs. | |
| - name: Check whether the dev container is affected | |
| id: changes | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| EVENT: ${{ github.event_name }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| affected=true | |
| if [ "$EVENT" = pull_request ] && | |
| files=$(gh pr diff "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --name-only) && | |
| ! grep -qE '^(\.devcontainer/|Makefile$|dune-project$|[^/]*\.opam(\.template)?$|\.yarnrc\.yml$|yarn\.lock$|\.yarn/|\.github/workflows/ci\.yml$)|(^|/)package\.json$' <<< "$files"; then | |
| affected=false | |
| fi | |
| echo "affected=$affected" | tee -a "$GITHUB_OUTPUT" | |
| - name: Checkout | |
| if: steps.changes.outputs.affected == 'true' | |
| uses: actions/checkout@v7 | |
| - name: Run make in dev container | |
| if: steps.changes.outputs.affected == 'true' | |
| uses: devcontainers/ci@v0.3 | |
| with: | |
| push: never | |
| runCmd: make | |
| # Installs the packages published by pkg-pr-new with npm, then with pnpm, | |
| # each in a directory of its own. One job per OS rather than one per | |
| # package manager halves the jobs that wait for a runner, macOS runners | |
| # in particular. | |
| test-installation: | |
| needs: | |
| - pkg-pr-new | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-26 | |
| - os: ubuntu-26.04 | |
| - os: ubuntu-26.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 directories | |
| id: tmp-dir | |
| shell: bash | |
| run: | | |
| for manager in npm pnpm; do | |
| 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 "$manager=$dir" >> "$GITHUB_OUTPUT" | |
| cp -r tests/package_tests/installation_test/* "$dir" | |
| # The compiled stdlib tests run against the installed runtime. Their | |
| # Test.mjs imports @babel/code-frame, which tests/tests depends on. | |
| cp -r tests/tests/src/stdlib "$dir/stdlib" | |
| done | |
| echo "code-frame=$(node -p 'require("./tests/tests/package.json").dependencies["@babel/code-frame"]')" >> "$GITHUB_OUTPUT" | |
| - name: "npm: 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}" \ | |
| "https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@${COMMIT_SHA}" \ | |
| "https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}" \ | |
| "@babel/code-frame@${{ steps.tmp-dir.outputs.code-frame }}" | |
| shell: bash | |
| working-directory: ${{ steps.tmp-dir.outputs.npm }} | |
| - name: "npm: Test installation" | |
| run: | | |
| npx rescript -h | |
| npx rescript build | |
| cp src/BeltTest.res.txt src/BeltTest.res | |
| if npx rescript build; then | |
| echo "Belt unexpectedly compiled without being listed as a dependency" >&2 | |
| exit 1 | |
| fi | |
| cp rescript-with-belt.json rescript.json | |
| npx rescript build | |
| node src/BeltTest.mjs | |
| shell: bash | |
| working-directory: ${{ steps.tmp-dir.outputs.npm }} | |
| - name: "npm: Test packaged CLI subcommands and watch shutdown" | |
| run: node packaged-cli-smoke.mjs | |
| shell: bash | |
| working-directory: ${{ steps.tmp-dir.outputs.npm }} | |
| # build-compiler runs the stdlib tests on the Node.js version in .nvmrc, | |
| # this job on the oldest supported one, so tests of APIs missing there | |
| # must stay out of Stdlib_TestSuite and Stdlib_TempTests. | |
| - name: "npm: Run stdlib tests" | |
| run: | | |
| node stdlib/Stdlib_TestSuite.mjs | |
| node stdlib/Stdlib_TempTests.mjs | |
| shell: bash | |
| working-directory: ${{ steps.tmp-dir.outputs.npm }} | |
| # The pnpm steps run even when an npm step failed, so that one run | |
| # reports both package managers. | |
| - name: "pnpm: Install ReScript package" | |
| id: pnpm-install | |
| if: ${{ !cancelled() && steps.tmp-dir.outcome == 'success' }} | |
| 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}" \ | |
| "https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@${COMMIT_SHA}" \ | |
| "https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}" \ | |
| "@babel/code-frame@${{ steps.tmp-dir.outputs.code-frame }}" | |
| shell: bash | |
| working-directory: ${{ steps.tmp-dir.outputs.pnpm }} | |
| - name: "pnpm: Test installation" | |
| id: pnpm-test | |
| if: ${{ !cancelled() && steps.pnpm-install.outcome == 'success' }} | |
| run: | | |
| pnpm rescript -h | |
| pnpm rescript build | |
| cp src/BeltTest.res.txt src/BeltTest.res | |
| if pnpm rescript build; then | |
| echo "Belt unexpectedly compiled without being listed as a dependency" >&2 | |
| exit 1 | |
| fi | |
| cp rescript-with-belt.json rescript.json | |
| pnpm rescript build | |
| node src/BeltTest.mjs | |
| shell: bash | |
| working-directory: ${{ steps.tmp-dir.outputs.pnpm }} | |
| - name: "pnpm: Run stdlib tests" | |
| if: ${{ !cancelled() && steps.pnpm-test.outcome == 'success' }} | |
| run: | | |
| node stdlib/Stdlib_TestSuite.mjs | |
| node stdlib/Stdlib_TempTests.mjs | |
| shell: bash | |
| working-directory: ${{ steps.tmp-dir.outputs.pnpm }} | |
| # The single CI check that the master ruleset requires. Matrix job names | |
| # contain runner labels, so requiring this job instead keeps the ruleset | |
| # unchanged when runners or jobs change. It runs even when a needed job fails | |
| # or the run is cancelled, because a skipped required check counts as passed. | |
| ci-ok: | |
| if: ${{ always() }} | |
| needs: | |
| - build-compiler | |
| - pkg-pr-new | |
| - test-devcontainer | |
| - test-installation | |
| runs-on: ubuntu-26.04 | |
| steps: | |
| - name: Check that all needed jobs succeeded | |
| env: | |
| NEEDS: ${{ toJSON(needs) }} | |
| run: | | |
| jq -r 'to_entries[] | "\(.key): \(.value.result)"' <<< "$NEEDS" | |
| jq -e 'all(.[]; .result == "success")' <<< "$NEEDS" > /dev/null |