setup-ocaml 3.6.0; fix static linking #9820
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, 11.0_release] | |
| # See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| - "v[0-9]+.[0-9]+.[0-9]+-*" | |
| pull_request: | |
| branches: [master, 11.0_release] | |
| 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 | |
| - 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 | |
| - os: macos-15-intel # x64 | |
| ocaml_compiler: 5.3.0 | |
| upload_binaries: true | |
| node-target: darwin-x64 | |
| rust-target: x86_64-apple-darwin | |
| - os: macos-15 # ARM | |
| ocaml_compiler: 5.3.0 | |
| upload_binaries: true | |
| node-target: darwin-arm64 | |
| rust-target: aarch64-apple-darwin | |
| - 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" | |
| # 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 | |
| runs-on: ${{matrix.os}} | |
| env: | |
| # When changing the setup-ocaml version, also adjust it in the setup step further below. | |
| SETUP_OCAML_VERSION: 3.6.0 # OPAM <2.6.0 | |
| 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@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| cache: yarn | |
| node-version-file: .nvmrc | |
| - name: Install npm packages | |
| run: yarn install | |
| - name: Install dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| uses: awalsh128/cache-apt-pkgs-action@v1.4.3 | |
| with: | |
| # https://github.com/ocaml/setup-ocaml/blob/2f57267f071bc8547dfcb9433ff21d44fffef190/packages/setup-ocaml/src/unix.ts#L48 | |
| # plus OPAM wants cmake | |
| packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync cmake | |
| version: v4 | |
| - name: Restore rewatch build cache | |
| id: rewatch-build-cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: rewatch/target | |
| key: rewatch-build-v3-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }} | |
| - name: Determine Rust toolchain version | |
| id: rust-version | |
| shell: bash | |
| run: | | |
| version="$(awk -F '"' '/^rust-version[[:space:]]*=/ { print $2; exit }' rewatch/Cargo.toml)" | |
| if [ -z "$version" ]; then | |
| echo "rust-version missing in rewatch/Cargo.toml" >&2 | |
| exit 1 | |
| fi | |
| echo "version=${version}" >> "$GITHUB_OUTPUT" | |
| - name: Install rust toolchain | |
| if: steps.rewatch-build-cache.outputs.cache-hit != 'true' | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ steps.rust-version.outputs.version }} | |
| targets: ${{ matrix.rust-target }} | |
| components: clippy, rustfmt | |
| - 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: Lint rewatch | |
| if: steps.rewatch-build-cache.outputs.cache-hit != 'true' | |
| run: | | |
| cargo clippy --manifest-path rewatch/Cargo.toml --all-targets --all-features | |
| - name: Run rewatch unit tests | |
| if: steps.rewatch-build-cache.outputs.cache-hit != 'true' | |
| run: | | |
| cargo test --manifest-path rewatch/Cargo.toml --release | |
| - name: Copy rewatch binary | |
| run: | | |
| cp rewatch/target/${{ matrix.rust-target }}/release/rescript${{ matrix.exe-suffix }} rescript | |
| mkdir -p rewatch/target/release | |
| cp rewatch/target/${{ matrix.rust-target }}/release/rescript${{ matrix.exe-suffix }} rewatch/target/release | |
| ./scripts/copyExes.js --rewatch | |
| shell: bash | |
| # matrix.ocaml_compiler may contain commas | |
| - name: Get OPAM cache key | |
| shell: bash | |
| run: echo "opam_cache_key=opam-env-v8-${{ matrix.os }}-${{ env.SETUP_OCAML_VERSION }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" | sed 's/,/-/g' >> $GITHUB_ENV | |
| - name: Restore OPAM environment | |
| id: cache-opam-env | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: | | |
| ${{ runner.tool_cache }}/opam | |
| ~/.opam | |
| _opam | |
| .opam-path | |
| C:\cygwin | |
| C:\.opam | |
| key: ${{ env.opam_cache_key }} | |
| - name: Use OCaml ${{matrix.ocaml_compiler}} | |
| uses: ocaml/setup-ocaml@v3.6.0 | |
| if: steps.cache-opam-env.outputs.cache-hit != 'true' | |
| with: | |
| ocaml-compiler: ${{matrix.ocaml_compiler}} | |
| opam-pin: false | |
| - name: Get OPAM executable path | |
| if: steps.cache-opam-env.outputs.cache-hit != 'true' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const opamPath = await io.which('opam', true); | |
| console.log('opam executable found: %s', opamPath); | |
| const fs = require('fs/promises'); | |
| await fs.writeFile('.opam-path', opamPath, 'utf-8'); | |
| console.log('stored path to .opam-path'); | |
| - name: Install OPAM dependencies | |
| if: steps.cache-opam-env.outputs.cache-hit != 'true' | |
| run: opam install . --deps-only --with-test | |
| - name: Cache OPAM environment | |
| if: steps.cache-opam-env.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: | | |
| ${{ runner.tool_cache }}/opam | |
| ~/.opam | |
| _opam | |
| .opam-path | |
| C:\cygwin | |
| C:\.opam | |
| key: ${{ env.opam_cache_key }} | |
| - name: Use cached OPAM environment | |
| if: steps.cache-opam-env.outputs.cache-hit == 'true' | |
| run: | | |
| # https://github.com/ocaml/setup-ocaml/blob/v3.6.0/packages/setup-ocaml/src/installer.ts | |
| echo "OPAMCOLOR=always" >> "$GITHUB_ENV" | |
| echo "OPAMCONFIRMLEVEL=unsafe-yes" >> "$GITHUB_ENV" | |
| echo "OPAMDOWNLOADJOBS=4" >> "$GITHUB_ENV" | |
| echo "OPAMERRLOGLEN=0" >> "$GITHUB_ENV" | |
| echo "OPAMEXTERNALSOLVER=builtin-0install" >> "$GITHUB_ENV" | |
| echo "OPAMPRECISETRACKING=1" >> "$GITHUB_ENV" | |
| echo "OPAMRETRIES=10" >> "$GITHUB_ENV" | |
| echo "OPAMSOLVERTIMEOUT=600" >> "$GITHUB_ENV" | |
| echo "OPAMYES=1" >> "$GITHUB_ENV" | |
| echo "CLICOLOR_FORCE=1" >> "$GITHUB_ENV" | |
| if [[ "$RUNNER_OS" != "Windows" ]]; then | |
| echo "OPAMROOT=$HOME/.opam" >> "$GITHUB_ENV" | |
| else | |
| echo "OPAMROOT=C:\\.opam" >> "$GITHUB_ENV" | |
| fi | |
| OPAM_PATH="$(cat .opam-path)" | |
| chmod +x "$OPAM_PATH" | |
| dirname "$OPAM_PATH" >> "$GITHUB_PATH" | |
| if [[ "$RUNNER_OS" == "Windows" ]]; then | |
| fsutil behavior query SymlinkEvaluation | |
| fsutil behavior set symlinkEvaluation R2L:1 R2R:1 | |
| fsutil behavior query SymlinkEvaluation | |
| echo "HOME=$USERPROFILE" >> "$GITHUB_ENV" | |
| echo "MSYS=winsymlinks:native" >> "$GITHUB_ENV" | |
| echo "CYGWIN=winsymlinks:native" >> "$GITHUB_ENV" | |
| echo "BASH_ENV=C:\\cygwin\\bash_env" >> "$GITHUB_ENV" | |
| fi | |
| shell: bash | |
| - name: Compiler build state key | |
| id: compiler-build-state-key | |
| shell: bash | |
| run: | | |
| echo "value=compiler-build-state-v1-${{ matrix.os }}-${{ env.SETUP_OCAML_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@v5 | |
| with: | |
| path: | | |
| C:\.cache\dune | |
| ~/.cache/dune | |
| _build | |
| key: ${{ steps.compiler-build-state-key.outputs.value }} | |
| - name: Build compiler | |
| if: runner.os != 'Linux' | |
| run: opam exec -- dune build --display quiet --profile release | |
| - name: Build compiler (Linux static) | |
| if: runner.os == 'Linux' | |
| run: opam exec -- dune build --display quiet --profile static | |
| - 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@v5 | |
| 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: Diagnose Linux binary linkage | |
| if: runner.os == 'Linux' | |
| run: | | |
| opam list | |
| opam exec -- ocamlopt -config | grep -E '^(native_c|mkexe|mkshared|system):' || true | |
| opam exec -- which musl-gcc || true | |
| for f in packages/@rescript/${{ matrix.node-target }}/bin/*.exe; do | |
| echo "== $f ==" | |
| file "$f" | |
| ldd "$f" || true | |
| readelf -d "$f" || true | |
| done | |
| shell: bash | |
| - 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: Snapshot Linux binaries after tests | |
| if: runner.os == 'Linux' | |
| run: | | |
| echo "== package bin hashes ==" | |
| sha256sum packages/@rescript/${{ matrix.node-target }}/bin/*.exe | |
| echo "== package bin file types ==" | |
| file packages/@rescript/${{ matrix.node-target }}/bin/*.exe | |
| echo "== dune install bin hashes ==" | |
| sha256sum _build/install/default/bin/bsc _build/install/default/bin/rescript-editor-analysis _build/install/default/bin/rescript-tools rewatch/target/release/rescript | |
| echo "== dune install bin file types ==" | |
| file _build/install/default/bin/bsc _build/install/default/bin/rescript-editor-analysis _build/install/default/bin/rescript-tools rewatch/target/release/rescript | |
| echo "== package vs dune install ==" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/bsc.exe _build/install/default/bin/bsc && echo "bsc: same" || echo "bsc: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript-editor-analysis.exe _build/install/default/bin/rescript-editor-analysis && echo "rescript-editor-analysis: same" || echo "rescript-editor-analysis: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript-tools.exe _build/install/default/bin/rescript-tools && echo "rescript-tools: same" || echo "rescript-tools: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe rewatch/target/release/rescript && echo "rescript: same" || echo "rescript: different" | |
| shell: bash | |
| - 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: Snapshot Linux binaries after rewatch tests | |
| if: runner.os == 'Linux' | |
| run: | | |
| echo "== package bin hashes ==" | |
| sha256sum packages/@rescript/${{ matrix.node-target }}/bin/*.exe | |
| echo "== package bin file types ==" | |
| file packages/@rescript/${{ matrix.node-target }}/bin/*.exe | |
| echo "== dune install bin hashes ==" | |
| sha256sum _build/install/default/bin/bsc _build/install/default/bin/rescript-editor-analysis _build/install/default/bin/rescript-tools rewatch/target/release/rescript | |
| echo "== dune install bin file types ==" | |
| file _build/install/default/bin/bsc _build/install/default/bin/rescript-editor-analysis _build/install/default/bin/rescript-tools rewatch/target/release/rescript | |
| echo "== package vs dune install ==" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/bsc.exe _build/install/default/bin/bsc && echo "bsc: same" || echo "bsc: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript-editor-analysis.exe _build/install/default/bin/rescript-editor-analysis && echo "rescript-editor-analysis: same" || echo "rescript-editor-analysis: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript-tools.exe _build/install/default/bin/rescript-tools && echo "rescript-tools: same" || echo "rescript-tools: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe rewatch/target/release/rescript && echo "rescript: same" || echo "rescript: different" | |
| 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@v5 | |
| # 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@v5 | |
| # with: | |
| # path: ./tests/benchmark-cache | |
| # key: syntax-benchmark-v1 | |
| - name: Build playground compiler | |
| if: matrix.build_playground | |
| run: opam exec -- make playground DUNE_PROFILE=static | |
| - name: Snapshot Linux binaries after playground build | |
| if: runner.os == 'Linux' && matrix.build_playground | |
| run: | | |
| echo "== package bin hashes ==" | |
| sha256sum packages/@rescript/${{ matrix.node-target }}/bin/*.exe | |
| echo "== package bin file types ==" | |
| file packages/@rescript/${{ matrix.node-target }}/bin/*.exe | |
| echo "== dune install bin hashes ==" | |
| sha256sum _build/install/default/bin/bsc _build/install/default/bin/rescript-editor-analysis _build/install/default/bin/rescript-tools rewatch/target/release/rescript | |
| echo "== dune install bin file types ==" | |
| file _build/install/default/bin/bsc _build/install/default/bin/rescript-editor-analysis _build/install/default/bin/rescript-tools rewatch/target/release/rescript | |
| echo "== package vs dune install ==" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/bsc.exe _build/install/default/bin/bsc && echo "bsc: same" || echo "bsc: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript-editor-analysis.exe _build/install/default/bin/rescript-editor-analysis && echo "rescript-editor-analysis: same" || echo "rescript-editor-analysis: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript-tools.exe _build/install/default/bin/rescript-tools && echo "rescript-tools: same" || echo "rescript-tools: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe rewatch/target/release/rescript && echo "rescript: same" || echo "rescript: different" | |
| shell: bash | |
| - name: Test playground compiler | |
| if: matrix.build_playground | |
| run: yarn workspace playground test | |
| - name: Setup Rclone | |
| if: ${{ matrix.build_playground && startsWith(github.ref, 'refs/tags/v') }} | |
| uses: cometkim/rclone-actions/setup-rclone@main | |
| - name: Configure Rclone remote | |
| if: ${{ matrix.build_playground && startsWith(github.ref, 'refs/tags/v') }} | |
| uses: cometkim/rclone-actions/configure-remote/s3-provider@main | |
| with: | |
| name: rescript | |
| provider: Cloudflare | |
| endpoint: https://${{ vars.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com | |
| access-key-id: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} | |
| secret-access-key: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} | |
| acl: private | |
| - name: Upload playground compiler to CDN | |
| if: ${{ matrix.build_playground && startsWith(github.ref, 'refs/tags/v') }} | |
| run: yarn workspace playground upload-bundle | |
| - name: Diagnose Linux binaries before upload | |
| if: runner.os == 'Linux' | |
| run: | | |
| for f in packages/@rescript/${{ matrix.node-target }}/bin/*.exe; do | |
| echo "== pre-upload $f ==" | |
| sha256sum "$f" || true | |
| file "$f" | |
| ldd "$f" || true | |
| readelf -d "$f" || true | |
| done | |
| shell: bash | |
| - 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: Snapshot Linux binaries after API docs | |
| if: runner.os == 'Linux' && matrix.generate_api_docs | |
| run: | | |
| echo "== package bin hashes ==" | |
| sha256sum packages/@rescript/${{ matrix.node-target }}/bin/*.exe | |
| echo "== package bin file types ==" | |
| file packages/@rescript/${{ matrix.node-target }}/bin/*.exe | |
| echo "== dune install bin hashes ==" | |
| sha256sum _build/install/default/bin/bsc _build/install/default/bin/rescript-editor-analysis _build/install/default/bin/rescript-tools rewatch/target/release/rescript | |
| echo "== dune install bin file types ==" | |
| file _build/install/default/bin/bsc _build/install/default/bin/rescript-editor-analysis _build/install/default/bin/rescript-tools rewatch/target/release/rescript | |
| echo "== package vs dune install ==" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/bsc.exe _build/install/default/bin/bsc && echo "bsc: same" || echo "bsc: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript-editor-analysis.exe _build/install/default/bin/rescript-editor-analysis && echo "rescript-editor-analysis: same" || echo "rescript-editor-analysis: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript-tools.exe _build/install/default/bin/rescript-tools && echo "rescript-tools: same" || echo "rescript-tools: different" | |
| cmp -s packages/@rescript/${{ matrix.node-target }}/bin/rescript.exe rewatch/target/release/rescript && echo "rescript: same" || echo "rescript: different" | |
| shell: bash | |
| - 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/ | |
| 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@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| cache: yarn | |
| node-version-file: .nvmrc | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: "@(binaries-*|lib-ocaml)" | |
| - name: Diagnose downloaded Linux artifacts | |
| run: | | |
| for f in binaries-linux-arm64/*.exe; do | |
| echo "== downloaded $f ==" | |
| file "$f" | |
| ldd "$f" || true | |
| readelf -d "$f" || true | |
| done | |
| shell: bash | |
| - name: Move artifacts into packages | |
| run: .github/workflows/moveArtifacts.sh | |
| shell: bash | |
| - name: Diagnose moved Linux package binaries | |
| run: | | |
| for f in packages/@rescript/linux-arm64/bin/*.exe; do | |
| echo "== moved $f ==" | |
| file "$f" | |
| ldd "$f" || true | |
| readelf -d "$f" || true | |
| done | |
| 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@v6 | |
| with: | |
| repository: rescript-lang/rescript-lang.org | |
| ssh-key: ${{ secrets.RESCRIPT_LANG_ORG_DEPLOY_KEY }} | |
| - 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@v6 | |
| with: | |
| cache: yarn | |
| node-version-file: .node-version | |
| - name: Build website | |
| if: steps.diffcheck.outputs.clean == 'false' | |
| run: | | |
| yarn | |
| yarn build | |
| - name: Commit and push | |
| if: ${{ steps.diffcheck.outputs.clean == 'false' && startsWith(github.ref, 'refs/tags/v') }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions@rescript-lang.org" | |
| git add data/api | |
| git commit -m "Update API docs for $GITHUB_REF_NAME" | |
| git push | |
| test-devcontainer: | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - 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@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| 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@v5 | |
| with: | |
| version: 10 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| # Run integration tests with the oldest supported node version. | |
| node-version: 20 | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - 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 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@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| 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 | |
| publish: | |
| permissions: | |
| id-token: write | |
| needs: | |
| - test-installation-npm | |
| - test-installation-pnpm | |
| - test-integration-rewatch | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| cache: yarn | |
| node-version-file: .nvmrc | |
| registry-url: https://registry.npmjs.org # Needed to make auth work for publishing | |
| - 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: Publish packages on npm with tag "ci" | |
| run: | | |
| yarn workspaces foreach -W --no-private \ | |
| npm publish --provenance --tolerate-republish --tag ci | |
| - name: Update Website Playground | |
| run: curl -X POST "${{ secrets.CLOUDFLARE_PAGES_DEPLOYMENT_HOOK }}" | |
| shell: bash |