name: CI

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

jobs:
  build:
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest]        
        ocaml-compiler:
          - ocaml-base-compiler.4.12.1
          - ocaml-base-compiler.4.13.1
          - ocaml-variants.4.12.0+domains

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

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

      - name: Use OCaml ${{ matrix.ocaml-compiler }}
        uses: ocaml/setup-ocaml@v2
        with:
          ocaml-compiler: ${{ matrix.ocaml-compiler }}
          opam-repositories: |
            multicore: https://github.com/ocaml-multicore/multicore-opam.git
            default: https://github.com/ocaml/opam-repository.git

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

      - run: opam exec -- dune b lib

      - run: opam exec -- dune runtest
