-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
216 lines (193 loc) · 5.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
stages:
- test
- docs
- release
# No longer create push pipeline if MR is created (avoiding duplicate pipelines).
# See https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
# Default image for all builds is the generic controller project build image containing most
# external dependencies, including rust, clippy, cargo, and C library dependencies.
# Adding additional dependencies to this image (by opening a MR in the respective project)
# is strongly preferred to installing dependencies in before_script.
image: gitlab.informatik.uni-bremen.de:5005/namib-master/ci-docker-images/controller:generic
# Cache definition for the cargo package cache.
# Pull only by default - the fetch-deps job will update the cache for each build.
.pkg_cache: &pkg_cache
key: "pkgcache-$CI_COMMIT_REF_SLUG"
paths:
- .cargo/
policy: pull
.on_default_branch:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
.on_tags:
- if: '$CI_COMMIT_TAG'
.allow_manual_run:
- when: manual
allow_failure: true
.on_ready_mrs:
- if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^(?:WIP|Draft):.*/'
default:
# Use the shared linux Kubernetes cluster for most tasks.
tags:
- linux
- docker
- kubernetes
# We don't want to keep most artifacts around for longer.
artifacts:
expire_in: 1 week
# retry: 2
cache:
- *pkg_cache
fetch-deps:
stage: .pre
cache:
- key: !reference [.pkg_cache, key]
paths: !reference [.pkg_cache, paths]
policy: pull-push
script:
- cargo fetch
- cargo generate-lockfile
artifacts:
paths:
- Cargo.lock # Because this is a library, we need the Cargo.lock to maintain consistency
.test_base:
stage: test
needs:
- job: fetch-deps
artifacts: true
script:
- cargo test --locked -p $PKG_NAME --no-fail-fast -- -Z unstable-options --format json --report-time | tee results.json
- cat results.json | cargo2junit > target/$PKG_NAME-test-results.xml
artifacts:
reports:
junit: target/$PKG_NAME-test-results.xml
sys:test:
extends: .test_base
variables:
PKG_NAME: tinydtls-sys
.coverage_base:
stage: test
allow_failure: true
needs:
- job: fetch-deps
artifacts: true
rules:
- !reference [.on_tags]
- !reference [.on_default_branch]
- !reference [.on_ready_mrs]
- !reference [.allow_manual_run]
script:
- cargo tarpaulin --locked --no-fail-fast -p $PKG_NAME --out Xml
- mv cobertura.xml target/$PKG_NAME-coverage.xml
artifacts:
reports:
cobertura: target/$PKG_NAME-coverage.xml
sys:coverage:
extends: .coverage_base
variables:
PKG_NAME: tinydtls-sys
.lint_base:
stage: test
allow_failure: true
needs:
- job: fetch-deps
artifacts: true
script:
- cargo clippy --locked -p $PKG_NAME -- -D warnings
after_script:
- cargo clippy --locked -p $PKG_NAME --message-format=json | gitlab-clippy > target/$PKG_NAME-code-quality.json
artifacts:
reports:
codequality: target/$PKG_NAME-code-quality.json
sys:lint:
extends: .lint_base
variables:
PKG_NAME: tinydtls-sys
docs:
stage: docs
allow_failure: true
needs:
- job: fetch-deps
artifacts: true
rules:
- !reference [.on_default_branch]
- !reference [.on_tags]
- !reference [.allow_manual_run]
script:
- cargo doc --locked --workspace --no-deps
artifacts:
paths:
- target/doc
pages:
stage: release
needs:
- docs
rules:
- !reference [.on_default_branch]
script:
- mv target/doc public
- echo '<meta http-equiv="refresh" content="0;" url="tinydtls_sys/index.html">' > public/index.html
artifacts:
paths:
- public
.publish_cratesio_base:
stage: release
needs:
- job: sys:test
artifacts: false
- job: docs
artifacts: false
- job: fetch-deps
artifacts: true
rules:
- if: "$CI_COMMIT_TAG"
when: manual
- when: never
script:
- cargo --locked -p $PKG_NAME publish
sys:publish_cratesio:
extends: .publish_cratesio_base
variables:
PKG_NAME: tinydtls-sys
gen-lsif:
stage: .post
allow_failure: true
cache: []
needs:
- job: fetch-deps # We need the Cargo.lock file in order to run the build script (which can't be disabled)
artifacts: true
script:
- rust-analyzer -v lsif . > tinydtls-rs.lsif
artifacts:
reports:
lsif: tinydtls-rs.lsif
variables:
# Kubernetes Runner Resource Limiting
KUBERNETES_CPU_REQUEST: 4
# KUBERNETES_CPU_LIMIT: 5
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 4Gi
# KUBERNETES_SERVICE_CPU_REQUEST: 400m
# KUBERNETES_SERVICE_CPU_LIMIT: 400m
# KUBERNETES_SERVICE_MEMORY_REQUEST: 1Gi
# KUBERNETES_SERVICE_MEMORY_LIMIT: 1Gi
# ---
# Cargo Settings
# Number of concurrent build threads to start.
# Note: Removing this value somehow causes jobs to randomly get stuck during compilation.
CARGO_BUILD_JOBS: 4
# Location of Cargo home. Needed for caching.
CARGO_HOME: "${CI_PROJECT_DIR}/.cargo"
# ---
# Fastzip
# Use faster cache and artifact compression method.
# Increases speed **drastically**, so don't remove it unless it causes issues.
FF_USE_FASTZIP: "true"
CACHE_COMPRESSION_LEVEL: fast
GIT_SUBMODULE_STRATEGY: recursive
TRANSFER_METER_FREQUENCY: 5s