-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
84 lines (75 loc) · 2.41 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# based on https://doc.rust-lang.org/cargo/guide/continuous-integration.html
# Setup a cache to cache job parts between jobs to ensure faster builds
cache:
- key: "$CI_JOB_NAME"
paths:
# Do not use target/ cache for now.
# - target/
- /usr/local/cargo
stages:
- cargo
# from https://gitlab.com/dlalic/gitlab-clippy#gitlab-ci-example
clippy:
stage: cargo
image: "rustdocker/rust:nightly"
before_script:
- rustup component add clippy
- cargo install gitlab_clippy
script:
- cargo clippy
after_script:
- cargo clippy --message-format=json | 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"'
test:
stage: cargo
image: "rustdocker/rust:nightly"
script:
# Install script for graphviz
- apt-get update
- apt-get install graphviz -y
# Tell Cargo to print debug output in tests
- cargo test --features svg -- --nocapture
build:
stage: cargo
image: "rustdocker/rust:nightly"
script:
- cargo build --verbose
# from https://www.collabora.com/news-and-blog/blog/2021/03/24/rust-integrating-llvm-source-base-code-coverage-with-gitlab/
coverage:
image: "rustdocker/rust:nightly"
stage: cargo
variables:
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
LLVM_PROFILE_FILE: "coverage-%p-%m.profraw"
CARGO_INCREMENTAL: "0"
script:
- apt-get update
- apt-get install graphviz -y
- rustup component add llvm-tools-preview
# do everything except doc tests since those don't work in this environment
- cargo test --lib --bins --tests --features svg
# 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
- grcov . --binary-path ./target/debug/ -s . -t cobertura --branch --ignore-not-existing --ignore "*cargo*" -o coverage.xml
artifacts:
paths:
- 'coverage'
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
formatting:
stage: cargo
image: "rustdocker/rust:nightly"
script:
- rustup component add rustfmt
- cargo fmt -- --check