-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
507 lines (466 loc) · 19.8 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
variables:
DOCKER_DRIVER: overlay2
# shopware 6
WEB_DOCUMENT_ROOT: '$CI_PROJECT_DIR/public'
MYSQL_ROOT_PASSWORD: root
DEFAULT_PLATFORM_BRANCH: trunk
LOG_STDOUT: $CI_PROJECT_DIR/stdout.log
CYPRESS_PERCY_USAGE: $CYPRESS_PERCY_USAGE
PERCY_BUILD_NAME: '000'
CYPRESS_shopwareRoot: $CI_PROJECT_DIR
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
default:
tags:
- t3.medium
Build Test Package:
interruptible: true
stage: build
tags:
- m5.large
only:
refs:
- schedules
- merge_requests
image: debian:bullseye-slim
services:
- name: docker:20.10-dind
alias: dockerdaemon
variables:
GIT_STRATEGY: none
SPLIT_REPOS: "Administration Storefront Core Elasticsearch Recovery"
SPLITSH: /opt/splitsh-lite
SHOPWARE_SKIP_BUNDLE_DUMP: 1
SHOPWARE_SKIP_ASSET_COPY: 1
SHOPWARE_SKIP_THEME_COMPILE: 1
DOCKER_HOST: tcp://dockerdaemon:2375/
DOCKER_TLS_CERTDIR: ""
cache:
key: "package_$CI_COMMIT_BRANCH"
paths:
- .platform
- .composer
- .apt
- .npm
policy: pull-push
before_script:
- apt-get update
- DEB_PACKAGES="git jq curl docker.io build-essential nodejs php-cli 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
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- 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 config --global init.defaultBranch trunk
- 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}
- git log -n 5
- 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)}
- echo "$TAG"
- SHOPWARE_VERSION="$(git describe --abbrev=0)"
- SHOPWARE_VERSION="${SHOPWARE_VERSION#"v"}"
- echo "$SHOPWARE_VERSION" > artifacts/SHOPWARE_VERSION
- 'if [[ -z "$TAG" ]]; then echo "TAG is empty"; exit 1; fi'
- '[[ -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}
# set HEAD to newest commit in $$MATCHING_BRANCH
- git -C .platform reset --soft FETCH_HEAD
- git -C .platform fetch --tags origin
- git -C .platform log -n 5
# export e2e tests for usage in test jobs
- git -C .platform archive --output $PWD/artifacts/tests.tar HEAD tests/
- tar --append -f $PWD/artifacts/tests.tar .gitlab-ci/install_store_plugin.bash
# 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
- .gitlab-ci/changed-files.sh --deleted > artifacts/additional_deleted_files
# TODO: get REFERENCE_INSTALLER_URL and REFERENCE_INSTALLER_SHA256 from shopware6.xml - use MINIMUM_VERSION
# create package archive file
- 'echo "Default env: $DEFAULT_ENV"'
- docker run
-v $PWD/artifacts:/artifacts
-e DEFAULT_ENV -e REFERENCE_INSTALLER_URL -e REFERENCE_INSTALLER_SHA256
--entrypoint=bin/package.sh ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
/artifacts/additional_update_files
/artifacts/additional_deleted_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:7.4-composer-2
only:
refs:
- merge_requests
script:
- apt update && apt install shellcheck
# SC1090: source is not resolved
# SC2039: busybox sh supports [[
- shellcheck --exclude=SC1090 --exclude=SC2039 bin/*.sh .gitlab-ci/*.sh .gitlab-ci/tools/bin/*.sh .gitlab-ci/e2e/*.sh
- 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
Tools unit test:
stage: test
image: shopware/development:7.4-composer-2
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.4:
extends: .unit_base
image: shopware/development:7.4-composer-2
only:
refs:
- schedules
- merge_requests
# e2e install tests
Install (Visual, EN):
extends: .e2e_install_base
only:
refs:
- schedules
- merge_requests
variables:
- $CYPRESS_PERCY_USAGE == "true"
variables:
GIT_STRATEGY: none
CYPRESS_SKIP_INIT: 'true'
script:
- cp artifacts/install*.tar.xz install.tar.xz
- tar -xf install.tar.xz
- rm install.tar.xz
- >
if [[ -n "$CI_MERGE_REQUEST_ID" ]]; then
mkdir -p config/packages/ || true
cat > config/packages/ci.yaml <<EOF
parameters:
kernel.shopware_version: '$SHOPWARE_VERSION'
EOF
fi
- SERVICE_PHPFPM_OPTS=--allow-to-run-as-root CONTAINER_UID=root /entrypoint supervisord > artifacts/supervisord.log 2>&1 &
- apt-get update && apt-get install -y xvfb
- tar -xf artifacts/tests.tar
- cd tests/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/recovery/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/recovery/visual/*"
Install (EN):
extends: .e2e_install_base
only:
refs:
- schedules
- merge_requests
variables:
- $CYPRESS_PERCY_USAGE != "true"
variables:
GIT_STRATEGY: none
CYPRESS_SKIP_INIT: 'true'
script:
- cp artifacts/install*.tar.xz install.tar.xz
- tar -xf install.tar.xz
- rm install.tar.xz
- export SHOPWARE_VERSION=$(cat artifacts/SHOPWARE_VERSION)
- >
if [[ -n "$CI_MERGE_REQUEST_ID" ]]; then
mkdir -p config/packages/ || true
cat > config/packages/ci.yaml <<EOF
parameters:
kernel.shopware_version: '$SHOPWARE_VERSION'
EOF
fi
- SERVICE_PHPFPM_OPTS=--allow-to-run-as-root CONTAINER_UID=root /entrypoint supervisord > artifacts/supervisord.log 2>&1 &
- apt-get update && apt-get install -y xvfb
- tar -xf artifacts/tests.tar
- cd tests/e2e
- npm clean-install
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0,retries=0 --headless
--env expectedVersion=$TAG
--spec cypress/integration/recovery/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/recovery/visual/*"
Install (NL):
extends: .e2e_install_base
variables:
GIT_STRATEGY: none
CYPRESS_SKIP_INIT: 'true'
script:
- cp artifacts/install*.tar.xz install.tar.xz
- tar -xf install.tar.xz
- rm install.tar.xz
- export SHOPWARE_VERSION=$(cat artifacts/SHOPWARE_VERSION)
- >
if [[ -n "$CI_MERGE_REQUEST_ID" ]]; then
mkdir -p config/packages/ || true
cat > config/packages/ci.yaml <<EOF
parameters:
kernel.shopware_version: '$SHOPWARE_VERSION'
EOF
fi
- SERVICE_PHPFPM_OPTS=--allow-to-run-as-root CONTAINER_UID=root /entrypoint supervisord > artifacts/supervisord.log 2>&1 &
- apt-get update && apt-get install -y xvfb
- tar -xf artifacts/tests.tar
- cd tests/e2e
- npm clean-install
- $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0,retries=0 --headless
--env expectedVersion=$TAG,locale="nl-NL"
--spec cypress/integration/recovery/installer/install_nl.spec.js
Install (NL) with scenarios:
extends: .e2e_install_base
only:
refs:
- schedules
- merge_requests
allow_failure: true
variables:
GIT_STRATEGY: none
#CYPRESS_SKIP_INIT: 'true'
CYPRESS_localUsage: 'true'
APP_ENV: e2e
script:
- export TAG=$(cat artifacts/TAG)
- export SHOPWARE_VERSION=$(cat artifacts/SHOPWARE_VERSION)
- cp artifacts/install*.tar.xz install.tar.xz
- tar -xf install.tar.xz
- rm install.tar.xz
- SERVICE_PHPFPM_OPTS=--allow-to-run-as-root CONTAINER_UID=root /entrypoint supervisord > artifacts/supervisord.log 2>&1 &
- apt-get update && apt-get install -y xvfb jq
- tar -xf artifacts/tests.tar
- >
if [[ -n "$CI_MERGE_REQUEST_ID" ]]; then
mkdir -p config/packages/ || true
cat > config/packages/ci.yaml <<EOF
parameters:
kernel.shopware_version: '$SHOPWARE_VERSION'
EOF
fi
- cat config/packages/ci.yaml || true
- cd tests/e2e
- npm clean-install
- $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0,retries=0 --headless
--env expectedVersion=$TAG,locale="nl-NL"
--spec cypress/integration/recovery/installer/install_nl.spec.js
- cd $CI_PROJECT_DIR
- .gitlab-ci/install_store_plugin.bash SwagLanguagePack SwagPayPal
- bin/console e2e:dump-db
- cd tests/e2e
- $(npm bin)/cypress run
--browser chrome --headless
--spec "cypress/integration/scenarios/**/*.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"
CYPRESS_SKIP_INIT: 'true'
script:
- unzip -qqo artifacts/update.zip
- chown -R application:application $CI_PROJECT_DIR
- cd tests/e2e
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG
--spec cypress/integration/recovery/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/recovery/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 (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.8.0
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
script:
- cd tests/e2e
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG
--spec cypress/integration/recovery/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/recovery/updater/validation/*"
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
CYPRESS_SKIP_INIT: 'true'
Update (Visual, DE):
extends: .E2E Update
only:
refs:
- schedules
- merge_requests
variables:
- $CYPRESS_PERCY_USAGE == "true"
script:
- cd tests/e2e
- 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/recovery/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/recovery/visual/*"
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
CYPRESS_SKIP_INIT: 'true'
Update (DE):
extends: .E2E Update
only:
refs:
- schedules
- merge_requests
variables:
- $CYPRESS_PERCY_USAGE != "true"
script:
- cd tests/e2e
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,testBase="Update"
--spec cypress/integration/recovery/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/recovery/visual/*"
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
CYPRESS_SKIP_INIT: 'true'
Update from latest:
extends: .E2E Update
tags:
- m5.large
only:
refs:
- schedules
- merge_requests
variables:
- $E2E_INSTALL_PACKAGE_URL_LATEST
script:
- cd tests/e2e
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0 --headless
--env expectedVersion=$TAG,testBase="Update"
--spec cypress/integration/recovery/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/recovery/visual/*"
- cd $CI_PROJECT_DIR
- php bin/console bundle:dump
- bash bin/build-administration.sh
variables:
E2E_INSTALL_PACKAGE_URL: $E2E_INSTALL_PACKAGE_URL_LATEST
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
CYPRESS_SKIP_INIT: 'true'
Finalize Percy Build:
extends: .e2e_install_base
stage: prepare-release
when: always
only:
refs:
- schedules
variables:
- '$CYPRESS_PERCY_USAGE == "true" && $PERCY_TOKEN'
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
- npm install -g percy --unsafe-perm=true
- percy finalize --all