Refine Travis CI build and add rustfmt/clippy
This patch modifies the Travis build pipeline to include multiple [build stages](https://docs.travis-ci.com/user/build-stages/). CI now progresses in the following steps: - First, `cargo check` is run on `stable` only. If it fails, the build is considered failed. This is so that we can fail fast for obviously botched commits. - Then, unit and doc tests are run for all targets. If any non-nightly tests fail, the build fails. - Then, integration tests with [GreenMail](http://www.icegreen.com/greenmail/) are run on Linux for all Rust targets. We can't run them on macOS because it doesn't support the Docker service. If any non-nightly tests fail, the build fails. - Then, `rustfmt` and `clippy` are both run on *beta* and on nightly. We use beta instead of stable to try to give ourselves some headroom for changes coming down the pike. The lints are only run on Linux, because the platform shouldn't matter. If any beta lints fail, the build fails. - And finally, we generate a coverage report on nightly on Linux. This can only run on nightly because tarpaulin requires nightly. It's only run on Linux, because we want to include integration tests. Note that the coverage stage has its own cache (`CACHE_NAME=coverage`) because the only thing it caches is cargo tarpaulin (the rust/cargo cache is cleaned before exit). Fixes #48.
This commit is contained in:
parent
b6e9ea080b
commit
1eab9c8375
1 changed files with 70 additions and 26 deletions
96
.travis.yml
96
.travis.yml
|
|
@ -14,38 +14,82 @@ rust:
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- rust: nightly
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
before_install:
|
before_script:
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
- if [[ "$INTEGRATION" == "true" ]]; then
|
||||||
docker pull greenmail/standalone:1.5.8 &&
|
docker pull greenmail/standalone:1.5.8 &&
|
||||||
docker run -d -e GREENMAIL_OPTS='-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose' -p 3025:3025 -p 3110:3110 -p 3143:3143 -p 3465:3465 -p 3993:3993 -p 3995:3995 greenmail/standalone:1.5.8;
|
docker run -d -e GREENMAIL_OPTS='-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose' -p 3025:3025 -p 3110:3110 -p 3143:3143 -p 3465:3465 -p 3993:3993 -p 3995:3995 greenmail/standalone:1.5.8;
|
||||||
fi
|
fi
|
||||||
script:
|
|
||||||
- cargo clean
|
|
||||||
- cargo check --all-targets
|
|
||||||
- cargo test --doc
|
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
|
||||||
cargo test --tests;
|
|
||||||
else
|
|
||||||
cargo test --lib;
|
|
||||||
fi
|
|
||||||
|
|
||||||
before_cache: |
|
# an entry in stage=test will be generated for each rust/os combination.
|
||||||
if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == nightly ]]; then
|
# each entry will run these commands.
|
||||||
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin
|
script:
|
||||||
fi
|
- cargo test --examples
|
||||||
|
- cargo test --doc
|
||||||
|
- cargo test --lib
|
||||||
|
jobs:
|
||||||
|
allow_failures:
|
||||||
|
- rust: nightly
|
||||||
|
include:
|
||||||
|
- stage: check # do a pre-screen to make sure this is even worth testing
|
||||||
|
script: cargo check --all-targets
|
||||||
|
rust: stable
|
||||||
|
os: linux
|
||||||
|
- stage: integration # make integration tests its own stage
|
||||||
|
script: cargo test --tests
|
||||||
|
env: INTEGRATION=true
|
||||||
|
rust: stable
|
||||||
|
os: linux
|
||||||
|
- script: cargo test --tests # it's a little sad we have to enumerate here
|
||||||
|
env: INTEGRATION=true
|
||||||
|
rust: beta
|
||||||
|
os: linux
|
||||||
|
- script: cargo test --tests
|
||||||
|
env: INTEGRATION=true
|
||||||
|
rust: nightly
|
||||||
|
os: linux
|
||||||
|
- stage: lint # we lint on beta to future-proof
|
||||||
|
name: "Rust: beta, rustfmt"
|
||||||
|
rust: beta
|
||||||
|
os: linux
|
||||||
|
script:
|
||||||
|
- rustup component add rustfmt-preview
|
||||||
|
- cargo fmt -v -- --check
|
||||||
|
- name: "Rust: nightly, rustfmt" # and on nightly with allow_fail
|
||||||
|
rust: nightly
|
||||||
|
os: linux
|
||||||
|
script:
|
||||||
|
- rustup component add rustfmt-preview
|
||||||
|
- cargo fmt -v -- --check
|
||||||
|
- name: "Rust: beta, clippy"
|
||||||
|
rust: beta
|
||||||
|
os: linux
|
||||||
|
script:
|
||||||
|
- rustup component add clippy-preview
|
||||||
|
- touch ./src/lib.rs && cargo clippy -- -D warnings
|
||||||
|
- name: "Rust: nightly, clippy"
|
||||||
|
rust: nightly
|
||||||
|
os: linux
|
||||||
|
script:
|
||||||
|
- rustup component add clippy-preview
|
||||||
|
- touch ./src/lib.rs && cargo clippy -- -D warnings
|
||||||
|
- stage: coverage
|
||||||
|
rust: nightly
|
||||||
|
os: linux
|
||||||
|
env: CACHE_NAME=coverage INTEGRATION=true
|
||||||
|
script:
|
||||||
|
- RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin
|
||||||
|
- cargo tarpaulin --out Xml
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
- cargo clean # ensure we don't cache build for coverage
|
||||||
|
stages:
|
||||||
|
- check
|
||||||
|
- test
|
||||||
|
- integration
|
||||||
|
- lint
|
||||||
|
- coverage
|
||||||
|
|
||||||
after_failure:
|
after_failure:
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker logs (docker ps -q); fi
|
- if [[ "$INTEGRATION" == "true" ]]; then docker logs (docker ps -q); fi
|
||||||
|
|
||||||
after_success: |
|
|
||||||
if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == nightly ]]; then
|
|
||||||
docker restart -t 1 (docker ps -q);
|
|
||||||
cargo tarpaulin --out Xml;
|
|
||||||
bash <(curl -s https://codecov.io/bash);
|
|
||||||
fi
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue