forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
684 lines (636 loc) · 21.7 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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: "/certs"
MYSQL_ROOT_PASSWORD: app
WEB_DOCUMENT_ROOT: $CI_PROJECT_DIR/development/public
GIT_STRATEGY: clone
stages:
- unit
- E2E
- Build
- Generate docs
- Security
- Deploy
include:
- local: .gitlab/ci/sync.yml
default:
image: shopware/development:latest
before_script:
- apt-install jq
- export CI_DEV_BRANCH=$(echo $CI_COMMIT_REF_NAME | cut -d'+' -f2-)
- zip -rq platform.zip .
- git clone http://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/6/product/development.git
- unzip -q platform.zip -d development/platform/
- cd development
- git -C platform checkout master
- git -C platform checkout $CI_COMMIT_SHA
- >
if [ "$(git ls-remote origin $CI_DEV_BRANCH | wc -l)" == 1 ]; then
echo "Development Branch: $CI_DEV_BRANCH (explicit)";
git checkout $CI_DEV_BRANCH;
elif [ "$(git ls-remote origin $CI_COMMIT_REF_NAME | wc -l)" == 1 ]; then
echo "Development Branch: $CI_COMMIT_REF_NAME (implicit by same branch name)";
git checkout $CI_COMMIT_REF_NAME;
else
export CI_TARGET_BRANCH_NAME=$(curl -LsS -H "PRIVATE-TOKEN: $CI_GITLAB_API_TOKEN" "https://gitlab.shopware.com/api/v4/projects/$CI_PROJECT_ID/merge_requests?source_branch=$CI_COMMIT_REF_NAME" | jq --raw-output ".[0].target_branch");
if [ "$(git ls-remote origin $CI_TARGET_BRANCH_NAME | wc -l)" == 1 ]; then
echo "Development Branch: $CI_TARGET_BRANCH_NAME (implicit by merge request target branch)";
git checkout $CI_TARGET_BRANCH_NAME;
else
echo "Development Branch: master (fallback)";
fi
fi
- cp -v dev-ops/gitlab/.psh.yaml.override .
- /entrypoint supervisord > /dev/null 2>&1 &
interruptible: true
Javascript analysis:
only:
refs:
- merge_requests
- master
- "6.1"
stage: unit
timeout: 1h 00m
before_script: []
script:
- cd src/Administration/Resources
- npm clean-install
- npm run lerna -- bootstrap
- cd app/administration
- PROJECT_ROOT=$(pwd) node_modules/.bin/eslint --ext .js,.vue --format junit src test > eslint.junit.xml
artifacts:
reports:
junit: src/Administration/Resources/app/administration/eslint.junit.xml
PHP analysis:
only:
refs:
- merge_requests
- master
- "6.1"
stage: unit
services:
- name: mysql:5.7
alias: mysql
retry:
max: 2
when: runner_system_failure
timeout: 1h 00m
script:
- ./psh.phar init
- if [[ ! -h vendor/shopware/platform ]]; then echo 'vendor/shopware/platform should be a symlink'; exit 1; fi
- php dev-ops/analyze/generate-composer.php
- php dev-ops/analyze/vendor/bin/ecs check platform/src --config platform/easy-coding-standard.yml
- php dev-ops/analyze/phpstan-config-generator.php
- php dev-ops/analyze/vendor/bin/phpstan analyze --autoload-file=dev-ops/analyze/vendor/autoload.php --configuration platform/phpstan.neon --error-format gitlab | tee phpstan-report.json
- >
for module in $(ls vendor/shopware/platform/src/); do
echo "[PSALM: scan $module]"
php dev-ops/analyze/vendor/bin/psalm --config=platform/psalm.xml --threads=$(nproc) --diff --show-info=false platform/src/$module;
done
- php dev-ops/analyze/vendor/bin/psalm --config=vendor/shopware/platform/psalm.xml --threads=$(nproc) --show-info=false src
artifacts:
reports:
codequality: development/phpstan-report.json
# stage: unit
.phpunit_base:
stage: unit
services:
- name: mariadb:10.3
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
variables:
TEST_SUITES: "administration storefront checkout content framework migration system elasticsearch docs"
timeout: 1h 00m
script:
- ./psh.phar init
- if [[ ! -h vendor/shopware/platform ]]; then echo 'vendor/shopware/platform should be a symlink'; exit 1; fi
- mkdir -p build/artifacts/
- echo -e
"<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
" > build/artifacts/phpunit.junit.xml
- >
for TEST_SUITE in $TEST_SUITES; do
log_unit_file=build/artifacts/$TEST_SUITE.junit.xml
set -x
php vendor/bin/phpunit --configuration vendor/shopware/platform/phpunit.xml.dist --log-junit "$log_unit_file" --colors=never --testsuite "$TEST_SUITE"
set +x
tail -n +3 "$log_unit_file" | head -n -1 >> build/artifacts/phpunit.junit.xml
done
- echo -e "</testsuites>" >> "build/artifacts/phpunit.junit.xml"
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
artifacts:
paths:
- development/build/artifacts/
reports:
junit: development/build/artifacts/phpunit.junit.xml
PHP 7.2:
only:
refs:
- merge_requests
- master
- "6.1"
extends: .phpunit_base
image: shopware/development:7.2
stage: unit
timeout: 1h 00m
services:
- name: mariadb:10.3
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
PHP 7.3:
only:
refs:
- merge_requests
- master
- "6.1"
except:
- schedules
extends: .phpunit_base
image: shopware/development:7.3
stage: unit
when: manual
timeout: 1h 00m
services:
- name: mysql:5.7
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
PHP 7.3 (Schedule):
only:
- schedules
extends: .phpunit_base
image: shopware/development:7.3
stage: unit
services:
- name: mysql:5.7
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
PHP 7.4:
only:
refs:
- merge_requests
- master
- "6.1"
except:
- schedules
extends: .phpunit_base
image: shopware/development:7.4
stage: unit
when: manual
timeout: 1h 00m
services:
- name: mysql:5.7
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
PHP 7.4 (Schedule):
only:
- schedules
extends: .phpunit_base
image: shopware/development:7.4
stage: unit
services:
- name: mysql:5.7
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
MySQL 5.7:
only:
refs:
- merge_requests
- master
- "6.1"
except:
- schedules
extends: .phpunit_base
stage: unit
when: manual
timeout: 1h 00m
services:
- name: mysql:5.7
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
MySQL 5.7 (Schedule):
only:
- schedules
extends: .phpunit_base
stage: unit
services:
- name: mysql:5.7
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
MySQL 8.0:
only:
refs:
- merge_requests
- master
- "6.1"
except:
- schedules
extends: .phpunit_base
stage: unit
when: manual
timeout: 1h 00m
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: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
MySQL 8.0 (Schedule):
only:
- schedules
extends: .phpunit_base
stage: unit
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: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
MariaDB 10.4:
only:
refs:
- merge_requests
- master
- "6.1"
except:
- schedules
extends: .phpunit_base
stage: unit
when: manual
timeout: 1h 00m
services:
- name: mariadb:10.4
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
MariaDB 10.4 (Schedule):
only:
- schedules
extends: .phpunit_base
stage: unit
allow_failure: true
services:
- name: mariadb:10.4
alias: mysql
- name: elastic/elasticsearch:7.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
Administration (Jest):
only:
refs:
- merge_requests
- master
- "6.1"
stage: unit
timeout: 1h 00m
services:
- name: mariadb:10.3
alias: mysql
script:
- ./psh.phar init
- ./psh.phar administration:install-dependencies
- ./psh.phar administration:unit
coverage: '/^\s?All files[^|]*\|[^|]*\s+([\d\.]+)/'
artifacts:
reports:
junit: development/build/artifacts/administration.junit.xml
Storefront (Jest):
only:
refs:
- merge_requests
- master
- "6.1"
stage: unit
timeout: 1h 00m
variables:
PROJECT_ROOT: $CI_PROJECT_DIR/development
services:
- name: mariadb:10.3
alias: mysql
script:
- ./psh.phar init
- ./psh.phar storefront:install-dependencies
- npm --prefix vendor/shopware/platform/src/Storefront/Resources/app/storefront/ run unit
coverage: '/^\s?All files[^|]*\|[^|]*\s+([\d\.]+)/'
artifacts:
reports:
junit: development/build/artifacts/storefront.junit.xml
# Stage: E2E
.job_template: &e2e_definition
stage: E2E
services:
- name: docker:18.09.7-dind
alias: docker
- name: mariadb:10.3
alias: mysql
dependencies: []
artifacts:
when: always
paths:
- development/build/artifacts/e2e/
reports:
junit: development/build/artifacts/e2e/*.xml
.mixed_script:
script: &mixed_definition
- ./psh.phar init --APP_ENV="prod"
- ./psh.phar administration:init --APP_ENV="prod"
- ./psh.phar storefront:init --APP_ENV="prod" --DB_NAME="shopware_e2e"
- ./psh.phar e2e:dump-db --APP_ENV="prod"
- E2E_BASE_PATH=vendor/shopware/platform/src/${SECTION}/Resources/app/$(echo ${SECTION} | tr '[:upper:]' '[:lower:]')/test/e2e
- npm i @shopware-ag/e2e-testsuite-platform --prefix $E2E_BASE_PATH
- forever start ${E2E_BASE_PATH}/node_modules/@shopware-ag/e2e-testsuite-platform/routes/cypress.js
- chown -R 1000:1000 .
- docker run --name cypress --add-host="docker.vm:$(hostname -I)" -e CYPRESS_baseUrl=http://docker.vm:8000 -v $(pwd)/${E2E_BASE_PATH}:/e2e -v $(pwd):/app -w /e2e --entrypoint "sh" cypress/included:3.8.1 -c "npm install --production --prefix /e2e && node_modules/.bin/cypress run --project /e2e --browser chrome --config baseUrl=http://docker.vm:8000 --config numTestsKeptInMemory=0 --spec $TEST_DIRECTORY"
.scheduled_script:
script: &scheduled_definition
- ./psh.phar init --APP_ENV="prod"
- ./psh.phar administration:init --APP_ENV="prod"
- ./psh.phar storefront:init --APP_ENV="prod" --DB_NAME="shopware_e2e"
- ./psh.phar e2e:dump-db --APP_ENV="prod"
- E2E_BASE_PATH=vendor/shopware/platform/src/${SECTION}/Resources/app/$(echo ${SECTION} | tr '[:upper:]' '[:lower:]')/test/e2e
- npm i @shopware-ag/e2e-testsuite-platform --prefix $E2E_BASE_PATH
- forever start ${E2E_BASE_PATH}/node_modules/@shopware-ag/e2e-testsuite-platform/routes/cypress.js
- chown -R 1000:1000 .
- docker run --name cypress --add-host="docker.vm:$(hostname -I)" -e CYPRESS_baseUrl=http://docker.vm:8000 -v $(pwd)/${E2E_BASE_PATH}:/e2e -v $(pwd):/app -w /e2e --entrypoint "sh" cypress/included:3.8.1 -c "npm install --production --prefix /e2e && node_modules/.bin/cypress run --project /e2e --browser chrome --config baseUrl=http://docker.vm:8000 --config numTestsKeptInMemory=0"
.generate_mochawesome_reports:
after_script: &mochawesome_report_definition
- npx mochawesome-merge development/build/artifacts/e2e/mochawesome/single-reports/mochawesome*.json > development/build/artifacts/e2e/mochawesome/report-final.json
- npx mochawesome-report-generator development/build/artifacts/e2e/mochawesome/report-final.json --cdn true --reportDir development/build/artifacts/e2e/mochawesome
- docker rm -f cypress
General (Storefront):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Storefront (Jest)]
timeout: 1h 00m
script: *mixed_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Storefront'
TEST_DIRECTORY: "cypress/integration/**/*"
Content (Mixed):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Administration (Jest)]
timeout: 1h 00m
script: *mixed_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/content/**/*"
Catalogues (Mixed):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Administration (Jest)]
timeout: 1h 00m
script: *mixed_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/catalogue/**/*"
Customers (Mixed):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Administration (Jest)]
timeout: 1h 00m
script: *mixed_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/customer/**/*"
Media and Marketing (Mixed):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Administration (Jest)]
script: *mixed_definition
timeout: 1h 00m
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/media-marketing/**/*"
General (Administration):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Administration (Jest)]
timeout: 1h 00m
script: *mixed_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/general/**/*"
Orders (Administration):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Administration (Jest)]
timeout: 1h 00m
script: *mixed_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/order/**/*"
Rules and Product Groups (Administration):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Administration (Jest)]
timeout: 1h 00m
script: *mixed_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/rule-product-stream/**/*"
Settings (Administration):
only:
- merge_requests
- master
- "6.1"
except:
- schedules
<<: *e2e_definition
needs: [Administration (Jest)]
timeout: 1h 00m
script: *mixed_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/settings/**/*"
Admin (Total):
only:
- schedules
<<: *e2e_definition
timeout: 2h 00m
script: *scheduled_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Administration'
TEST_DIRECTORY: "cypress/integration/**/*"
Storefront (Total):
only:
- schedules
<<: *e2e_definition
timeout: 2h 00m
script: *scheduled_definition
after_script: *mochawesome_report_definition
variables:
SECTION: 'Storefront'
TEST_DIRECTORY: "cypress/integration/**/*"
# Stage: build
Component Library:
only:
refs:
- merge_requests
- master
- "6.1"
changes:
- src/Administration/**/*
- src/Storefront/**/*
stage: Build
image: node:10.8
before_script: []
dependencies: []
needs: [Administration (Jest), Storefront (Jest)]
variables:
PROJECT_ROOT: $CI_PROJECT_DIR
environment:
name: Component Library
url: https://component-library.shopware.com
script:
- npm install --prefix src/Administration/Resources/
- npm run --prefix src/Administration/Resources lerna -- bootstrap
- npm install --prefix src/Administration/Resources/app/administration/build/nuxt-component-library/
- npm run --prefix src/Administration/Resources/app/administration/build/nuxt-component-library/ generate
- "[[ -d build/artifacts/component-library/ ]] && (ls -1qA build/artifacts/component-library/ | grep -q .)"
artifacts:
paths:
- build/artifacts/component-library/
# Stage: Generate docs
Generating docs:
only:
refs:
- merge_requests
- master
- "6.1"
changes:
- src/Docs/**/*
stage: Generate docs
dependencies: []
services:
- name: docker:18.09.7-dind
alias: docker
script:
- docker build -t shopware-plattform-plantuml dev-ops/docs/docker/plantuml/.
- sh ./dev-ops/docs/scripts/render_puml.sh platform/src/Docs/Resources/current
- ./psh.phar init-composer
- php dev-ops/docs/scripts/dumpPlatformUpdates.php
- php dev-ops/docs/scripts/convertMarkdownToDocs.php convert -i platform/src/Docs/Resources/current/ -o build/docs -u /shopware-platform-dev -s
# Stage: security
RIPS security:
stage: Security
image: php:7.3-alpine
before_script: []
allow_failure: true
only:
- master
- "6.1"
script:
- apk add --no-cache libzip-dev && docker-php-ext-configure zip --with-libzip=/usr/include && docker-php-ext-install zip
- wget https://github.com/rips/rips-cli/releases/download/3.2.0/rips-cli.phar -O /usr/bin/rips-cli
- chmod 755 /usr/bin/rips-cli
- rips-cli rips:scan:start -p . -t critical:0 -a ${RIPS_APP_ID} --progress
interruptible: false
# Stage: deploy
.Scrutinizer:
stage: Deploy
image: php:7.3-alpine
allow_failure: true
before_script: []
only:
- master
- "6.1"
dependencies:
- PHPUnit (MySQL)
script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload
--repository="g/shopware/platform"
--revision="$CI_COMMIT_SHA"
--format=php-clover
development/build/artifacts/phpunit.clover.xml
interruptible: false
Upload Component Library:
stage: Deploy
image: python:latest
before_script: []
only:
refs:
- master
- "6.1"
changes:
- src/Administration/**/*
- src/Storefront/**/*
dependencies:
- Component Library
script:
- pip install awscli
- cd build/artifacts/component-library
- aws s3 sync --delete --acl public-read . s3://shopware-ui-component-library-docs/
- aws cloudfront create-invalidation --distribution-id E18U17118IAC82 --paths "/*"
interruptible: false