summaryrefslogtreecommitdiffstats
path: root/.travis.yml
blob: 19160961e41af4d05c5037a254b22e013e1eaf1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# true because of tarpaulin dependency
sudo: true

language: rust

# only build pushes to master
# prs are build separately
# https://docs.travis-ci.com/user/pull-requests/#how-pull-requests-are-built
branches:
  only:
  - master

matrix:
  fast_finish: true
  include:
  - rust: nightly
  - rust: beta
  - rust: stable
  allow_failures:
  - rust: nightly

install: |
  # should only be necessary until rustfmt produces consistent results in stable/nightly
  # see also https://github.com/xd009642/tarpaulin/issues/150 for tarpaulin nightly dependency
  rustup toolchain install nightly
  rustup component add rustfmt-preview --toolchain nightly
  if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then
    `RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo +nightly install --force cargo-tarpaulin`
  fi

script:
- cargo +nightly fmt --all -- --check
- cargo test

# Cache `cargo install`ed tools, but don't cache the project's `target`
# directory (which ends up over-caching and filling all disk space!)
# https://levans.fr/rust_travis_cache.html
cache:
  directories:
    - /home/travis/.cargo

before_cache:
  # But don't cache the cargo registry
  - rm -rf /home/travis/.cargo/registry

addons:
  apt:
    packages:
      # required by tarpaulin code coverage tool
      - libssl-dev

after_success:
  # report coverage to coveralls
  # see https://github.com/xd009642/tarpaulin for more information
  - '[ $TRAVIS_EVENT_TYPE != "cron" ] &&
    [ $TRAVIS_RUST_VERSION = stable ] &&
    [ $TRAVIS_BRANCH = master ] &&
    [ $TRAVIS_PULL_REQUEST = false ] &&
    cargo +nightly tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID || true'
  - '[ $TRAVIS_RUST_VERSION = stable ] &&
    [ $TRAVIS_BRANCH = master ] &&
    [ $TRAVIS_PULL_REQUEST = false ]
    && cargo doc --no-deps &&
    echo "<meta http-equiv=refresh content=0;url=`echo $TRAVIS_REPO_SLUG | cut -d / -f 2`/index.html>" > target/doc/index.html &&
    pip install --user ghp-import &&
    /home/travis/.local/bin/ghp-import -n target/doc &&
    git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages &&
    echo "documented"'