name: Build_PR

on:
  pull_request:
    branches:
      - 'master'

jobs:
  build:
    env:
      #OCANREN_STATS: yes
      OCANREN_DOCS: yes
      OPAMROOT: /home/user/.opam

    runs-on: ubuntu-22.04
    container:
      image: kakadu18/ocaml:pltlab
      options: --user user

    steps:
      - name: Cancel Previous Runs
        uses: styfle/cancel-workflow-action@0.11.0
        with:
          access_token: ${{ github.token }}

      - name: Checkout code
        uses: actions/checkout@v3

      - run: opam update
      - name: Install dev version of GT
        run: |
          opam source GT --dev-repo
          opam pin add GT ./GT -y

      - name: Install dependencies for documentation
        run: opam install odoc pa_ppx --yes

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

      - name: List installed packages
        run: opam list

      - run: opam exec -- make #dune build
      - run: opam exec -- make test # dune runtest
