forked from drupal/drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
312 lines (271 loc) · 8.23 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
# cspell:ignore drupaltestbot drupaltestbotpw codequality Micheh micheh
################
# Drupal GitLabCI template.
#
# Based off GitlabCI templates project: https://git.drupalcode.org/project/gitlab_templates
# Guide: https://www.drupal.org/docs/develop/git/using-gitlab-to-contribute-to-drupal/gitlab-ci
#
# With thanks to:
# - The GitLab Acceleration Initiative participants
# - DrupalSpoons
################
################
# Includes
#
# Additional configuration can be provided through includes.
# One advantage of include files is that if they are updated upstream, the
# changes affect all pipelines using that include.
#
# Includes can be overridden by re-declaring anything provided in an include,
# here in gitlab-ci.yml.
# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values
################
include:
- project: $_GITLAB_TEMPLATES_REPO
ref: $_GITLAB_TEMPLATES_REF
file:
- '/includes/include.drupalci.variables.yml'
- '/includes/include.drupalci.workflows.yml'
################
# Variables
#
# Overriding variables
# - To override one or more of these variables, simply declare your own variables keyword.
# - Keywords declared directly in .gitlab-ci.yml take precedence over include files.
# - Documentation: https://docs.gitlab.com/ee/ci/variables/
# - Predefined variables: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
#
################
variables:
COMPOSER: composer.json
# Let composer know what self.version means.
COMPOSER_ROOT_VERSION: "${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH}-dev"
CONCURRENCY: 32
GIT_DEPTH: "3"
#############
# Stages #
#############
stages:
- 🏗️ Build
- 🪄 Lint
- 🗜️ Test
#############
# Templates #
#############
.default-job-settings: &default-job-settings-lint
interruptible: true
allow_failure: false
variables:
_TARGET_PHP: "8.2"
_TARGET_DB: "mysql-8"
image:
name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
.composer-cache: &composer-cache
key:
files:
- ./composer.json
- ./composer.lock
paths:
- ./vendor
.yarn-cache: &yarn-cache
key:
files:
- ./core/package.json
- ./core/yarn.lock
paths:
- ./core/node_modules
.pull-composer-cache: &pull-composer-cache
cache:
policy: pull
<<: *composer-cache
dependencies:
- '📦️ Composer'
.with-composer-cache: &with-composer-cache
needs:
- '📦️ Composer'
<<: *pull-composer-cache
.with-yarn-cache: &with-yarn-cache
dependencies:
- '📦️ Yarn'
needs:
- '📦️ Yarn'
cache:
policy: pull
<<: *yarn-cache
.junit-artifacts: &junit-artifacts
artifacts:
expose_as: junit
expire_in: 6 mos
paths:
- junit.xml
reports:
junit: junit.xml
################
# Stages
#
# Each job is assigned to a stage, defining the order in which the jobs are executed.
# Jobs in the same stage run in parallel.
#
# If all jobs in a stage succeed, the pipeline will proceed to the next stage.
# If any job in the stage fails, the pipeline will exit early.
################
.default-stage: &default-stage
stage: 🗜️ Test
trigger:
# Rely on the status of the child pipeline.
strategy: depend
include:
- local: .gitlab-ci/pipeline.yml
.run-on-commit: &run-on-commit
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
allow_failure: true
.run-daily: &run-daily
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_ROOT_NAMESPACE == "project"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
allow_failure: true
# Default configuration.
'PHP 8.2 MySQL 8':
<<: *default-stage
variables:
_TARGET_PHP: "8.2"
_TARGET_DB: "mysql-8"
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
# Run on commit, or manually.
'PHP 8.1 MySQL 5.7':
<<: [ *default-stage, *run-on-commit ]
variables:
_TARGET_PHP: "8.1"
_TARGET_DB: "mysql-5.7"
'PHP 8.2 PostgreSQL 14.1':
<<: [ *default-stage, *run-daily ]
variables:
_TARGET_PHP: "8.2"
_TARGET_DB: "pgsql-14.1"
'PHP 8.2 PostgreSQL 15':
<<: [ *default-stage, *run-daily ]
variables:
_TARGET_PHP: "8.2"
_TARGET_DB: "pgsql-15"
'PHP 8.2 PostgreSQL 16':
<<: [ *default-stage, *run-on-commit ]
variables:
_TARGET_PHP: "8.2"
_TARGET_DB: "pgsql-16"
# 'PHP 8.2 SQLite 3.34.0':
# <<: [ *default-stage, *run-on-commit ]
# variables:
# _TARGET_PHP: "8.2"
# _TARGET_DB: "php-$_TARGET_PHP-apache"
# Run daily, or manually.
# 'PHP 8.1 MariaDB 10.3.22':
# <<: [ *default-stage, *run-daily ]
# variables:
# _TARGET_PHP: "8.1"
# _TARGET_DB: "mariadb-10.3.22"
# 'PHP 8.1 MySQL 5.7 with updated deps':
# <<: [ *default-stage, *run-daily ]
# variables:
# _TARGET_PHP: "8.1"
# _TARGET_DB: "mysql-5.7"
'PHP 8.1 PostgreSQL 14.1':
<<: [ *default-stage, *run-daily ]
variables:
_TARGET_PHP: "8.1"
_TARGET_DB: "pgsql-14.1"
# 'PHP 8.1 SQLite 3.27.0':
# <<: [ *default-stage, *run-daily ]
# variables:
# _TARGET_PHP: "8.1"
# _TARGET_DB: "php-$_TARGET_PHP-apache"
################
# Build Jobs for linting
################
'📦️ Composer':
<<: *default-job-settings-lint
stage: 🏗️ Build
cache:
<<: *composer-cache
artifacts:
expire_in: 1 week
expose_as: 'web-vendor'
paths:
- vendor/
script:
- composer validate
- composer install
'📦️ Yarn':
<<: *default-job-settings-lint
stage: 🏗️ Build
cache:
<<: *yarn-cache
artifacts:
expire_in: 1 week
expose_as: 'yarn-vendor'
paths:
- core/node_modules/
script:
- yarn --cwd ./core install
################
# Lint Jobs
################
'🧹 PHP Coding standards (PHPCS)':
<<: [ *with-composer-cache, *junit-artifacts, *default-job-settings-lint ]
stage: 🪄 Lint
script:
- composer phpcs -- --report-full --report-summary --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-quality-report.json
artifacts:
reports:
codequality: phpcs-quality-report.json
'🧹 PHP Static Analysis (phpstan)':
<<: [ *with-composer-cache, *junit-artifacts, *default-job-settings-lint ]
stage: 🪄 Lint
script:
# Turn off apc to avoid corrupt composer cache.
- php -d apc.enabled=0 -d apc.enable_cli=0 vendor/bin/phpstan analyze --configuration=./core/phpstan.neon.dist --error-format=gitlab > phpstan-quality-report.json
artifacts:
reports:
codequality: phpstan-quality-report.json
'🧹 CSS linting (stylelint)':
<<: [ *with-yarn-cache, *junit-artifacts, *default-job-settings-lint ]
stage: 🪄 Lint
variables:
STYLELINT_CODE_QUALITY_REPORT: ../stylelint-quality-report.json
script:
- yarn run --cwd=./core lint:css --color --custom-formatter=node_modules/stylelint-formatter-gitlab
artifacts:
reports:
codequality: stylelint-quality-report.json
'🧹 Compilation check':
<<: [ *with-yarn-cache, *default-job-settings-lint ]
stage: 🪄 Lint
script:
- yarn run --cwd=./core build:css --check
- cd core && yarn run -s check:ckeditor5
'🧹 JavaScript linting (eslint)':
<<: [ *with-yarn-cache, *junit-artifacts, *default-job-settings-lint ]
stage: 🪄 Lint
variables:
ESLINT_CODE_QUALITY_REPORT: ../eslint-quality-report.json
script:
- yarn --cwd=./core run -s lint:core-js-passing --format gitlab
artifacts:
reports:
codequality: eslint-quality-report.json
'📔 Spell-checking':
<<: [ *with-yarn-cache, *default-job-settings-lint ]
stage: 🪄 Lint
script:
- export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH}
- git fetch -vn --depth=$GIT_DEPTH "${CI_MERGE_REQUEST_PROJECT_URL:-origin}" "+refs/heads/$TARGET_BRANCH:refs/heads/$TARGET_BRANCH"
- export MODIFIED=`git diff --name-only refs/heads/$TARGET_BRANCH|while read r;do echo "$CI_PROJECT_DIR/$r";done|tr "\n" " "`
- echo $MODIFIED | tr ' ' '\n' | yarn --cwd=./core run -s spellcheck:core --no-must-find-files --file-list stdin