-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy path.gitlab-ci.yml
234 lines (209 loc) · 9.26 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
variables:
DOCKER_DRIVER: "overlay2"
DOCKER_HOST: "tcp://docker:2376"
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_BUILDKIT: 1
SW_HOST: "shopware"
SW_BASE_PATH: ""
WEB_DOCUMENT_ROOT: "$CI_PROJECT_DIR/"
ARTIFACTS_ROOT: "$CI_PROJECT_DIR/artifacts"
GIT_STRATEGY: "clone"
CHECKOUT_SHOPWARE_BRANCH: "5.7"
PLUGIN_NAME: "SwagPaymentPayPalUnified"
DB_USER: "app"
DB_PASSWORD: "app"
DB_NAME: "shopware"
DB_HOST: "mysql"
DB_PORT: 3306
stages:
- code-analysis
- phpunit
- shopware-versions
- e2e-current
- e2e-legacy
default:
tags:
- t3.medium
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:7.4
interruptible: true
.prepare_files_script: &prepare_files_script
- composer install --no-dev
- composer dump-autoload
- zip -rq plugin.zip .
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/5/product/shopware.git shopware --depth=1 -b ${CHECKOUT_SHOPWARE_BRANCH}
- unzip -q plugin.zip -d shopware/custom/plugins/${PLUGIN_NAME}
- composer install -q -d shopware
- cd shopware
.prepare_files_script_cookie_consent_manager: &prepare_files_script_cookie_consent_manager
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/5/product/swagcookieconsentmanager.git custom/plugins/SwagCookieConsentManager -b ${CHECKOUT_COOKIE_CONSENT_MANAGER_BRANCH}
# TODO: Check why this is necessary. This should probably only be done during certain testcases, instead of all.
.prepare_files_script_config_override: &prepare_files_script_config_override
- sed -e "s/%db\.user%/${DB_USER}/g" -e "s/%db\.password%/${DB_PASSWORD}/g" -e "s/%db\.database%/${DB_NAME}/g" -e "s/%db\.host%/${DB_HOST}/g" -e "s/%db\.port%/${DB_PORT}/g" < custom/plugins/${PLUGIN_NAME}/Tests/config_gitlab.php > config.php
.prepare_installation_script_install_shopware: &prepare_installation_script_install_shopware
- sed -e "s/%db\.user%/${DB_USER}/g" -e "s/%db\.password%/${DB_PASSWORD}/g" -e "s/%db\.database%/${DB_NAME}/g" -e "s/%db\.host%/${DB_HOST}/g" -e "s/%db\.port%/${DB_PORT}/g" < config.php.dist > config.php
- php bin/console sw:database:setup --steps=drop,create,import,importDemodata
- php bin/console sw:cache:clear
- php bin/console sw:database:setup --steps=setupShop --shop-url=http://${SW_HOST}${SW_BASE_PATH}
- php bin/console sw:snippets:to:db --include-plugins
- php bin/console sw:theme:initialize
- php bin/console sw:firstrunwizard:disable
- php bin/console sw:admin:create --name="Demo" --email="[email protected]" --username="demo" --password="demo" --locale=de_DE -n
- touch recovery/install/data/install.lock
.prepare_installation_script_install_shopware_make: &prepare_installation_script_install_shopware_make
- eval export DB_USER DB_PASSWORD DB_HOST DB_PORT DB_NAME SW_HOST SW_BASE_PATH # TODO: This line can probably be deleted.
- make init
.prepare_installation_script_install_plugin: &prepare_installation_script_install_plugin
- php bin/console sw:plugin:refresh
- php bin/console sw:plugin:install --activate ${PLUGIN_NAME}
- php bin/console sw:cache:clear
.prepare_installation_script_install_cookie_consent_manager_plugin: &prepare_installation_script_install_cookie_consent_manager_plugin
- php bin/console sw:plugin:refresh
- php bin/console sw:plugin:install --activate SwagCookieConsentManager
- php bin/console sw:cache:clear
.entrypoint_script: &entrypoint_script
- /usr/bin/supervisord -c /etc/supervisord.conf &>/dev/null &
.docker_login: &docker_login
- echo "$CI_REGISTRY_PASSWORD" | docker login --password-stdin -u "$CI_REGISTRY_USER" "$CI_REGISTRY"
.phpunit_base:
stage: phpunit
services:
- name: mysql:5.7
alias: mysql
variables:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_USER: "${DB_USER}"
MYSQL_PASSWORD: "${DB_PASSWORD}"
MYSQL_DATABASE: "${DB_NAME}"
before_script:
- *prepare_files_script
- *prepare_installation_script_install_shopware_make
- *prepare_installation_script_install_plugin
- *prepare_files_script_config_override
- *entrypoint_script
- cd custom/plugins/${PLUGIN_NAME}
script:
- ../../../vendor/bin/phpunit --stderr -v --config="phpunit.xml.dist" --colors="never" --log-junit="${ARTIFACTS_ROOT}/test-log.junit.xml"
artifacts:
paths:
- ${ARTIFACTS_ROOT}
reports:
junit: ${ARTIFACTS_ROOT}/*.junit.xml
.phpunit_base_pre_v57:
extends: .phpunit_base
before_script:
- composer self-update --1
- *prepare_files_script
- *prepare_installation_script_install_shopware
- *prepare_installation_script_install_plugin
- *prepare_files_script_config_override
- cd custom/plugins/${PLUGIN_NAME}
.phpunit_base_pre_v56:
extends: .phpunit_base
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:7.2
before_script:
- composer self-update --1
- *prepare_files_script
- *prepare_files_script_cookie_consent_manager
- *prepare_installation_script_install_shopware
- *prepare_installation_script_install_cookie_consent_manager_plugin
- *prepare_installation_script_install_plugin
- *prepare_files_script_config_override
- cd custom/plugins/${PLUGIN_NAME}
.phpunit_base_pre_v53:
extends: .phpunit_base_pre_v56
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:5.6
javascript-checks:
stage: code-analysis
image: node:alpine
services: []
before_script:
- apk add --no-cache make bash zip unzip git
- zip -rq plugin.zip .
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/5/product/shopware.git shopware --depth=1 -b ${CHECKOUT_SHOPWARE_BRANCH}
- unzip -q plugin.zip -d shopware/custom/plugins/${PLUGIN_NAME}
script:
- cd shopware
- make .make.install.npm-dependencies
- cd custom/plugins/${PLUGIN_NAME}
- (cd Tests/E2E && npm install)
- make check-js-code
- make run-jest-tests
php-analysis:
extends: .phpunit_base
stage: code-analysis
script:
- composer require --dev phpcompatibility/php-compatibility
- ./vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility
- ./vendor/bin/phpcs -p --ignore="./vendor/,./PhpStan/" --standard="PHPCompatibility" --runtime-set testVersion 5.6 ./
- make fix-cs-dry
- php ../../../bin/console -e production -q # Initialise DIC (var/cache/production____REVISION____) for phpstan
- >
if [ $CI_PIPELINE_SOURCE == "schedule" ]; then
sed -i "s|reportUnmatchedIgnoredErrors: true|reportUnmatchedIgnoredErrors: false|g" phpstan.neon
fi
- make phpstan
artifacts:
code-coverage:
extends: .phpunit_base
script:
- php -d pcov.enabled="1" -d pcov.directory="${CI_PROJECT_DIR}" -d pcov.exclude='~(vendor|Tests)~'
../../../vendor/bin/phpunit
--stderr
--configuration="phpunit.xml.dist"
--colors="never"
--log-junit="${ARTIFACTS_ROOT}/phpunit.junit.xml"
--coverage-cobertura=${ARTIFACTS_ROOT}/phpunit-coverage.cobertura.xml
--coverage-text | 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
- sed -i 's/\/shopware\/custom\/plugins\/SwagPaymentPayPalUnified//' ${ARTIFACTS_ROOT}/phpunit-coverage.cobertura.xml # Remove the shopware installation part from the <sources> tag, so the coverage paths are relative to the original plugin root again, not the one inside custom/plugins.
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
artifacts:
reports:
junit: ${ARTIFACTS_ROOT}/*.junit.xml
coverage_report:
coverage_format: cobertura
path: ${ARTIFACTS_ROOT}/phpunit-coverage.cobertura.xml
expire_in: 1 week
shopware-v5.2:
extends: .phpunit_base_pre_v53
stage: shopware-versions
variables:
CHECKOUT_SHOPWARE_BRANCH: "5.2"
CHECKOUT_COOKIE_CONSENT_MANAGER_BRANCH: "5.2.11-5.2.27"
shopware-v5.3:
extends: .phpunit_base_pre_v56
stage: shopware-versions
variables:
CHECKOUT_SHOPWARE_BRANCH: "5.3"
CHECKOUT_COOKIE_CONSENT_MANAGER_BRANCH: "5.3.5-5.3.7"
only:
- master
shopware-v5.4:
extends: .phpunit_base_pre_v56
stage: shopware-versions
variables:
CHECKOUT_SHOPWARE_BRANCH: "5.4"
CHECKOUT_COOKIE_CONSENT_MANAGER_BRANCH: "5.4.6"
only:
- master
shopware-v5.5:
extends: .phpunit_base_pre_v56
stage: shopware-versions
variables:
CHECKOUT_SHOPWARE_BRANCH: "5.5"
CHECKOUT_COOKIE_CONSENT_MANAGER_BRANCH: "5.5.0-5.5.10"
only:
- master
shopware-v5.6:
extends: .phpunit_base_pre_v57
stage: shopware-versions
variables:
CHECKOUT_SHOPWARE_BRANCH: "5.6"
only:
- master
shopware-v5.7-php-v7.4:
extends: .phpunit_base
only:
- master
shopware-v5.7-php-v8.0:
extends: .phpunit_base
image: gitlab.shopware.com:5005/shopware/5/product/image/continuous:8.0