opam: &OPAM
  language: minimal
  sudo: required
  services: docker
  install: |
    # Prepare the COQ container
    docker pull ${COQ_IMAGE}
    docker run -d -i --init --name=COQ -v ${TRAVIS_BUILD_DIR}:/home/coq/${CONTRIB_NAME} -w /home/coq/${CONTRIB_NAME} ${COQ_IMAGE}
    travis_wait 60 docker exec COQ /bin/bash --login -c "
      # This bash script is double-quoted to interpolate Travis CI env vars:
      echo \"Build triggered by ${TRAVIS_EVENT_TYPE}\"
      export PS4='+ \e[33;1m(\$0 @ line \$LINENO) \$\e[0m '
      set -ex  # -e = exit on failure; -x = trace for debug
      sudo apt-get update -y -q
      DEBIAN_FRONTEND=noninteractive sudo apt-get install -y -q --no-install-recommends zlib1g-dev libgmp-dev
      opam switch ${SWITCH} ; eval $(opam env)
      opam update -y
      opam pin add ${CONTRIB_NAME} . -y -n -k path
      opam install ${CONTRIB_NAME} -y -j ${NJOBS} --deps-only
      opam config list
      opam repo list
      opam list
      "
  script:
  - echo -e "${ANSI_YELLOW}Building ${CONTRIB_NAME}...${ANSI_RESET}" && echo -en 'travis_fold:start:script\\r'
  - |
    travis_wait 60 docker exec COQ /bin/bash --login -c "
      export PS4='+ \e[33;1m(\$0 @ line \$LINENO) \$\e[0m '
      set -ex
      sudo chown -R coq:coq /home/coq/${CONTRIB_NAME}
      opam install ${CONTRIB_NAME} -v -y -j ${NJOBS}
      "
  - docker stop COQ  # optional
  - echo -en 'travis_fold:end:script\\r'

matrix:
  include:

  # Test supported versions of Coq via OPAM
  - env:
    - COQ_IMAGE=mathcomp/mathcomp:1.10.0-coq-8.11
    - CONTRIB_NAME=coq-ceramist
    - NJOBS=4
    - SWITCH=4.07.1+flambda
    <<: *OPAM

