language: generic
sudo: false

services:
  - docker

env:
  global:
    - THIS_REPO=StructTact
  matrix:
    - DOWNSTREAM=verdi-raft COQ_VERSION=coq8.7-32bit
    - DOWNSTREAM=none COQ_VERSION=coq8.8-32bit

# The "docker run" command will pull if needed.
# Running this first gives two tries in case of network lossage.
before_script:
  - timeout 5m docker pull palmskog/xenial-for-verdi-$COQ_VERSION || true

# Using travis_wait here seems to cause the job to terminate after 1 minute
# with no error (!).
# The git commands are tried twice, in case of temporary network failure.
# The fcntl line works around a bug where Travis truncates logs and fails.
script:
  - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)"
  - REMOTE_ORIGIN_URL=`git config --get remote.origin.url`
  - echo "THIS_REPO=${THIS_REPO}"
  - echo "COQ_VERSION=${COQ_VERSION}"
  - echo "DOWNSTREAM=${DOWNSTREAM}"
  - echo "TRAVIS_BRANCH=${TRAVIS_BRANCH}"
  - echo "REMOTE_ORIGIN_URL=${REMOTE_ORIGIN_URL}"
  - echo "TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE}"
  - echo "TRAVIS_COMMIT=${TRAVIS_COMMIT}"
  - echo "TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST}"
  - echo "TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH}"
  - echo "TRAVIS_PULL_REQUEST_SHA=${TRAVIS_PULL_REQUEST_SHA}"
  - echo "TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG}"
  - >-
    docker run palmskog/xenial-for-verdi-$COQ_VERSION /bin/bash -c "true &&
       if [ $TRAVIS_EVENT_TYPE = pull_request ] ; then
         git clone --quiet --depth 9 $REMOTE_ORIGIN_URL $THIS_REPO || git clone --quiet --depth 9 $REMOTE_ORIGIN_URL $THIS_REPO
         cd $THIS_REPO
         git fetch origin +refs/pull/$TRAVIS_PULL_REQUEST/merge
         git checkout -qf $TRAVIS_PULL_REQUEST_SHA
         git config user.email noone@cares.com
         git config user.name Noone Cares
         git remote add theupstream https://github.com/$TRAVIS_REPO_SLUG.git
         git pull --depth 9 theupstream $TRAVIS_BRANCH || git pull --depth 9 theupstream $TRAVIS_BRANCH
       else
         git clone --quiet --depth 9 -b $TRAVIS_BRANCH $REMOTE_ORIGIN_URL $THIS_REPO || git clone --quiet --depth 9 -b $TRAVIS_BRANCH $REMOTE_ORIGIN_URL $THIS_REPO
         cd $THIS_REPO
         git checkout -qf $TRAVIS_COMMIT
       fi &&
       ./.travis-ci.sh $DOWNSTREAM"

git:
  depth: 9

notifications:
  slack:
    secure: AaJDFxx98pMhb4ZaA2uqZ/itjmKCu/Ig33NxHxdn3GZotzAds/cwwFWq2aEpiyfQCSn7UOiEjMYNTHaI/HUnt71CJbOMNGqGCVG/09Jh4UYxKT3Gy7MPq5ClTUQ2577bNVY46yMJ9nSoByXvG0caDMICO72amiQZfQdOiXO5IwcjjhXlv2LswQjOFSd8OPI7tkt5g5FoWHCJbbb1QjhuXoeyVKcrXgmS12kwg0w6O1kVL6uTk9NnOt6g/D6aaPGR1xi9nJHcOu4T0UPwnbzfJMR0z4lAFNz/jmHuAwiyJj7HQAGl7uFDU5oh0SwVv0JAE31Nraez8v4wrQu0vEwq+oNYjbmNoVG/G/ow9KnZier7Ti8D920R9nsCsKKVMm8rYYFVuM7Fd3OQiDpQ2Dn3+s2MAl0tqLpYV6VHsu3WxLR6+VljoPL4Mica23ehAtSVZspok0BLSVSTNTnwF+nqVE/C1kJPc35WZGcaY/sx5qCuU06WDvj8dgkOwkjVf3Ar0o8XvpEaHe1dQSjwfygo/9g0Cy6RwXitQ/ojPUOIF2CCTgGdJ7/woiuIy50/8MTsbw3P1RrT9Gh/PsTB5l2KzqgKEcAYGlvIeRqG8DfLEviYaLJjVnPw0yJ1E4mY5amKxHwbxG9TGYPrVz44fhOkx3ASwxmvGGu3Hcn9AuhdGjE=
