# Use the (faster) container-based infrastructure, see also
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

language: go
go:
  - 1.8
  - 1.9
  - "1.10"

addons:
  apt:
    packages:
    - debian-archive-keyring
    - apt-transport-https

script:
  - /usr/lib/apt/apt-helper download-file https://people.debian.org/~stapelberg/mandoc-static/mandoc mandoc SHA256:91d1f1a6120d0fcccd7590645dcb852ad83a7ad59523e6fd026a64b1c913a102
  - /usr/lib/apt/apt-helper download-file https://people.debian.org/~stapelberg/mandoc-static/mandocd mandocd SHA256:9c30e64b5721ae223e18449d4c82b30919cf11e423de160beff4724cefcdd02e
  - chmod +x mandoc mandocd
  # Check whether files are syntactically correct.
  - "gofmt -l $(find . -name '*.go' | tr '\\n' ' ') >/dev/null"
  # Check whether files were not gofmt'ed, but only with new enough go versions
  # because formatting changed.
  - if [[ $TRAVIS_GO_VERSION =~ ^1.[^3-5] ]]; then gosrc=$(find . -name '*.go' | tr '\\n' ' '); [ $(gofmt -l $gosrc 2>&- | wc -l) -eq 0 ] || (echo 'gofmt was not run on these files:'; gofmt -l $gosrc 2>&-; false); fi
  # We intentionally do not use “go tool vet”, because vet reports issues for
  # go ≥ 1.3, but some of these (e.g. unreached code) is required for
  # compilation with go1.0.2.
  - go get github.com/Debian/debiman/...
  - PATH=$PWD:$PATH go test github.com/Debian/debiman/...
