From 1a677abcf439de5a9588809a1951aeb1bba97068 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Thu, 12 Mar 2026 09:52:57 +0100 Subject: [PATCH 1/3] Migrate CI to setup-dune --- .github/workflows/ci.yml | 49 ++++++++++--------- .github/workflows/deploy-doc.yml | 29 ++++++----- .github/workflows/test-deploy-doc.yml | 29 ++++++----- dune-workspace-5.4 | 13 +++++ third-party-license/README.md | 6 +-- .../setup-dune/LICENSE.md} | 4 +- 6 files changed, 77 insertions(+), 53 deletions(-) create mode 100644 dune-workspace-5.4 rename third-party-license/{ocaml/setup-ocaml/LICENSE => ocaml-dune/setup-dune/LICENSE.md} (94%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a815cf7..ab5041b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,9 @@ on: branches: - "**" # This will match pull requests targeting any branch +permissions: + contents: read + jobs: build: strategy: @@ -15,42 +18,40 @@ jobs: matrix: os: - ubuntu-latest - ocaml-compiler: - - 5.3.x + ocaml-version: + - "5.4" runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Setup OCaml - uses: ocaml/setup-ocaml@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3.4.8 - with: - ocaml-compiler: ${{ matrix.ocaml-compiler }} - opam-repositories: | - default: https://github.com/ocaml/opam-repository.git - mbarbin: https://github.com/mbarbin/opam-repository.git - # janestreet-bleeding: https://github.com/janestreet/opam-repository.git - # janestreet-bleeding-external: https://github.com/janestreet/opam-repository.git#external-packages + - name: Environment setup + run: | + echo "DUNE_WORKSPACE=$PWD/dune-workspace-${{ matrix.ocaml-version }}" >> "$GITHUB_ENV" - - name: Install dependencies - run: opam install . --deps-only --with-doc --with-test --with-dev-setup + - name: Setup Dune + uses: mbarbin/setup-dune@ae2985bcdedc6fb24e5743d6f9dace9cf262b41c # v2.0.0+patch-4 + with: + version: "3.21.0" + workspace: ${{ env.DUNE_WORKSPACE }} + cache-prefix: "main-ci-${{ matrix.ocaml-version }}" + cache-readonly: ${{ github.ref != 'refs/heads/main' }} + steps: install-dune enable-pkg lazy-update-depexts install-gpatch install-depexts - name: Build - run: opam exec -- dune build @all @lint + run: dune build @all @lint - name: Run tests - run: opam exec -- dune runtest + run: dune runtest + + - name: Build Doc + run: dune build @doc - name: Check for uncommitted changes run: git diff --exit-code - - - name: Lint opam - uses: ocaml/setup-ocaml/lint-opam@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3.4.8 - - - name: Lint fmt - uses: ocaml/setup-ocaml/lint-fmt@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3.4.8 - - - name: Lint doc - uses: ocaml/setup-ocaml/lint-doc@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3.4.8 diff --git a/.github/workflows/deploy-doc.yml b/.github/workflows/deploy-doc.yml index 11c1def..0f8b232 100644 --- a/.github/workflows/deploy-doc.yml +++ b/.github/workflows/deploy-doc.yml @@ -7,10 +7,15 @@ on: # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on +permissions: + contents: read + jobs: build: name: Build Docusaurus runs-on: ubuntu-latest + env: + OCAML_VERSION: "5.4" defaults: run: shell: bash @@ -31,21 +36,21 @@ jobs: working-directory: ./doc run: npm ci - - name: Setup OCaml - uses: ocaml/setup-ocaml@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3.4.8 - with: - ocaml-compiler: "5.3.x" - opam-repositories: | - default: https://github.com/ocaml/opam-repository.git - mbarbin: https://github.com/mbarbin/opam-repository.git -# janestreet-bleeding: https://github.com/janestreet/opam-repository.git -# janestreet-bleeding-external: https://github.com/janestreet/opam-repository.git#external-packages + - name: Environment setup + run: | + echo "DUNE_WORKSPACE=$PWD/dune-workspace-${{ env.OCAML_VERSION }}" >> "$GITHUB_ENV" - - name: Install OCaml Dependencies - run: opam install . --deps-only --with-doc + - name: Setup Dune + uses: mbarbin/setup-dune@ae2985bcdedc6fb24e5743d6f9dace9cf262b41c # v2.0.0+patch-4 + with: + version: "3.21.0" + workspace: ${{ env.DUNE_WORKSPACE }} + cache-prefix: "main-ci-${{ env.OCAML_VERSION }}" + cache-readonly: true + steps: install-dune enable-pkg lazy-update-depexts install-gpatch install-depexts - name: Build Odoc Pages - run: opam exec -- dune build @doc + run: dune build @doc - name: Copy Odoc Pages to Docusaurus Static Directory run: | diff --git a/.github/workflows/test-deploy-doc.yml b/.github/workflows/test-deploy-doc.yml index b244566..5026ede 100644 --- a/.github/workflows/test-deploy-doc.yml +++ b/.github/workflows/test-deploy-doc.yml @@ -7,10 +7,15 @@ on: # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on +permissions: + contents: read + jobs: test-deploy: name: Test deployment runs-on: ubuntu-latest + env: + OCAML_VERSION: "5.4" defaults: run: shell: bash @@ -31,21 +36,21 @@ jobs: working-directory: ./doc run: npm ci - - name: Setup OCaml - uses: ocaml/setup-ocaml@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3.4.8 - with: - ocaml-compiler: "5.3.x" - opam-repositories: | - default: https://github.com/ocaml/opam-repository.git - mbarbin: https://github.com/mbarbin/opam-repository.git -# janestreet-bleeding: https://github.com/janestreet/opam-repository.git -# janestreet-bleeding-external: https://github.com/janestreet/opam-repository.git#external-packages + - name: Environment setup + run: | + echo "DUNE_WORKSPACE=$PWD/dune-workspace-${{ env.OCAML_VERSION }}" >> "$GITHUB_ENV" - - name: Install OCaml Dependencies - run: opam install . --deps-only --with-doc + - name: Setup Dune + uses: mbarbin/setup-dune@ae2985bcdedc6fb24e5743d6f9dace9cf262b41c # v2.0.0+patch-4 + with: + version: "3.21.0" + workspace: ${{ env.DUNE_WORKSPACE }} + cache-prefix: "main-ci-${{ env.OCAML_VERSION }}" + cache-readonly: true + steps: install-dune enable-pkg lazy-update-depexts install-gpatch install-depexts - name: Build Odoc Pages - run: opam exec -- dune build @doc + run: dune build @doc - name: Copy Odoc Pages to Docusaurus Static Directory run: | diff --git a/dune-workspace-5.4 b/dune-workspace-5.4 new file mode 100644 index 0000000..24220a9 --- /dev/null +++ b/dune-workspace-5.4 @@ -0,0 +1,13 @@ +(lang dune 3.20) + +(pkg enabled) + +(lock_dir + (repositories overlay upstream mbarbin) + (constraints + (ocaml + (= 5.4.1)))) + +(repository + (name mbarbin) + (url "git+https://github.com/mbarbin/opam-repository.git")) diff --git a/third-party-license/README.md b/third-party-license/README.md index fe6a497..0ffaf96 100644 --- a/third-party-license/README.md +++ b/third-party-license/README.md @@ -40,9 +40,9 @@ See the [actions/upload-pages-artifact license](https://github.com/actions/uploa --- -## ocaml/setup-ocaml +## ocaml-dune/setup-dune -- Repository: https://github.com/ocaml/setup-ocaml +- Repository: https://github.com/ocaml-dune/setup-dune - License: MIT License -See the [ocaml/setup-ocaml license](https://github.com/ocaml/setup-ocaml/blob/master/LICENSE) for full details. +See the [ocaml-dune/setup-dune license](https://github.com/ocaml-dune/setup-dune/blob/main/LICENSE.md) for full details. diff --git a/third-party-license/ocaml/setup-ocaml/LICENSE b/third-party-license/ocaml-dune/setup-dune/LICENSE.md similarity index 94% rename from third-party-license/ocaml/setup-ocaml/LICENSE rename to third-party-license/ocaml-dune/setup-dune/LICENSE.md index 761ba84..376d252 100644 --- a/third-party-license/ocaml/setup-ocaml/LICENSE +++ b/third-party-license/ocaml-dune/setup-dune/LICENSE.md @@ -1,6 +1,6 @@ -MIT License +# MIT License -Copyright (c) 2019 Anil Madhavapeddy +Copyright (c) 2025-2026 Tarides, Samuel Hym Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 34ef7778b7483b2582f32a38edcd4dc6735cb3ec Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Thu, 12 Mar 2026 09:57:59 +0100 Subject: [PATCH 2/3] Add more build target --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab5041b..d0316a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,11 +44,11 @@ jobs: cache-readonly: ${{ github.ref != 'refs/heads/main' }} steps: install-dune enable-pkg lazy-update-depexts install-gpatch install-depexts - - name: Build - run: dune build @all @lint + - name: Build and Run Tests + run: dune build @all @runtest - - name: Run tests - run: dune runtest + - name: Lint + run: dune build @lint @fmt @unused-libs - name: Build Doc run: dune build @doc From 3df10480c4242097a613ad9d8840138fd53f69c2 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Thu, 12 Mar 2026 10:00:13 +0100 Subject: [PATCH 3/3] Add ignore-script in doc workflows --- .github/workflows/deploy-doc.yml | 2 +- .github/workflows/test-deploy-doc.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-doc.yml b/.github/workflows/deploy-doc.yml index 0f8b232..64f84eb 100644 --- a/.github/workflows/deploy-doc.yml +++ b/.github/workflows/deploy-doc.yml @@ -34,7 +34,7 @@ jobs: - name: Install Docusaurus Dependencies working-directory: ./doc - run: npm ci + run: npm ci --ignore-scripts - name: Environment setup run: | diff --git a/.github/workflows/test-deploy-doc.yml b/.github/workflows/test-deploy-doc.yml index 5026ede..dede50a 100644 --- a/.github/workflows/test-deploy-doc.yml +++ b/.github/workflows/test-deploy-doc.yml @@ -34,7 +34,7 @@ jobs: - name: Install Docusaurus Dependencies working-directory: ./doc - run: npm ci + run: npm ci --ignore-scripts - name: Environment setup run: |