image: "rust:slim"
stages:
- check
- build
- test
- release
variables:
RUST_VERSION: stable
cache:
key: "$CI_PIPELINE_ID-$RUST_VERSION"
paths:
- /usr/local/cargo/registry/
- /usr/local/rustup/toolchains/
- /usr/local/rustup/update-hashes/
- target/
before_script:
- |
rustup install $RUST_VERSION
rustup default $RUST_VERSION
- |
rustc --version
cargo --version
.check-base: &check-base
stage: check
script:
- cargo check --verbose
check-stable:
<<: *check-base
check-beta:
<<: *check-base
variables:
RUST_VERSION: beta
check-nightly:
<<: *check-base
variables:
RUST_VERSION: nightly
check-msrv:
<<: *check-base
variables:
RUST_VERSION: "1.42.0"
build:
stage: build
needs: []
dependencies: []
script:
- cargo build --release --verbose
test:
stage: test
needs: []
dependencies: []
script:
- cargo test --verbose
test-coverage:
stage: test
only:
- master
- /^v(\d+\.)*\d+$/
needs: []
dependencies: []
coverage: '/^\d+.\d+% coverage/'
script:
- apt-get update
- apt-get install -y --no-install-recommends pkg-config libssl-dev
- cargo install cargo-tarpaulin -f
- cargo tarpaulin --verbose --avoid-cfg-tarpaulin --coveralls $COVERALLS_TOKEN --out Xml
artifacts:
reports:
cobertura:
- cobertura.xml
release-crate:
stage: release
dependencies: []
only:
- /^v(\d+\.)*\d+$/
script:
- echo "Creating release crate to publish on crates.io..."
- echo $CARGO_TOKEN | cargo login
- echo "Publishing crate to crates.io..."
- cargo publish --verbose --allow-dirty