name: Main workflow

on:
  - pull_request
  - push

jobs:
  build:
    strategy:
      matrix:
        ocaml-version:
          - 4.14.x
          - 5.0.x

    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Use OCaml ${{ matrix.ocaml-version }}
        uses: ocaml/setup-ocaml@v2
        with:
          ocaml-compiler: ${{ matrix.ocaml-version }}
          cache-prefix: v2

      - run: opam install . --deps-only --with-doc --with-test

      - run: opam exec -- dune build

      - run: opam exec -- dune runtest

      - run: opam install ocamlformat=0.26.1

      - run: opam exec -- dune build @fmt
