forked from shopware5/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
276 lines (250 loc) · 8.04 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
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: "/certs"
MYSQL_ROOT_PASSWORD: app
MYSQL_USER: app
MYSQL_PASSWORD: app
MYSQL_DATABASE: shopware
GIT_STRATEGY: clone
GIT_DEPTH: 1
ARTIFACTS_ROOT: "$CI_PROJECT_DIR/build/artifacts"
DB_USER: "app"
DB_PASSWORD: "app"
DB_HOST: "mysql"
DB_PORT: 3306
DB_NAME: shopware
SW_HOST: "localhost"
SW_BASE_PATH: ""
SELENIUM_HOST: selenium
ELASTICSEARCH_HOST: elasticsearch
SMTP_HOST: smtp
# Include the default gitlab rules template for "MergeRequest-Pipelines".
# This makes pipelines run for the default branch, tags, and all types of merge
# request pipelines.
# @see https://docs.gitlab.com/ee/ci/yaml/workflow.html#workflowrules-templates
include:
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
.composer-cache: &composer-cache
key:
files:
- 'composer.lock'
# - 'recovery/common/composer.lock' TODO - SW-26745: Needs to be considered again, but GitLab only allows two files
- 'vendor-bin/cs-fixer/composer.lock'
paths:
- 'vendor/'
- 'recovery/common/vendor/'
- 'vendor-bin/'
- '.htaccess'
- '.make.install.composer-dependencies'
policy: pull-push
.npm-cache: &npm-cache
key:
files:
- 'themes/package-lock.json'
- 'themes/Frontend/Responsive/package-lock.json'
paths:
- 'themes/node_modules/'
- 'themes/Frontend/Responsive/node_modules/'
- '.make.install.npm-dependencies'
policy: pull-push
stages:
- Prepare Files
- Static analysis
- PHPUnit
- End-to-end testing
- Build Image
default:
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:7.4
tags:
- t3.medium
interruptible: true
# Stage: Prepare Files
Install Required PHP Files:
stage: Prepare Files
script:
- make .make.install.composer-dependencies
cache:
<<: *composer-cache
Install Required JS Files:
image: node:alpine
stage: Prepare Files
before_script:
- apk add --no-cache make bash
script:
- make .make.install.npm-dependencies
cache:
<<: *npm-cache
PHP analyze:
tags:
- m5.large
cache:
- <<: *composer-cache
policy: pull
stage: Static analysis
before_script:
- make init
script:
- make check-code
services:
- name: mysql:5.7
alias: mysql
JavaScript checks:
cache:
- <<: *npm-cache
policy: pull
stage: Static analysis
image: node:alpine
before_script:
- apk add bash make
script:
- make check-js-code
- make test-jest
.phpunit_base:
cache:
- <<: *composer-cache
policy: pull
before_script: # TODO: (SW-26726) Remove this and see if anything breaks.
- sed -i -e "s;__ROOT__;$CI_PROJECT_DIR;g" /etc/nginx/sites-enabled/shopware.conf
- /usr/bin/supervisord -c /etc/supervisord.conf &>/dev/null &
# https://gitlab.com/gitlab-org/gitlab-foss/-/issues/27921#note_38132416
- eval export DB_USER DB_PASSWORD DB_HOST DB_PORT DB_NAME SW_HOST SW_BASE_PATH ELASTICSEARCH_HOST
stage: PHPUnit
services:
- name: mysql:5.7
alias: mysql
script:
- make test-phpunit
artifacts:
expire_in: 1 week
reports:
junit: ${ARTIFACTS_ROOT}/test-log.xml
.phpunit_es_base:
extends: .phpunit_base
script:
- make init
- make test-phpunit-elasticsearch
artifacts:
expire_in: 1 week
reports:
junit: ${ARTIFACTS_ROOT}/test-log.xml
Code Coverage:
extends: .phpunit_base
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:8.0
script:
- make test-phpunit-coverage-cobertura
artifacts:
paths:
- ${ARTIFACTS_ROOT}/*
expire_in: 1 week
reports:
coverage_report:
coverage_format: cobertura
path: ${ARTIFACTS_ROOT}/*.cobertura.xml
parallel:
matrix:
- TESTSUITE: ['unit', 'functional']
Code Coverage Statistic:
extends: .phpunit_base
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:8.0
variables:
TESTSUITE: 'all'
script:
- make test-phpunit-coverage-statistic | sed -E -n '1,/^\s*Lines:\s*([0-9]+(\.[0-9]+)?)%/ p' # See: https://gitlab.shopware.com/shopware/6/product/platform/-/blob/trunk/.gitlab/stages/02-unit.yml#L92
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
PHP 7.4:
extends: .phpunit_base
PHP 8.1:
extends: .phpunit_base
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:8.1
PHP 8.2:
extends: .phpunit_base
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:8.2
MySQL 8.0:
extends: .phpunit_base
services:
- name: mysql:8.0
alias: mysql
command: [ "mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--default-authentication-plugin=mysql_native_password", "--sql-require-primary-key=ON" ]
MariaDB 10.1:
extends: .phpunit_base
services:
- name: mariadb:10.1
alias: mysql
MariaDB 10.4:
extends: .phpunit_base
services:
- name: mariadb:10.4
alias: mysql
MariaDB 10.5:
extends: .phpunit_base
services:
- name: mariadb:10.5
alias: mysql
Elasticsearch 7:
extends: .phpunit_es_base
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:7.4
services:
- name: mysql:8.0
alias: mysql
command: [ "mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--default-authentication-plugin=mysql_native_password" ]
- name: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
.mink_base:
tags:
- m5.large
extends: .phpunit_base
stage: End-to-end testing
artifacts:
when: always
expire_in: 1 week
paths:
- ${ARTIFACTS_ROOT}/**
- build/logs/**
reports:
junit: ${ARTIFACTS_ROOT}/mink/*.xml
script:
- apk add --no-cache sudo
- export SW_HOST=$(hostname -i)
- make init
- make prepare-mink
- chown -R www-data:www-data .
- sudo -E -u www-data vendor/bin/behat -vv --config=tests/Mink/behat.yml --format=pretty --out=std --format=junit --out=${ARTIFACTS_ROOT}/mink --tags ${MINK_TAG}
services:
- name: selenium/standalone-chrome:94.0
alias: selenium
- name: mailhog/mailhog
alias: smtp
- name: mysql:8.0
alias: mysql
command: [ "mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--default-authentication-plugin=mysql_native_password" ]
Mink:
extends: .mink_base
image: "gitlab.shopware.com:5005/shopware/5/product/image/continuous:$IMAGE_TAG"
parallel:
matrix:
- IMAGE_TAG: [ '7.4', '8.2' ]
MINK_TAG: [ 'account', 'checkout1', 'checkout2', 'detail', 'listing', 'note', 'sitemap', 'misc', 'backend' ]
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $IMAGE_TAG != "7.4"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: manual
allow_failure: true
Build Image:
stage: Build Image
inherit:
variables: false
variables:
UPSTREAM_REF_NAME: '$CI_COMMIT_REF_NAME'
UPSTREAM_COMMIT_SHA: '$CI_COMMIT_SHORT_SHA'
UPSTREAM_CI_COMMIT_REF_PROTECTED: '$CI_COMMIT_REF_PROTECTED'
PHP_VERSION: '8.0'
COMPOSER_VERSION: '2'
NODE_VERSION: '18'
trigger:
project: shopware/5/product/image
branch: master
rules:
- if: '$CI_COMMIT_REF_PROTECTED == "true"'