mirror of
https://gitlab.com/MisterBiggs/aoc_2015-rust.git
synced 2025-06-16 06:56:42 +00:00
124 lines
2.9 KiB
YAML
124 lines
2.9 KiB
YAML
image: 'rust:latest'
|
|
|
|
stages:
|
|
- check
|
|
- lint
|
|
- test
|
|
|
|
|
|
variables:
|
|
CARGO_HOME: $CI_PROJECT_DIR/cargo_cache
|
|
DEBIAN_BINARY: "debian-x86_64-${CI_COMMIT_TAG}.tar.bz2"
|
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/gitlab-clippy/${CI_COMMIT_TAG}"
|
|
|
|
.common:
|
|
interruptible: true
|
|
cache:
|
|
key:
|
|
files:
|
|
- Cargo.lock
|
|
paths:
|
|
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
|
|
- cargo_cache/bin
|
|
- cargo_cache/registry/index
|
|
- cargo_cache/registry/cache
|
|
- cargo_cache/git/db
|
|
policy: pull
|
|
|
|
.recreate_cache:
|
|
cache:
|
|
policy: pull-push
|
|
|
|
check:
|
|
stage: check
|
|
needs: []
|
|
extends:
|
|
- .common
|
|
- .recreate_cache
|
|
script:
|
|
- cargo check --workspace
|
|
|
|
fmt:
|
|
stage: lint
|
|
extends: .common
|
|
needs:
|
|
- job: check
|
|
artifacts: false
|
|
before_script:
|
|
- rustup component add rustfmt
|
|
script:
|
|
- cargo fmt --all -- --check
|
|
|
|
clippy-cli:
|
|
stage: lint
|
|
before_script:
|
|
- rustup component add clippy
|
|
- cargo install --path .
|
|
script:
|
|
- cargo clippy
|
|
after_script:
|
|
- cargo clippy --message-format=json | $CARGO_HOME/bin/gitlab-clippy > gl-code-quality-report.json
|
|
artifacts:
|
|
reports:
|
|
codequality: gl-code-quality-report.json
|
|
expire_in: 1 week
|
|
rules:
|
|
- if: '$CODE_QUALITY_DISABLED'
|
|
when: never
|
|
- if: '$CI_PIPELINE_SOURCE == "push"'
|
|
|
|
clippy-be:
|
|
stage: lint
|
|
extends: .common
|
|
needs:
|
|
- job: check
|
|
artifacts: false
|
|
before_script:
|
|
- rustup component add clippy
|
|
script:
|
|
- cargo clippy
|
|
after_script:
|
|
- cargo clippy --message-format=json &> clippy.txt || true
|
|
- curl -X POST "https://gitlab-cq-rust.herokuapp.com/clippy" --data-binary @clippy.txt --output report.json
|
|
artifacts:
|
|
reports:
|
|
codequality: report.json
|
|
expire_in: 1 week
|
|
rules:
|
|
- if: '$CODE_QUALITY_DISABLED'
|
|
when: never
|
|
- if: '$CI_PIPELINE_SOURCE == "push"'
|
|
|
|
test:
|
|
stage: test
|
|
extends: .common
|
|
needs:
|
|
- job: check
|
|
artifacts: false
|
|
before_script:
|
|
- rustup component add clippy
|
|
script:
|
|
- cargo test --all
|
|
|
|
coverage:
|
|
image: "rustdocker/rust:nightly"
|
|
stage: extras
|
|
variables:
|
|
RUSTFLAGS: "-Zinstrument-coverage"
|
|
LLVM_PROFILE_FILE: "coverage-%p-%m.profraw"
|
|
script:
|
|
- rustup component add llvm-tools-preview
|
|
- cargo test
|
|
# generate html report
|
|
- cargo install grcov
|
|
- grcov . --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing --ignore "*cargo*" -o ./coverage/
|
|
# generate cobertura report for gitlab integration
|
|
- pip3 install lcov_cobertura
|
|
- grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "*cargo*" -o coverage.lcov
|
|
- python3 /usr/local/lib/python3.5/dist-packages/lcov_cobertura.py coverage.lcov
|
|
artifacts:
|
|
reports:
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: cobertura.xml
|
|
coverage: '/^\d+.\d+% coverage/' |