name: Build, test, lint
on:
  - push
  - pull_request

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout tree
        uses: actions/checkout@v4

      - name: Set-up OCaml
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: "5.1.1"
      - run: opam install . --deps-only --with-test
      - run: opam exec -- dune build
      - run: opam exec -- dune runtest
      - run: opam exec -- dune exec bin/ring.exe -- build

      - name: Upload the build artifact
        uses: actions/upload-artifact@v4
        with:
          name: ring.exe
          path: _build/default/bin/ring.exe

  lint-doc:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout tree
        uses: actions/checkout@v4

      - name: Set-up OCaml
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: "5.1.1"

      - uses: ocaml/setup-ocaml/lint-doc@v3

  lint-fmt:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout tree
        uses: actions/checkout@v4

      - name: Set-up OCaml
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: "5.1.1"

      - uses: ocaml/setup-ocaml/lint-fmt@v3
