language: rust
sudo: false

rust: nightly

env:
  global:
    - FMT_VERSION=nightly-2018-11-07
    - CLIPPY_VERSION=$FMT_VERSION
    - DOCS_RS_VERSION=nightly-2018-10-20 # https://github.com/rust-lang-nursery/docs.rs/blob/c695234cdf5b63f9727063e54edb5d980b535135/Vagrantfile#L50
    - RUST_TOOLCHAINS="1.20.0 stable beta $DOCS_RS_VERSION $CLIPPY_VERSION nightly"

before_script: |
  ( set -o errexit;set -o pipefail; set -o xtrace;set -o nounset;
    for RUST_TOOLCHAIN in $RUST_TOOLCHAINS; do travis_retry rustup toolchain add $RUST_TOOLCHAIN; done
    travis_retry rustup component add rustfmt-preview --toolchain $FMT_VERSION
    travis_retry rustup component add clippy-preview --toolchain $CLIPPY_VERSION
  )

script: |
  ( set -o errexit;set -o pipefail; set -o xtrace;set -o nounset;
    for RUST_TOOLCHAIN in $RUST_TOOLCHAINS; do (
      cargo +$RUST_TOOLCHAIN test --all-features
    ); done
    cargo +$FMT_VERSION fmt -- --check
    cargo +$CLIPPY_VERSION clippy --all-targets --all-features -- -D warnings
    cargo +$DOCS_RS_VERSION doc --no-deps --all-features
  )

notifications:
  email: false
