set -x
set -e
cargo_audit() {
cargo install cargo-audit --force
cargo audit
}
clippy() {
rustup component add clippy
cargo clippy --all-targets -- --deny warnings
}
fmt_check() {
rustup component add rustfmt
cargo fmt -- --check
}
build() {
cargo build --release
}
run_tests() {
export RUST_BACKTRACE=1
case $TRAVIS_OS_NAME in
windows)
export PATH=/c/Python37:${PATH}
;;
linux)
export DMENV_NO_VENV_STDLIB=1
;;
esac
if [[ "${TRAVIS_RUST_VERSION}" == "nightly" ]] && [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin
cargo tarpaulin --ignore-tests --out Xml
bash <(curl -s https://codecov.io/bash)
else
cargo test --release
fi
}
main() {
if [[ "${TRAVIS_OS_NAME}" == "linux" ]] && [[ "${TRAVIS_RUST_VERSION}" == "stable" ]]; then
fmt_check
cargo_audit
clippy
fi
build
run_tests
}
main