forked from forkcms/forkcms
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
308 lines (291 loc) · 11.5 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
stages:
- build
- code quality
- dependency scanning
- test
# Cache default configuration
cache: &global_cache
key: "$CI_PIPELINE_ID"
paths:
- app/config/parameters.yml
- bin
- css
- fonts
- images
- js
- node_modules
- vendor
policy: pull
.mysql_configuration: &mysql_configuration
MYSQL_DATABASE: ci_test
MYSQL_ROOT_PASSWORD: root
.before_script_test_template: &before_script_test_configuration
# disable Xdebug and Blackfire extensions
- |
mkdir /usr/local/etc/php/conf.d/disabled
mv /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/disabled/docker-php-ext-xdebug.ini
mv /usr/local/etc/php/conf.d/blackfire.ini /usr/local/etc/php/conf.d/disabled/blackfire.ini
# import test DB
- mysql -h mysql -u root -proot ci_test < tests/data/test_db.sql
# make sure bundle.js exists
- touch src/Frontend/Core/Js/bundle.js
# generate correct parameters.yml
- php bin/generate-parameters-gitlab
- cp app/config/parameters.yml.gitlab app/config/parameters.yml
- sed -i -E 's/database\.name:(.*)ci$/database.name:\1ci_test/g' app/config/parameters.yml
# create assets for test env
- php bin/console --no-interaction assetic:dump .
# clear cache
- php bin/console --no-interaction forkcms:cache:clear
# Build section
Install dependencies and build assets:
image: sumocoders/cli-tools-php74:latest
script:
- COMPOSER_MEMORY_LIMIT=-1 composer install --no-scripts --no-progress
- cp app/config/parameters.yml.dist app/config/parameters.yml
- nvm install
- nvm use
- nvm exec npm install --no-progress
cache:
<<: *global_cache
policy: pull-push
stage: build
tags:
- docker
# Code Quality section
PHP_CodeSniffer - check code styling:
image: sumocoders/fork-php74:latest
services:
- mysql:5.7
before_script:
- *before_script_test_configuration
script:
- php bin/phpcs --report-full --report-junit=phpcs-report.xml
artifacts:
expire_in: 1 week
reports:
junit: phpcs-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker
variables:
<<: *mysql_configuration
allow_failure: true
PHPStan - check for bugs:
image: sumocoders/fork-php74:latest
services:
- mysql:5.7
before_script:
- *before_script_test_configuration
- php bin/console cache:warmup --no-interaction --env=dev
script:
- php bin/phpstan analyze --memory-limit=-1 --error-format=junit --no-progress > phpstan-report.xml
after_script:
# Run it again so the output is visible in the job
- php bin/phpstan analyze --memory-limit=-1 --no-progress
artifacts:
expire_in: 1 week
reports:
junit: phpstan-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker
variables:
<<: *mysql_configuration
allow_failure: true
StandardJS - check code styling:
image: sumocoders/cli-tools-php74:latest
script:
- php bin/convert-to-junit-xml convert:standardjs "$(nvm exec --silent node_modules/.bin/standard)" > standardjs-report.xml
after_script:
# Run it again so the output is visible in the job
- nvm exec node_modules/.bin/standard
artifacts:
expire_in: 1 week
reports:
junit: standardjs-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true
TODOs - check for unfinished code:
image: sumocoders/cli-tools-php74:latest
script:
- >
php bin/convert-to-junit-xml convert:grep "$(
find .
-path "./.git/*" -prune -o
-path "./.github/*" -prune -o
-path "./bin/*" -prune -o
-path "./css/*" -prune -o
-path "./docs/*" -prune -o
-path "./fonts/*" -prune -o
-path "./images/*" -prune -o
-path "./js/*" -prune -o
-path "./node_modules/*" -prune -o
-path "./src/Backend/Cache/*" -prune -o
-path "./src/Backend/Core/Js/backend.js" -prune -o
-path "./src/Backend/Core/Layout/Sass/*" -prune -o
-path "./src/Backend/Core/Engine/DataGrid.php" -prune -o
-path "./src/Backend/Modules/Location/Layout/Templates/Index.html.twig" -prune -o
-path "./src/Backend/Modules/MediaGalleries/*" -prune -o
-path "./src/Backend/Modules/FormBuilder/*" -prune -o
-path "./src/Backend/Modules/Tags/DataFixtures/LoadTagsModulesTags.php" -prune -o
-path "./src/Backend/Modules/MediaLibrary/*" -prune -o
-path "./src/Backend/Modules/ContentBlocks/*" -prune -o
-path "./src/Backend/Core/Js/ckeditor/*" -prune -o
-path "./src/Backend/Core/Js/ckfinder/*" -prune -o
-path "./src/Backend/Core/Js/jquery/*" -prune -o
-path "./src/Backend/DependencyInjection/BackendExtension.php" -prune -o
-path "./src/Backend/Modules/*/Installer/*" -prune -o
-path "./src/Common/*" -prune -o
-path "./src/ForkCMS/*" -prune -o
-path "./src/Frontend/Cache/*" -prune -o
-path "./src/Frontend/Core/Layout/Css/screen.css" -prune -o
-path "./src/Frontend/Modules/MediaLibrary/*" -prune -o
-path "./src/Frontend/Themes/Bootstrap/*" -prune -o
-path "./src/Frontend/Themes/Fork/*" -prune -o
-path "./src/Frontend/Themes/Custom/Core/Js/bundle.js" -prune -o
-path "./tests/*" -prune -o
-path "./var/*" -prune -o
-path "./vendor/*" -prune -o
-path "./.gitlab-ci.yml" -prune -o
-path "./autoload.php" -prune -o
-path "./CHANGELOG.md" -prune -o
-path "./unresolved-todos-report.xml" -prune -o
-not -type d
-exec grep -niH -E "\b(FIXME|TODO)\b" {} \;
)" > unresolved-todos-report.xml
after_script:
- >
find .
-path "./.git/*" -prune -o
-path "./.github/*" -prune -o
-path "./bin/*" -prune -o
-path "./css/*" -prune -o
-path "./docs/*" -prune -o
-path "./fonts/*" -prune -o
-path "./images/*" -prune -o
-path "./js/*" -prune -o
-path "./node_modules/*" -prune -o
-path "./src/Backend/Cache/*" -prune -o
-path "./src/Backend/Core/Js/backend.js" -prune -o
-path "./src/Backend/Core/Layout/Sass/*" -prune -o
-path "./src/Backend/Core/Engine/DataGrid.php" -prune -o
-path "./src/Backend/Modules/Location/Layout/Templates/Index.html.twig" -prune -o
-path "./src/Backend/Modules/MediaGalleries/*" -prune -o
-path "./src/Backend/Modules/FormBuilder/*" -prune -o
-path "./src/Backend/Modules/Tags/DataFixtures/LoadTagsModulesTags.php" -prune -o
-path "./src/Backend/Modules/MediaLibrary/*" -prune -o
-path "./src/Backend/Modules/ContentBlocks/*" -prune -o
-path "./src/Backend/Core/Js/ckeditor/*" -prune -o
-path "./src/Backend/Core/Js/ckfinder/*" -prune -o
-path "./src/Backend/Core/Js/jquery/*" -prune -o
-path "./src/Backend/DependencyInjection/BackendExtension.php" -prune -o
-path "./src/Backend/Modules/*/Installer/*" -prune -o
-path "./src/Common/*" -prune -o
-path "./src/ForkCMS/*" -prune -o
-path "./src/Frontend/Cache/*" -prune -o
-path "./src/Frontend/Core/Layout/Css/screen.css" -prune -o
-path "./src/Frontend/Modules/MediaLibrary/*" -prune -o
-path "./src/Frontend/Themes/Bootstrap/*" -prune -o
-path "./src/Frontend/Themes/Fork/*" -prune -o
-path "./src/Frontend/Themes/Custom/Core/Js/bundle.js" -prune -o
-path "./tests/*" -prune -o
-path "./var/*" -prune -o
-path "./vendor/*" -prune -o
-path "./.gitlab-ci.yml" -prune -o
-path "./autoload.php" -prune -o
-path "./CHANGELOG.md" -prune -o
-path "./unresolved-todos-report.xml" -prune -o
-not -type d
-exec grep -niH -E "\b(FIXME|TODO)\b" {} \;
artifacts:
expire_in: 1 week
reports:
junit:
unresolved-todos-report.xml
stage: code quality
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true
# Dependency Scanning section
NPM packages - check for vulnerabilities:
image: sumocoders/cli-tools-php74:latest
script:
- php bin/convert-to-junit-xml convert:npm-audit "$(nvm exec --silent npm audit --production --json)" > npm-audit-report.xml
after_script:
# Run it again so the output is visible in the job output
- nvm exec npm audit --production
artifacts:
expire_in: 1 week
reports:
junit: npm-audit-report.xml
stage: dependency scanning
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true
PHP packages - check for vulnerabilities:
image: sumocoders/cli-tools-php74:latest
before_script:
- PHP_SC_VERSION=$(curl -s "https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/;s/^v//')
- curl -LSs https://github.com/fabpot/local-php-security-checker/releases/download/v${PHP_SC_VERSION}/local-php-security-checker_${PHP_SC_VERSION}_linux_amd64 > ./php-security-checker
- chmod +x ./php-security-checker
script:
- php bin/convert-to-junit-xml convert:sensiolabs-security-check "$(./php-security-checker --format=json)" > security-checker-report.xml
after_script:
# Run it again so the output is visible in the job output
- ./php-security-checker
artifacts:
expire_in: 1 week
reports:
junit: security-checker-report.xml
stage: dependency scanning
needs: ["Install dependencies and build assets"]
tags:
- docker
allow_failure: true
# Test section
PHPUnit - Run functional tests:
image: sumocoders/fork-php74:latest
services:
- mysql:5.7
before_script:
- *before_script_test_configuration
- sed -i -E 's/database\.name:(.*)ci_test$/database.name:\1ci/g' app/config/parameters.yml
- cat app/config/parameters.yml
script:
- php bin/simple-phpunit --testsuite=functional --log-junit phpunit-functional-report.xml
artifacts:
reports:
junit: phpunit-functional-report.xml
stage: test
needs: ["Install dependencies and build assets"]
tags:
- docker
variables:
<<: *mysql_configuration
PHPUnit - Run unit tests:
image: sumocoders/fork-php74:latest
services:
- mysql:5.7
before_script:
- *before_script_test_configuration
- sed -i -E 's/database\.name:(.*)ci_test$/database.name:\1ci/g' app/config/parameters.yml
- cat app/config/parameters.yml
script:
- php bin/simple-phpunit --testsuite=unit --log-junit phpunit-unit-report.xml
artifacts:
reports:
junit: phpunit-unit-report.xml
stage: test
needs: ["Install dependencies and build assets"]
tags:
- docker
variables:
<<: *mysql_configuration