stages:
  - test

tests:
  stage: test
  image: ocaml/opam@sha256:013a26ccbaa8344b63274e335e2492c432cec1c3526b9ba888ab151abb2b4c25
  cache:
    key: $CI_COMMIT_REF_SLUG
    paths:
      - _opam
  script:
  - if [ ! -d _opam ]; then echo "no local switch in the CI cache, we setup a new switch"; opam switch create --yes --no-install . ocaml-base-compiler.4.13.1; fi
  - opam switch 4.13
  - eval $(opam env --switch=4.13 --set-switch)
  - opam switch
  - sudo apt-get update
  - sudo apt install -y protobuf-compiler
  - opam repository add remote https://opam.ocaml.org
  - opam depext --yes ocplib-endian base fmt alt-ergo.2.4.0
  - opam install . --deps-only --with-test --yes
  - make
  - make test
  tags:
    - docker
