forked from shopware/production
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
342 lines (322 loc) · 13.9 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_HOST: "tcp://docker:2375"
# shopware 6
WEB_DOCUMENT_ROOT: '$CI_PROJECT_DIR/public'
MYSQL_ROOT_PASSWORD: root
DEFAULT_PLATFORM_BRANCH: master
LOG_STDOUT: $CI_PROJECT_DIR/stdout.log
CYPRESS_PERCY_USAGE: $CYPRESS_PERCY_USAGE
PERCY_TOKEN: $PERCY_TOKEN
PERCY_BUILD_NAME: '000'
stages:
- build
- analyze
- test
- prepare-release
- release
include:
- local: .gitlab-ci/release_jobs.yml
- local: .gitlab-ci/test_base.yml
- local: .gitlab-ci/integration_jobs.yml
Build Test Package:
stage: build
tags:
- release
only:
refs:
- schedules
image: debian:buster-slim
services:
- name: docker:18.09.7-dind
alias: docker
variables:
GIT_STRATEGY: none
SPLIT_REPOS: "Administration Storefront Core Elasticsearch Recovery"
SPLITSH: /opt/splitsh-lite
cache:
key: "package_$CI_COMMIT_BRANCH"
paths:
- .platform
- .composer
- .apt
- .npm
policy: pull-push
before_script:
- apt-get update
- DEB_PACKAGES="git jq composer curl docker.io build-essential nodejs php-ctype php-curl php-dom php-fileinfo php-gd php-iconv php-intl php-json php-mbstring php-pdo php-mysql php-simplexml php-xml php-zip"
# setup caching
- rm /etc/apt/apt.conf.d/docker-clean
- cp -a /var/cache/apt .apt
- echo "Dir::Cache::Archives ${PWD}/.apt;" >> /etc/apt/apt.conf.d/cache.conf
- apt-get install -y --download-only curl && apt-get install -y curl
- curl -sL https://deb.nodesource.com/setup_12.x | bash -
- apt-get install -y --download-only $DEB_PACKAGES && apt-get install -y $DEB_PACKAGES
- npm config set cache $PWD/.npm
# we need to do the checkout to have correct permissions. See: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1736
- umask 0022
- git init .
- git remote add origin ${CI_REPOSITORY_URL}
- git fetch origin $CI_COMMIT_BRANCH
- git fetch --tags
- git checkout -f -q ${CI_COMMIT_SHA}
- composer config --global cache-dir $PWD/.composer
# install helper tools
- composer install --working-dir=.gitlab-ci/tools
- '[[ -x $SPLITSH ]] || (curl -sL https://github.com/splitsh/lite/releases/download/v1.0.1/lite_linux_amd64.tar.gz | tar -xz ./splitsh-lite && mv splitsh-lite $SPLITSH)'
- chmod +x $SPLITSH
- HASH_CHECK_LINE="ec46c5a409422bf55b26f7de1faab67c2320362934947f984872b3aedc4a9d99 $SPLITSH"
- echo $HASH_CHECK_LINE | sha256sum -c
script:
# clone platform if it's not cached. We use caching to speed up the split
- export TAG=${TAG:-$(.gitlab-ci/tools/console release:show-next-tag)}
- '[[ -d .platform/ ]] || git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/6/product/platform.git -b ${DEFAULT_PLATFORM_BRANCH} --bare .platform'
- git -C .platform remote set-url origin https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/6/product/platform.git
# Find best matching branch. Example try: 6.3.2.1, 6.3.2, 6.3, master
- export MATCHING_BRANCH=$(.gitlab-ci/tools/console release:show-platform-branch $TAG .platform)
- if [[ -z $MATCHING_BRANCH ]]; then echo "No matching branch found"; exit 1; fi
- echo "Checkout platform branch $MATCHING_BRANCH"
# fetch newest changes from $MATCHING_BRANCH
- git -C .platform fetch origin ${MATCHING_BRANCH}
- git -C .platform log -n 5
# set HEAD to newest commit in $$MATCHING_BRANCH
- git -C .platform reset --soft FETCH_HEAD
# split platform into separate repos/packages
- >
for pkg in $SPLIT_REPOS ; do
.gitlab-ci/split_repo.sh .platform src/${pkg}
git -C .platform/ rev-parse HEAD > repos/${pkg,,}/PLATFORM_COMMIT_SHA
done
# build test package
- .gitlab-ci/build-nightly.sh
- IMAGE_TAG=${TAG}-dev
- docker build . -t "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
- mkdir artifacts || true
- chmod 777 artifacts || true
- .gitlab-ci/changed-files.sh > artifacts/additional_update_files
# TODO: get REFERENCE_INSTALLER_URL and REFERENCE_INSTALLER_SHA256 from shopware6.xml - use MINIMUM_VERSION
# create package archive file
- docker run -v $PWD/artifacts:/artifacts -e REFERENCE_INSTALLER_URL -e REFERENCE_INSTALLER_SHA256 --entrypoint=bin/package.sh ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} /artifacts/additional_update_files
- echo ${TAG} > artifacts/TAG
- echo ${CI_JOB_ID} > artifacts/PACKAGE_JOB_ID
- echo ${MATCHING_BRANCH} > artifacts/PLATFORM_BRANCH
artifacts:
expire_in: 1 week
paths:
- artifacts/
- repos/
Static Analysis:
stage: analyze
image: shopware/development:latest
only:
refs:
- merge_requests
script:
- composer install
- composer install -d .gitlab-ci/tools
- php .gitlab-ci/tools/vendor/bin/ecs check --config easy-coding-standard.php
- php .gitlab-ci/tools/vendor/bin/phpstan analyse
- php .gitlab-ci/tools/vendor/bin/psalm.phar
Tools unit test:
stage: test
image: shopware/development:latest
only:
refs:
- merge_requests
script:
- composer install -d .gitlab-ci/tools
- php .gitlab-ci/tools/vendor/bin/phpunit --configuration .gitlab-ci/tools/phpunit.xml.dist --log-junit phpunit.junit.xml
artifacts:
when: always
paths:
- phpunit.junit.xml
reports:
junit: phpunit.junit.xml
# Unit tests
Unit PHP 7.2:
extends: .unit_base
image: shopware/development:7.2
# e2e install tests
Install (Visual, EN):
extends: .e2e_install_base
only:
refs:
- schedules
variables:
- $CYPRESS_PERCY_USAGE == "true"
variables:
GIT_STRATEGY: none
script:
- cp artifacts/install*.tar.xz install.tar.xz
- tar -xf install.tar.xz
- rm install.tar.xz
- /entrypoint supervisord > /dev/null 2>&1 &
- apt-get update && apt-get install -y xvfb
- cd vendor/shopware/recovery/Test/e2e
- npm clean-install
- echo $PERCY_BUILD_NAME
- timeout 20m npx percy exec -- cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,usePercy=$CYPRESS_PERCY_USAGE
--spec cypress/integration/installer/basic.spec.js
- timeout 5m npx percy exec -- cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,usePercy=$CYPRESS_PERCY_USAGE
--spec "cypress/integration/visual/*"
Install (EN):
extends: .e2e_install_base
only:
refs:
- schedules
variables:
- $CYPRESS_PERCY_USAGE == "false"
variables:
GIT_STRATEGY: none
script:
- cp artifacts/install*.tar.xz install.tar.xz
- tar -xf install.tar.xz
- rm install.tar.xz
- /entrypoint supervisord > /dev/null 2>&1 &
- apt-get update && apt-get install -y xvfb
- cd vendor/shopware/recovery/Test/e2e
- npm clean-install
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG
--spec cypress/integration/installer/basic.spec.js
- timeout 5m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG
--spec "cypress/integration/visual/*"
Install (NL):
extends: .e2e_install_base
variables:
GIT_STRATEGY: none
script:
- cp artifacts/install*.tar.xz install.tar.xz
- tar -xf install.tar.xz
- rm install.tar.xz
- /entrypoint supervisord > /dev/null 2>&1 &
- apt-get update && apt-get install -y xvfb
- cd vendor/shopware/recovery/Test/e2e
- npm clean-install
- $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,locale="nl-NL"
--spec cypress/integration/installer/install_nl.spec.js
# e2e update tests
Manual Update (EN):
extends: .e2e_update_base
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
script:
- unzip -qqo artifacts/update.zip
- chown -R application:application $CI_PROJECT_DIR
- cd vendor/shopware/recovery/Test/e2e/
- npm ci
- npm install --save-dev @percy/cypress
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG
--spec cypress/integration/updater/manual-update.spec.js
- timeout 5m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,testDataUsage=true
--spec cypress/integration/updater/validation/storefront.spec.js
after_script:
- npx mochawesome-merge .gitlab-ci/e2e/test/artifacts/mochawesome/single-reports/mochawesome*.json > .gitlab-ci/e2e/test/artifacts/mochawesome/single-reports/report-final.json
- npx mochawesome-report-generator .gitlab-ci/e2e/test/artifacts/mochawesome/single-reports/report-final.json --cdn true --reportDir .gitlab-ci/e2e/test/artifacts/mochawesome
.E2E Update:
extends: .e2e_update_base
artifacts:
when: always
expire_in: 1 week
paths:
- .gitlab-ci/e2e/test/artifacts/*
- var/log/*
- development/var/log/*
- $CI_PROJECT_DIR/stdout.log
after_script:
- npx mochawesome-merge .gitlab-ci/e2e/test/artifacts/mochawesome/single-reports/mochawesome*.json > .gitlab-ci/e2e/test/artifacts/mochawesome/single-reports/report-final.json
- npx mochawesome-report-generator .gitlab-ci/e2e/test/artifacts/mochawesome/single-reports/report-final.json --cdn true --reportDir .gitlab-ci/e2e/test/artifacts/mochawesome
Update (EN, Mysql 8.0):
extends: .E2E Update
services:
- name: mysql:8.0.19
alias: mysql
command: [ "mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--default-authentication-plugin=mysql_native_password" ]
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
script:
- cd .gitlab-ci/e2e/test/
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG
--spec cypress/integration/updater/auto-update.spec.js
- timeout 5m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,testDataUsage=true
--spec "cypress/integration/updater/validation/*"
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
Update (Visual, DE):
extends: .E2E Update
only:
refs:
- schedules
variables:
- $CYPRESS_PERCY_USAGE == "true"
script:
- cd .gitlab-ci/e2e/test/
- echo $PERCY_BUILD_NAME
- timeout 20m npx percy exec -- cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,usePercy=$CYPRESS_PERCY_USAGE,testBase="Update"
--spec cypress/integration/updater/auto-update.spec.js
- timeout 5m npx percy exec -- cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,testDataUsage=true,testBase="Update",locale="de-DE",usePercy=$CYPRESS_PERCY_USAGE
--spec "cypress/integration/visual/*"
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
Update (DE):
extends: .E2E Update
only:
refs:
- schedules
variables:
- $CYPRESS_PERCY_USAGE == "false"
script:
- cd .gitlab-ci/e2e/test/
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,testBase="Update"
--spec cypress/integration/updater/auto-update.spec.js
- timeout 5m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,testDataUsage=true,testBase="Update",locale="de-DE"
--spec "cypress/integration/visual/*"
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
Finalize Percy Build:
extends: .e2e_install_base
stage: prepare-release
when: always
only:
refs:
- schedules
variables:
- $CYPRESS_PERCY_USAGE == "true"
script:
# finalize all visual testing jobs
- export PERCY_TOKEN=$PERCY_TOKEN
- export PERCY_BUILD_NAME=$CI_PIPELINE_ID
- export PERCY_PARALLEL_NONCE=$PERCY_BUILD_NAME
- export PERCY_PARALLEL_TOTAL=-1
- npx percy finalize --all