-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
150 lines (120 loc) · 3.29 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# This file is based on the Rust GitLab template.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/rust/tags/
image: "rust:latest" # latest stable release
#image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
# Create directories for Cargo and print versions
before_script:
- mkdir -p target
- mkdir -p cargo
- du -hs target
- du -hs cargo
- rustup -V
- rustup component add rustfmt
- rustup component add clippy
- rustc --version && cargo --version # Print version info for debugging
# Use cargo to build and test the project
# stolen from: https://willroe.me/2016/08/16/fast-rust-builds-on-gitlab-ci.html
variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo
RUST_BACKTRACE: full
RUSTFLAGS: -D warnings
# Basic pipeline example: https://docs.gitlab.com/ee/ci/pipelines/pipeline_architectures.html
stages:
- build
- test
- deploy
# Global cache for cargo home and target directory for all jobs
cache:
key:
files:
- Cargo.lock
paths:
- target/
- cargo/
# Build stage
build:
stage: build
script:
- cargo build --verbose --jobs 1 --release # Don't parallelize to make errors more readable
build-nightly:
stage: build
when: manual # needs to be triggered manually
image: rustlang/rust:nightly
script:
- cargo build --verbose
- cargo test --verbose
allow_failure: true
# Test stage
test:
stage: test
needs: [ build ]
script:
- cargo test --verbose --jobs 1 --release # Don't parallelize to make errors more readable
lint:
stage: test
needs: [ build ]
script:
- cargo clippy --verbose --jobs 1 --all-features -- -D clippy::all
rustfmt:
stage: test
needs: [ build ]
script:
- cargo fmt -- --check
allow_failure: true
.coverage:
stage: test
needs: test
image: kcov/kcov
script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends jq
- kcov target/coverage target/release/$CI_PROJECT_NAME
- jq '.percent_covered | tonumber' target/coverage/$CI_PROJECT_NAME.*/coverage.json
coverage: '/\d+\.\d+/'
# Deploy stage
# Packaging for crates.io does not work because `libtapasco` is a git dependency
.package:
stage: deploy
needs: [ test ]
script:
- cargo publish --verbose --dry-run # just a dry run to check packaging
artifacts:
paths:
- target/package/
expose_as: 'package'
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
# Currently defunct due to non-existing login, remove dot when it is ready
.publish:
stage: deploy
needs: [ test ]
only:
refs:
- main # run only on main branch
when: manual # needs to be triggered manually
script:
- cargo publish --verbose
allow_failure: true
doc:
stage: deploy
needs: [ test ]
only:
refs:
- main
script:
- cargo doc --no-deps
artifacts:
paths:
- target/doc
expose_as: 'documentation'
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
# Also build image from Dockerfile automatically
#include:
# - local: '.docker.gitlab-ci.yml'
# Enable license scanning - nice feature but needs GitLab Ultimate..
# So sad, it stays here anyway because it could be a community feature in the future
#include:
# - template: License-Scanning.gitlab-ci.yml
#license_scanning:
# variables:
# CI_DEBUG_TRACE: "true"