.cargo_build_template: &cargo_build
stage: build
script:
- cargo build --release --all
artifacts:
paths:
- target/release
.cargo_test_template: &cargo_test
stage: test
script:
- cargo test --verbose --jobs 1 --all
.rustfmt_template: &rustfmt
stage: test
before_script:
- rustup component add rustfmt-preview
script:
- cargo fmt --all -- --write-mode=diff
allow_failure: true
cache:
untracked: true
stages:
- build
- test
- docs
- deploy
build:stable:cargo:
cache:
key: stable
image: rust
<<: *cargo_build
build:beta:cargo:
image: registry.gitlab.com/iron-oxide/docker/rust-codecov:beta
cache:
key: beta
<<: *cargo_build
build:nightly:cargo:
image: registry.gitlab.com/iron-oxide/docker/rust-codecov:nightly
cache:
key: nightly
<<: *cargo_build
test:stable:cargo:
image: registry.gitlab.com/iron-oxide/docker/rust-codecov:stable
cache:
key: stable
policy: pull
<<: *cargo_test
after_script:
- |
for file in target/debug/qwerty-*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done &&
bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN &&
echo "Uploaded code coverage"
test:beta:cargo:
image: registry.gitlab.com/iron-oxide/docker/rust-codecov:beta
cache:
key: beta
policy: pull
<<: *cargo_test
test:nightly:cargo:
image: registry.gitlab.com/iron-oxide/docker/rust-codecov:nightly
cache:
key: nightly
policy: pull
<<: *cargo_test
rustfmt:stable:cargo:
image: registry.gitlab.com/iron-oxide/docker/rust-codecov:stable
cache:
key: stable
policy: pull
<<: *rustfmt
rustfmt:beta:cargo:
image: registry.gitlab.com/iron-oxide/docker/rust-codecov:beta
cache:
key: beta
policy: pull
<<: *rustfmt
rustfmt:nightly:cargo:
image: registry.gitlab.com/iron-oxide/docker/rust-codecov:nightly
cache:
key: nightly
policy: pull
<<: *rustfmt
pages:
image: rust
stage: docs
cache:
key: stable
policy: pull
script:
- cargo doc --all --no-deps
- rm -rf public
- mkdir public
- cp -R target/doc/* public
artifacts:
paths:
- public
only:
- master
- tags
release:
image: rust
stage: deploy
cache: {}
script:
- cargo login $CRATES_IO_TOKEN
- cargo publish
only:
- tags