-
Notifications
You must be signed in to change notification settings - Fork 6
/
.gitlab-ci.yml
227 lines (208 loc) · 6.43 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
stages:
- build
- code quality
- dependency scanning
- outdated packages
- test
- deploy
# Cache default configuration
cache: &global_cache
key: "$CI_PIPELINE_ID"
paths:
- node_modules
- public/build
- vendor
policy: pull
# Build section
Install dependencies and build assets:
image: sumocoders/cli-tools-php83:latest
script:
- COMPOSER_MEMORY_LIMIT=-1 composer install --no-scripts --no-progress
- COMPOSER_MEMORY_LIMIT=-1 composer run-script post-autoload-dump
- php bin/console importmap:install --no-interaction
- php bin/console sass:build --no-interaction
- php bin/console fos:js-routing:dump --format=json --locale=nl --target=public/build/routes/fos_js_routes.json
cache:
<<: *global_cache
policy: pull-push
stage: build
tags:
- docker
# Code Quality section
PHP_CodeSniffer - check code styling:
image: sumocoders/cli-tools-php83:latest
script:
- vendor/bin/phpcs --report-full --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-report.json
artifacts:
expire_in: 1 week
reports:
codequality: phpcs-report.json
stage: code quality
needs: [ "Install dependencies and build assets" ]
tags:
- docker
PHPStan - check for bugs:
image: sumocoders/cli-tools-php83:latest
before_script:
- bin/console cache:warmup --env=dev
script:
- vendor/bin/phpstan analyse --memory-limit=-1 --error-format=gitlab --no-progress --no-interaction > phpstan-report.json
after_script:
# Run it again so the output is visible in the job
- >
if [ $CI_JOB_STATUS != 'success' ]; then
vendor/bin/phpstan analyse --memory-limit=-1 --no-progress
fi
artifacts:
expire_in: 1 week
reports:
codequality: phpstan-report.json
stage: code quality
needs: [ "Install dependencies and build assets" ]
tags:
- docker
Twig-CS-Fixer - check code styling:
image: sumocoders/cli-tools-php83:latest
script:
- vendor/bin/twig-cs-fixer lint templates/ --report=junit > twigcs-report.xml
after_script:
# Run it again so the output is visible in the job
- >
if [ $CI_JOB_STATUS != 'success' ]; then
vendor/bin/twig-cs-fixer --no-interaction lint templates/
fi
artifacts:
expire_in: 1 week
reports:
junit: twigcs-report.xml
stage: code quality
needs: [ "Install dependencies and build assets" ]
tags:
- docker
allow_failure: true
Stylelint - check code styling:
image: sumocoders/stylelint:latest
script:
- stylelint --output-file=stylelint-report.json --custom-formatter=stylelint-formatter-gitlab-code-quality-report .
after_script:
- >
if [ $CI_JOB_STATUS != 'success' ]; then
stylelint --color .
fi
artifacts:
expire_in: 1 week
reports:
codequality: stylelint-report.json
stage: code quality
needs: [ "Install dependencies and build assets" ]
tags:
- docker
allow_failure: true
StandardJS - check code styling:
image: sumocoders/standardjs:latest
script:
- sh -c 'standard . | standard-gitlab --output-file standardjs-report.json --human-readable'
artifacts:
expire_in: 1 week
reports:
codequality: standardjs-report.json
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-php83:latest
script:
- php bin/console importmap:audit --no-interaction --ansi
stage: dependency scanning
needs: [ "Install dependencies and build assets" ]
tags:
- docker
allow_failure: true
PHP packages - composer audit:
image: sumocoders/cli-tools-php83:latest
script:
- composer audit --ansi --no-interaction
stage: dependency scanning
needs: [ "Install dependencies and build assets" ]
tags:
- docker
allow_failure: true
# Outdated packages Scanning section
NPM packages - check for outdated packages:
image: sumocoders/cli-tools-php83:latest
script:
- php bin/console importmap:outdated --no-interaction --ansi
stage: outdated packages
needs: [ "Install dependencies and build assets" ]
tags:
- docker
allow_failure: true
PHP packages - composer outdated:
image: sumocoders/cli-tools-php83:latest
script:
- composer outdated --ansi --no-interaction
stage: outdated packages
needs: [ "Install dependencies and build assets" ]
tags:
- docker
allow_failure: true
# Test section
PHPUnit - Run tests:
image: sumocoders/framework-php83:latest
services:
- mysql:5.7
before_script:
# Uncomment this if you need Chrome for PDF's
# or if you have integration tests that use Symfony Panther (https://github.com/symfony/panther)
# # install Chromium
# - apt-get --allow-releaseinfo-change update && apt-get install -y chromium
# # install Chromium Chromedriver
# - |
# curl -s -f -L -o /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE_97`/chromedriver_linux64.zip
# unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
script:
- php bin/console doctrine:migrations:migrate --env=test --no-interaction --allow-no-migration
# Uncomment this if you have fixtures that need to be loaded
# Make sure that you have installed doctrine/doctrine-fixtures-bundle
#- php bin/console doctrine:fixtures:load --env=test
- php vendor/bin/simple-phpunit --log-junit phpunit-report.xml
artifacts:
reports:
junit: phpunit-report.xml
stage: test
needs: [ "Install dependencies and build assets" ]
tags:
- docker
variables:
MYSQL_DATABASE: ci_test
MYSQL_ROOT_PASSWORD: root
DATABASE_URL: mysql://root:root@mysql:3306/ci_test?serverVersion=5.7
PANTHER_NO_SANDBOX: 1
PANTHER_WEB_SERVER_PORT: 9080
# Deploy section
Deploy - to staging:
image: sumocoders/cli-tools-php83:latest
before_script:
# Add the private SSH key to the CI environment
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- vendor/bin/dep deploy stage=staging
environment:
name: staging
url: https://$project.$client.php83.sumocoders.eu
only:
- staging
stage: deploy
tags:
- docker
variables:
USER: "CI/CD gitlab-runner"