This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
/
.gitlab-ci.yml
241 lines (220 loc) · 7.58 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
variables:
MYSQL_ROOT_PASSWORD: app
WEB_DOCUMENT_ROOT: $CI_PROJECT_DIR/development/public
REPOSITORY_HOST: "gitlab.shopware.com:5005"
# Default platform branch used for static analysis e.g. overwritten by unit test steps
PLATFORM_BRANCH: "6.2"
DEVELOPMENT_BRANCH: "6.2"
IMAGE_NAME: "${REPOSITORY_HOST}/shopware-cloud/connect/php-static-analysis"
stages:
- Build
- Static analysis
- Unit
- E2E
cache:
key: "Eternal static key"
paths:
- .composer
- .npm
.sw6_base:
image: shopware/development:latest
before_script:
- zip -rq plugin.zip .
- git clone http://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/6/product/development.git --branch $DEVELOPMENT_BRANCH
- rm -rf development/platform
- git clone http://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/6/product/platform.git development/platform --branch $PLATFORM_BRANCH
- unzip -q plugin.zip -d development/custom/plugins/SaasConnect
- cd development
- composer install --no-interaction --optimize-autoloader --no-suggest --no-scripts --no-progress
- cp -v dev-ops/gitlab/.psh.yaml.override .
- /entrypoint supervisord > /dev/null 2>&1 &
.sw6_base_services:
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" ]
.unit:
extends:
- .sw6_base
- .sw6_base_services
script:
- ./psh.phar init
- ./psh.phar storefront:install-dependencies
- ./psh.phar storefront:build
- composer install -d custom/plugins/SaasConnect
- composer dump-autoload -d custom/plugins/SaasConnect
- php bin/console plugin:install --activate SaasConnect
- ./psh.phar init-test-databases
- mkdir custom/apps
- php -d pcov.enabled=1 -d pcov.directory=$CI_PROJECT_DIR
vendor/bin/phpunit
--configuration custom/plugins/SaasConnect/phpunit.xml.dist
--log-junit build/artifacts/phpunit.junit.xml
--colors=never
--coverage-clover build/artifacts/phpunit.clover.xml
--coverage-html build/artifacts/phpunit-coverage-html
--coverage-text
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
artifacts:
paths:
- development/build/artifacts/
reports:
junit: development/build/artifacts/phpunit.junit.xml
Build-Analysis-Container:
stage: Build
only:
refs:
- merge_requests
- master
changes:
- dev-ops/tools/*
- dev-ops/tools/**/*
image: docker
services:
- name: docker:19.03.9-dind
alias: docker
script:
- apk add git bash
- docker login "${REPOSITORY_HOST}" -u $CI_REGISTRY_USER -p "$CI_REGISTRY_PASSWORD"
- docker build dev-ops/tools -t "${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}"
- docker tag "${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}" "${IMAGE_NAME}:latest"
- docker push "${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}"
- docker push "${IMAGE_NAME}:latest"
EasyCodingStandard:
stage: Static analysis
only:
refs:
- merge_requests
- master
image: "${IMAGE_NAME}:latest"
script:
- composer install --no-interaction --optimize-autoloader --no-suggest --no-scripts --no-progress
- ecs check .
Psalm:
stage: Static analysis
extends:
- .sw6_base
only:
refs:
- merge_requests
- master
script:
- cd custom/plugins/SaasConnect
- make psalm
Phpstan:
stage: Static analysis
only:
refs:
- merge_requests
- master
extends:
- .sw6_base
script:
- cd custom/plugins/SaasConnect
- make phpstan
PhpInsights:
stage: Static analysis
only:
refs:
- merge_requests
- master
image: "${IMAGE_NAME}:latest"
script:
- composer install --no-interaction --optimize-autoloader --no-suggest --no-scripts --no-progress
- phpinsights --no-interaction --min-quality=100 --min-complexity=75 --min-architecture=100 --min-style=100
Eslint Administration:
stage: Static analysis
only:
refs:
- merge_requests
- master
extends:
- .sw6_base
script:
- cd custom/plugins/SaasConnect/src/Resources/app/administration
- npm install
- npm run eslint-junit > eslint-administration.junit.xml
artifacts:
reports:
junit: development/custom/plugins/SaasConnect/src/Resources/app/administration/eslint-administration.junit.xml
Unit 6.2:
stage: Unit
extends:
- .unit
only:
refs:
- merge_requests
- master
variables:
PLATFORM_BRANCH: "6.2"
DEVELOPMENT_BRANCH: "6.2"
Unit 6.3:
stage: Unit
extends:
- .unit
only:
refs:
- merge_requests
- master
variables:
PLATFORM_BRANCH: "6.3.2.0"
DEVELOPMENT_BRANCH: "master"
Jest (Administration):
stage: Unit
only:
refs:
- merge_requests
- master
extends:
- .sw6_base
- .sw6_base_services
script:
- composer install
- ./psh.phar administration:install-dependencies
- npm --prefix custom/plugins/SaasConnect/src/Resources/app/administration/ install
- PROJECT_ROOT=${CI_PROJECT_DIR}/development npm --prefix custom/plugins/SaasConnect/src/Resources/app/administration/ run unit
coverage: '/^\s?All files[^|]*\|[^|]*\s+([\d\.]+)/'
artifacts:
paths:
- development/build/artifacts/clover.xml
reports:
junit: development/build/artifacts/administration.junit.xml
Connect E2E:
stage: E2E
allow_failure: true
only:
refs:
- merge_requests
- master
extends:
- .sw6_base
services:
- name: docker:19.03.5-dind
# copied from .sw6_base_services as it does not merge the 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" ]
script:
- ./psh.phar init --APP_ENV="prod"
- php bin/console plugin:install --activate -c SaasConnect
- ./psh.phar administration:init --APP_ENV="prod"
- ./psh.phar storefront:init --APP_ENV="prod"
- ./psh.phar init-test-databases --APP_ENV="prod"
- ./psh.phar e2e:dump-db
- cp -v custom/plugins/SaasConnect/dev-ops/gitlab/cypress.env.json custom/plugins/SaasConnect/src/Resources/app/e2e/cypress.env.json
- chown -R 1000:1000 .
- npm --prefix custom/plugins/SaasConnect/src/Resources/app/e2e install --production
- forever start -c "npm run start-e2e-proxy" --workingDir custom/plugins/SaasConnect/src/Resources/app/e2e/ ./custom/plugins/SaasConnect/src/Resources/app/e2e/
- forever list
- docker run --name cypress --add-host="docker.vm:$(hostname -I)" -v $(pwd)/custom/plugins/SaasConnect/src/Resources/app/e2e:/e2e -v $(pwd)/build:/build -w /e2e cypress/included:4.4.0
- docker rm -f cypress
artifacts:
when: always
paths:
- development/build/artifacts/e2e/
reports:
junit: development/build/artifacts/e2e/*.xml