name: Build & test

on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  test:
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
        ocaml-compiler:
          - 5.2.x

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Use OCaml ${{ matrix.ocaml-compiler }}
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: ${{ matrix.ocaml-compiler }}
      - run: opam install . --deps-only --with-test --with-doc
      - run: opam exec -- dune fmt
      - run: opam exec -- dune build --profile=release
      - run: opam exec -- dune test --profile=release
