forked from devicezero/platformsh-shopware6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
223 lines (207 loc) · 8.54 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
variables:
GIT_STRATEGY: clone
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
# The platform branch used to split the repos
PLATFORM_BRANCH: "6.2"
# minimum stability of the new version. Example: v6.2.0-RC2 -> if rc: v6.2.0-RC3, if stable: v6.2.0
MINIMUM_STABILITY: "stable"
include:
- local: .gitlab-ci/release.yml
- local: .gitlab-ci/test_base.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_$PLATFORM_BRANCH"
paths:
- .platform
- .composer
- .apt
- .npm
policy: pull-push
before_script:
- apt-get update
- DEB_PACKAGES="git jq composer php-dom php-tokenizer php-xmlwriter php-xml curl docker.io build-essential nodejs"
# 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
- git config --global user.email $GIT_EMAIL
- git config --global user.name $GIT_USER
script:
# clone platform if it's not cached
- '[[ -d .platform/ ]] || git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.shopware.com/shopware/6/product/platform.git -b ${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
# fetch newest changes from $PLATFORM_BRANCH
- git -C .platform fetch origin ${PLATFORM_BRANCH}
# set HEAD to newest commit in $PLATFORM_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
- export TAG=${TAG:-$(.gitlab-ci/tools/console show-next-tag --minimum-stability "$MINIMUM_STABILITY")}
- export IMAGE_TAG=${TAG}-dev
# build test package
- .gitlab-ci/build-nightly.sh
- docker build . -t "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
- mkdir artifacts || true
- chmod 777 artifacts || true
# 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}
- mv artifacts/install.tar.xz artifacts/install_${IMAGE_TAG}.tar.xz
- echo ${TAG} > artifacts/TAG
artifacts:
expire_in: 1 week
paths:
- artifacts/
- repos/
# Unit tests
Unit PHP 7.2:
extends: .unit_base
image: shopware/development:7.2
Unit PHP 7.3:
extends: .unit_base
image: shopware/development:7.3
Unit PHP 7.4:
extends: .unit_base
image: shopware/development:7.4
Unit MySQL 5.7:
extends: .unit_base
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 MySQL 8.0:
extends: .unit_base
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" ]
Unit MariaDB 10.4:
extends: .unit_base
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" ]
# e2e install tests
Install:
extends: .e2e_base
variables:
GIT_STRATEGY: none
before_script:
- export TAG=$(cat artifacts/TAG)
- export CYPRESS_CACHE_FOLDER="${PWD}/.cypress"
- npm config set cache $PWD/.npm
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
--env expectedVersion=$TAG
--spec cypress/integration/installer/basic.spec.js
# e2e update tests
Manual Upd 6.2.0:
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
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0
--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
--env expectedVersion=$TAG
--spec cypress/integration/updater/storefront.spec.js
.E2E Update:
extends: .e2e_update_base
script:
- cd .gitlab-ci/e2e/test/
- timeout 20m $(npm bin)/cypress run
--browser chrome --config baseUrl=http://localhost:8000,numTestsKeptInMemory=0
--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
--env expectedVersion=$TAG
--spec cypress/integration/updater/storefront.spec.js
artifacts:
when: always
expire_in: 1 week
paths:
- .gitlab-ci/e2e/test/artifacts/*
- var/log/*
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.1.1
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"
Update:
extends: .E2E Update
variables:
E2E_INSTALL_PACKAGE_URL: $REFERENCE_INSTALLER_URL
E2E_TEST_DATA_FILE: "v6.1.6_test_data.tar.xz"