From 45d7b8b1af30581f677347eb94de4d127f6a4383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20Roch=C3=A9?= Date: Thu, 26 Dec 2024 20:00:22 +0100 Subject: [PATCH] ci: update actions --- .github/workflows/build-test.yml | 11 +++- .github/workflows/lint.yml | 51 +++++++++++++++---- .../workflows/opam-dependency-submission.yml | 4 +- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index d490940..0445131 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -24,11 +24,10 @@ jobs: uses: actions/checkout@v4 - name: Use OCaml ${{ matrix.ocaml-version }} - uses: ocaml/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: ${{ matrix.ocaml-version }} dune-cache: true - opam-depext-flags: "--with-test" allow-prerelease-opam: true - run: opam install . --deps-only --with-test @@ -38,3 +37,11 @@ jobs: - name: run test run: opam exec -- dune runtest + + - run: opam install . --deps-only --with-test --criteria='+removed,+count[version-lag,solution]' --solver=builtin-0install + + - name: build project with lower bounds + run: opam exec -- dune build + + - name: run test with lower bounds + run: opam exec -- dune runtest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cc34b59..5fd4d7c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,6 +5,7 @@ on: - pull_request jobs: + lint-fmt: runs-on: ubuntu-latest steps: @@ -12,15 +13,49 @@ jobs: uses: actions/checkout@v4 - name: Use OCaml 5.1 - uses: ocaml/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: 5.1 dune-cache: true - opam-depext-flags: "--with-doc" allow-prerelease-opam: true - name: Lint fmt - uses: ocaml/setup-ocaml/lint-fmt@v2 + uses: ocaml/setup-ocaml/lint-fmt@v3 + + # auto fix formatting, Thanks to robur.coop for the implementation + # https://discuss.ocaml.org/t/ocamlformat-and-github-actions/15464 + lint-auto-fmt: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Use OCaml 5.1 + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: 5.1 + dune-cache: true + allow-prerelease-opam: true + + - name: Install ocamlformat + run: grep '^version' .ocamlformat | cut -d '=' -f 2 | xargs -I V opam install ocamlformat=V + + - name: Format code + run: | + git ls-files '*.ml' '*.mli' | xargs opam exec -- ocamlformat --inplace + + - name: Check for modified files + id: git-check + run: echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT + + - name: Commit and push changes + if: ${{ steps.git-check.outputs.modified == 'true' }} + run: | + git config --global user.name "Automated ocamlformat GitHub action, developed by robur.coop" + git config --global user.email "autoformat@robur.coop" + git add -A + git commit -m "formatted code" + git push lint-opam: runs-on: ubuntu-latest @@ -29,15 +64,14 @@ jobs: uses: actions/checkout@v4 - name: Use OCaml 5.1 - uses: ocaml/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: 5.1 dune-cache: true - opam-depext-flags: "--with-doc" allow-prerelease-opam: true - name: Lint opam - uses: ocaml/setup-ocaml/lint-opam@v2 + uses: ocaml/setup-ocaml/lint-opam@v3 lint-doc: runs-on: ubuntu-latest @@ -46,12 +80,11 @@ jobs: uses: actions/checkout@v4 - name: Use OCaml 5.1 - uses: ocaml/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: 5.1 dune-cache: true - opam-depext-flags: "--with-doc" allow-prerelease-opam: true - name: Lint doc - uses: ocaml/setup-ocaml/lint-doc@v2 + uses: ocaml/setup-ocaml/lint-doc@v3 diff --git a/.github/workflows/opam-dependency-submission.yml b/.github/workflows/opam-dependency-submission.yml index 72b1bec..29a3c60 100644 --- a/.github/workflows/opam-dependency-submission.yml +++ b/.github/workflows/opam-dependency-submission.yml @@ -12,11 +12,11 @@ jobs: uses: actions/checkout@v4 - name: Set-up OCaml 5.1 - uses: ocaml/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: 5.1 dune-cache: true allow-prerelease-opam: true - name: Opam Dependency Submission - uses: ocaml/setup-ocaml/analysis@v2 + uses: ocaml/setup-ocaml/analysis@v3