name: Main workflow

on:
  - pull_request
  - push

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Use OCaml 4.11.0
        uses: avsm/setup-ocaml@v1
        with:
          ocaml-version: 4.11.0
      - name: "Install ocamlformat.0.15.0"
        run: opam install ocamlformat.0.15.0
      - name: "Check lint"
        run: opam exec -- ocamlformat --check src/*.ml*

  build:
    strategy:
      fail-fast: false
      matrix:
        os:
          - macos-latest
          - ubuntu-latest
          - windows-latest
        ocaml-version:
          - 4.11.1
          - 4.10.2
          - 4.09.1
          - 4.08.1
          - 4.07.1
          - 4.06.1
          - 4.05.0
          - 4.04.2
          - 4.03.0

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

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

      - name: Use OCaml ${{ matrix.ocaml-version }}
        uses: avsm/setup-ocaml@v1
        with:
          ocaml-version: ${{ matrix.ocaml-version }}

      - run: opam pin add cordova.dev . --no-action

      - run: opam depext cordova --yes --with-doc --with-test

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

      - run: opam exec -- dune build

      - run: opam exec -- dune runtest
