-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
249 lines (213 loc) · 4.93 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
stages:
- devenv
- build
- test
- lint
- style
- coverage
- release
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "push"
variables:
GIT_DEPTH: 0
.nix:
image: registry.gitlab.com/cynerd/gitlab-ci-nix
tags:
- docker
cache:
key: "nix"
paths:
- ".nix-cache"
before_script:
- gitlab-ci-nix-cache-before
after_script:
- gitlab-ci-nix-cache-after
## Development environment #####################################################
devenv:
stage: devenv
extends: .nix
script:
- nix develop -c true
## Build stage #################################################################
.build:
stage: build
extends: .nix
needs: ["devenv"]
.musl:
variables:
NIXATTR: .#musl
build:
extends: .build
script:
- nix develop --quiet $NIXATTR -c meson setup build -Doptimization=plain $SETUP_ARGS
- nix develop --quiet $NIXATTR -c meson compile -C build
artifacts:
expire_in: 1 week
paths:
- 'build/'
build:musl:
extends: ["build", ".musl"]
build-werror:
extends: build
needs:
- job: build
artifacts: false
allow_failure: true
variables:
SETUP_ARGS: --werror
build-werror:musl:
extends: ["build-werror", ".musl"]
needs:
- job: build:musl
artifacts: false
nix:
stage: build
extends: .nix
script:
- nix build $NIXATTR
nix:musl:
extends: ["nix", ".musl"]
## Test stage ##################################################################
.test:
stage: test
extends: .nix
needs: ["devenv"]
tests:
extends: .test
needs: ["build"]
script:
- ulimit -n 1024 # workaround for Valgrind
- nix develop --quiet $NIXATTR -c meson setup build -Doptimization=plain -Db_coverage=true
- nix develop --quiet $NIXATTR -c meson test -C build
artifacts:
expire_in: 1 week
paths:
- 'build/'
reports:
junit: 'build/meson-logs/testlog.junit.xml'
tests:musl:
extends: ["tests", ".musl"]
needs: ["build:musl"]
allow_failure: true
valgrind:memcheck:
extends: tests
variables:
VALGRIND: memcheck
valgrind:helgrind:
extends: tests
variables:
VALGRIND: helgrind
valgrind:drd:
extends: tests
variables:
VALGRIND: drd
nix-check:
extends: .test
needs:
- job: nix
artifacts: false
script:
- nix flake check
include:
- template: Security/Secret-Detection.gitlab-ci.yml
## Lint stage ##################################################################
.linter:
stage: lint
extends: .nix
needs: ["devenv"]
allow_failure: true
.mesonlinter:
extends: .linter
script:
- nix develop --quiet -c meson setup build -Doptimization=plain
- nix develop --quiet -c meson compile -C build $COMPILE_ARG
cppcheck:
extends: .mesonlinter
variables:
COMPILE_ARG: ./cppcheck
flawfinder:
extends: .mesonlinter
variables:
COMPILE_ARG: ./flawfinder
shellcheck:
extends: .linter
script:
- git ls-files '**.sh' | xargs nix develop --quiet -c shellcheck
statix:
extends: .linter
script:
- nix develop --quiet -c statix check .
## Code Style stage ############################################################
.style:
stage: style
extends: .nix
needs: ["devenv"]
allow_failure: true
muon:
extends: .style
script:
- git ls-files '**/meson.build' meson_options.txt | nix develop --quiet -c xargs -n 1 muon fmt -c .muon_fmt.ini -i
- git diff --exit-code
clang-format:
extends: .style
script:
- git ls-files '**.[ch]' | xargs nix develop --quiet -c clang-format -i
- git diff --exit-code
shell-format:
extends: .style
script:
- git ls-files '**.sh' '**.bats' | xargs nix develop --quiet -c shfmt -w
- git diff --exit-code
nixfmt:
extends: .style
script:
- nix fmt
- git diff --exit-code
deadnix:
extends: .style
script:
- nix develop --quiet -c deadnix --fail .
editorconfig-checker:
extends: .style
script:
- nix develop --quiet -c editorconfig-checker -exclude '.nix-cache/.*'
gitlint:
extends: .style
script:
- git fetch
- nix develop --quiet -c gitlint --commits origin/master..$CI_COMMIT_SHA
## Code Coverage stage #########################################################
coverage:
stage: coverage
extends: .nix
needs:
- job: tests
artifacts: true
script:
- nix develop --quiet -c ninja -j1 -C build coverage-html coverage-xml
- mv build/meson-logs/coveragereport ./
coverage: '/lines\.\.\.\.\.\.: (\d+.\d+%)/'
artifacts:
expire_in: 1 month
expose_as: 'Code Coverage'
paths:
- 'coveragereport/'
reports:
coverage_report:
coverage_format: cobertura
path: 'build/meson-logs/coverage.xml'
## Release creation ############################################################
release:
stage: release
rules:
- if: '$CI_COMMIT_TAG'
image: "registry.gitlab.com/gitlab-org/release-cli:latest"
needs:
- job: tests
artifacts: false
before_script:
- apk update
- apk add bash py3-semver
script:
- ./.release.sh