forked from DOMjudge/domjudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
317 lines (292 loc) · 6.7 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
variables:
SAST_EXCLUDED_ANALYZERS: "brakeman,kubesec,mobsf,nodejs-scan,pmd-apex,security-code-scan,sobelow,spotbugs"
stages:
- visual_pre
- integration
- compare
- accessibility
- test
- unit
- style
include:
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml
- template: SAST.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
.retry_config: &retry_job
retry:
max: 0 #Max is 2, set when gitlab is flacky
when:
- always
.retry_config: &matrix_retry_job
retry:
max: 2 #Max is 2, set when gitlab is flacky
when:
- always
.clean_ordering: &clean_ordering
needs: []
# These seem to be overwritten when a job actually specifies these
.retry_time: &tiny_job
<<: *clean_ordering
timeout: 3m
.retry_time: &short_job
<<: *clean_ordering
timeout: 7m
.retry_time: &normal_job
<<: *clean_ordering
timeout: 15m
.retry_time: &long_job
<<: *clean_ordering
timeout: 30m
# Due to the retry this will be worst case 3*timeout before the job fails
webstandard_check_role:
<<: *matrix_retry_job
<<: *short_job
parallel:
matrix:
- ROLE: public
TEST: [w3cval,WCAG2A,WCAG2AA]
- ROLE: team
TEST: [w3cval,WCAG2A,WCAG2AA]
- ROLE: balloon
TEST: [w3cval,WCAG2A,WCAG2AA]
- ROLE: jury
TEST: [w3cval]
stage: accessibility
image: domjudge/gitlabci:2.1
services:
- mariadb
variables:
MYSQL_ROOT_PASSWORD: password
script:
- ./gitlab/webstandard.sh
artifacts:
when: always
paths:
- public
- w3chtmlpublic.json
- w3ccsspublic.json
- w3csvgpublic.json
check syntax:
<<: *retry_job
<<: *short_job
stage: style
image: domjudge/gitlabci:2.1
script:
- ./gitlab/syntax.sh
check static codecov:
<<: *retry_job
<<: *tiny_job
stage: style
script:
- curl -s https://codecov.io/bash > newcodecov
- diff newcodecov gitlab/uploadcodecov.sh
run unit tests:
<<: *retry_job
<<: *normal_job
stage: unit
image: domjudge/gitlabci:2.1
# Disabled for now as it drastically speeds up running unit tests and we don't use it yet
# before_script:
# - apt-get update -yqq
# - apt-get install php-xdebug -yqq
services:
- mariadb
variables:
MYSQL_ROOT_PASSWORD: password
script:
- ./gitlab/unit-tests.sh
artifacts:
when: always
paths:
- unit-tests.xml
- coverage-html
- deprecation.txt
reports:
junit:
- unit-tests.xml
cache:
key: unit-tests
paths:
- lib/vendor/
visual_pr:
<<: *retry_job
<<: *long_job
stage: visual_pre
image: domjudge/gitlabci:2.1
services:
- mariadb
variables:
MYSQL_ROOT_PASSWORD: password
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
parallel:
matrix:
- URL: team
ROLE: [jury,admin,team]
- URL: public
ROLE: [none,jury,admin,balloon,team]
script:
- git fetch
- git config --global user.email "[email protected]"
- git config --global user.name "Rebase against main"
- echo -e "section_start:`date +%s`:diff[collapsed=true]\r\e[0K'Git Diff'"
- git diff origin/main
- echo -e "section_end:`date +%s`:diff\r\e[0K"
- git pull origin main
- ./gitlab/visualpr.sh pr
artifacts:
when: always
paths:
- screenshotspr
- html
- wget.log
visual_main:
<<: *retry_job
<<: *long_job
stage: visual_pre
image: domjudge/gitlabci:2.1
services:
- mariadb
variables:
MYSQL_ROOT_PASSWORD: password
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
parallel:
matrix:
- URL: team
ROLE: [jury,admin,team]
- URL: public
ROLE: [none,jury,admin,balloon,team]
script:
- git fetch
- git checkout -B main origin/main
- git branch --set-upstream-to=origin/main main
- git pull
- git checkout $CI_COMMIT_SHA -- gitlab/visualpr.sh # Always compare with the same tests
- git checkout $CI_COMMIT_SHA -- gitlab/default-nginx
- git checkout $CI_COMMIT_SHA -- gitlab/visualreg.css
- ./gitlab/visualpr.sh main
artifacts:
when: always
paths:
- screenshotsmain
- html
visual_compare:
<<: *retry_job
<<: *normal_job
stage: compare
image: domjudge/gitlabci:2.1
needs:
- visual_pr
- visual_main
script:
- ./gitlab/visualcompare.sh
artifacts:
when: always
paths:
- visualchanges
- addrem.log
.job_template: &job_integration
<<: *retry_job
<<: *long_job
stage: integration
image: domjudge/gitlabci:2.1
variables:
MYSQL_ROOT_PASSWORD: password
MARIADB_PORT_3306_TCP_ADDR: sqlserver
script:
- timeout --signal=15 40m ./gitlab/integration.sh
artifacts:
when: always
paths:
- gitlabartifacts
cache:
key: integration
paths:
- lib/vendor/
# TODO: Re-enable when gitlab is in better shape...
# cache:
# key: integration
# paths:
# - chroot
integration_mysql:
<<: *job_integration
services:
- name: mysql
command: ["--default-authentication-plugin=mysql_native_password"]
alias: sqlserver
integration_mariadb:
<<: *job_integration
services:
- name: mariadb
alias: sqlserver
phpcs_compatibility:
<<: *tiny_job
stage: style
image: pipelinecomponents/php-codesniffer:latest
before_script:
- set -euxo pipefail
- export PS4='[$?] $'
parallel:
matrix:
- PHPVERSION: ["7.2","7.3","7.4"]
script:
- >
phpcs -s -p --colors
--standard=PHPCompatibility
--extensions=php
--runtime-set testVersion $PHPVERSION
lib/lib.*.php
etc
judge
webapp/src
webapp/tests
webapp/public
webapp/config
# This finds different problems from codesniffer
php linter:
<<: *tiny_job
stage: style
image: pipelinecomponents/php-linter:latest
script:
- ls
- >
parallel-lint --colors
lib/lib.*.php
etc
judge
webapp/src
webapp/tests
webapp/public
webapp/config
php-cs-fixer:
<<: *tiny_job
stage: style
image:
name: cytopia/php-cs-fixer
entrypoint: [""]
artifacts:
when: always
reports:
codequality: code-quality.json
paths:
- code_quality_debug.json
script:
- /usr/bin/php-cs-fixer fix --format=gitlab --dry-run --diff . > code-quality.json || true
- cp code-quality.json code_quality_debug.json
codespell:
<<: *tiny_job
stage: style
image: domjudge/gitlabci:2.1
script:
- pip install codespell
- python3 gitlab/codespell_gitlab.py
detect dump:
<<: *tiny_job
stage: style
image: domjudge/gitlabci:2.1
script:
- OUT=$(grep -H -n --exclude-dir=.git -r "dump(" ./ | grep -v "js/ace\|Yaml::dump")
- echo $OUT
- exit $(($(wc -l <<< $OUT)-1))