forked from ptthao-yrglmvn/ec-cube2
-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (215 loc) · 7.44 KB
/
e2e-tests.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
name: E2E testing for EC-CUBE
run-name: E2E testing for EC-CUBE
on:
workflow_call:
inputs:
ref_name:
required: false
type: string
base_ref:
required: false
type: string
event_name:
required: true
type: string
owner:
required: true
type: string
jobs:
run-on-linux:
name: Run on Linux
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
pattern:
- 'test:e2e'
- 'test:e2e-extends'
group:
- 'test/front_login'
- 'test/front_guest'
- 'test/admin'
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4-rc' ]
db: [ mysql, pgsql ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build docker image
uses: ./.github/actions/dockerbuild
with:
php-version: ${{ matrix.php }}
# - name: Create ADMIN_DIR
# run: |
# sudo apt-fast install -y sharutils
# echo "ADMIN_DIR=$(head -c 10 < /dev/random | uuencode -m - | tail -n 2 |head -n 1 | sed 's,[/+],_,g' | head -c10)/" >> $GITHUB_ENV
- name: Setup environment
env:
REF_NAME: ${{ inputs.ref_name }}
BASE_REF: ${{ inputs.base_ref }}
EVENT_NAME: ${{ inputs.event_name }}
OWNER: ${{ inputs.owner }}
DB: ${{ matrix.db }}
PHP: ${{ matrix.php }}
PATTERN: ${{ matrix.pattern }}
GROUP: ${{ matrix.group }}
run: |
echo "COMPOSE_FILE=docker-compose.yml:docker-compose.${DB}.yml:docker-compose.dev.yml" >> $GITHUB_ENV
echo "IMAGE_NAME=${OWNER,,}/ec-cube2-php" >> $GITHUB_ENV
if [ $EVENT_NAME = "pull_request" ]; then
if [ -n $DOCKER_METADATA_OUTPUT_VERSION ]; then
echo "TAG=${DOCKER_METADATA_OUTPUT_VERSION}" >> $GITHUB_ENV
else
echo "TAG=${PHP}-apache-${BASE_REF}" >> $GITHUB_ENV
fi
else
echo "TAG=${PHP}-apache-${REF_NAME}" >> $GITHUB_ENV
fi
echo "PATTERN=${PATTERN//:/-}" >> $GITHUB_ENV
echo "GROUP=${GROUP//\//-}" >> $GITHUB_ENV
- if: matrix.pattern == 'test:e2e-extends'
run: cp -rp tests/class/fixtures/page_extends/* data/class_extends/page_extends
- name: Setup to EC-CUBE
run: |
docker compose up -d --wait
while [ ! -e "data/config/config.php" ]
do
printf "."
sleep 1
done
docker compose exec -T ec-cube composer install
docker compose exec -T ec-cube composer require ec-cube2/cli "dev-master@dev" -W
docker compose exec -T ec-cube composer update 'symfony/*' -W
docker compose exec -T ec-cube php data/vendor/bin/eccube eccube:fixtures:generate --products=5 --customers=1 --orders=5
- if: ${{ matrix.db == 'pgsql' }}
run: |
docker compose exec -T postgres psql --user=eccube_db_user eccube_db -c "UPDATE dtb_customer SET email = '[email protected]' WHERE customer_id = (SELECT MAX(customer_id) FROM dtb_customer WHERE status = 2 AND del_flg = 0);"
- if: ${{ matrix.db == 'mysql' }}
run: |
docker compose exec mysql mysql --user=eccube_db_user --password=password eccube_db -e "UPDATE dtb_customer SET email = '[email protected]' WHERE customer_id = (SELECT customer_id FROM (SELECT MAX(customer_id) FROM dtb_customer WHERE status = 2 AND del_flg = 0) AS A);"
- run: sleep 1
- run: |
yarn install
yarn run playwright install --with-deps chromium
yarn playwright install-deps chromium
- name: Run to E2E testing
env:
GROUP: ${{ matrix.group }}
PATTERN: ${{ matrix.pattern }}
CI: 1
FORCE_COLOR: 1
run: yarn ${PATTERN} e2e-tests/${GROUP}
- name: Upload evidence
if: failure()
uses: actions/upload-artifact@v4
with:
name: linux-php${{ matrix.php }}-${{ matrix.db }}-${{ env.PATTERN }}-${{ env.GROUP }}-evidence
path: 'test-results/'
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: linux-php${{ matrix.php }}-${{ matrix.db }}-${{ env.PATTERN }}-${{ env.GROUP }}-logs
path: data/logs
installer:
name: Installer test
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
db: [ 'pgsql', 'mysql' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4-rc' ]
include:
- db: mysql
dbport: '3306'
dbuser: 'eccube_db_user'
dbpass: 'password'
dbname: 'eccube_db'
dbhost: 'mysql'
- db: pgsql
dbport: '5432'
dbuser: 'eccube_db_user'
dbpass: 'password'
dbname: 'eccube_db'
dbhost: 'postgres'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build docker image
uses: ./.github/actions/dockerbuild
with:
php-version: ${{ matrix.php }}
- name: Setup environment
env:
REF_NAME: ${{ inputs.ref_name }}
BASE_REF: ${{ inputs.base_ref }}
EVENT_NAME: ${{ inputs.event_name }}
OWNER: ${{ inputs.owner }}
DB: ${{ matrix.db }}
PHP: ${{ matrix.php }}
run: |
echo "COMPOSE_FILE=docker-compose.yml:docker-compose.${DB}.yml:docker-compose.dev.yml" >> $GITHUB_ENV
echo "IMAGE_NAME=${OWNER,,}/ec-cube2-php" >> $GITHUB_ENV
if [ $EVENT_NAME = "pull_request" ]; then
if [ -n $DOCKER_METADATA_OUTPUT_VERSION ]; then
echo "TAG=${DOCKER_METADATA_OUTPUT_VERSION}" >> $GITHUB_ENV
else
echo "TAG=${PHP}-apache-${BASE_REF}" >> $GITHUB_ENV
fi
else
echo "TAG=${PHP}-apache-${REF_NAME}" >> $GITHUB_ENV
fi
- name: Setup to EC-CUBE
env:
PHP_VERSION_TAG: ${{ matrix.php }}
run: |
sudo chown -R 1001:1000 zap
sudo chmod -R g+w zap
sh -c 'echo "<?php" >> data/config/config.php'
docker compose up -d --wait
docker compose exec -T ec-cube composer install
- run: sleep 1
- run: |
yarn install
yarn run playwright install --with-deps chromium
yarn playwright install-deps chromium
- run: |
rm data/config/config.php
chmod -R o+w html
chmod o+w data
chmod -R o+w data/Smarty
chmod -R o+w data/cache
chmod -R o+w data/class
chmod -R o+w data/class_extends
chmod o+w data/config
chmod -R o+w data/download
chmod -R o+w data/downloads
chmod o+w data/fonts
chmod o+w data/include
chmod o+w data/logs
chmod -R o+w data/module
chmod o+w data/smarty_extends
chmod o+w data/upload
chmod o+w data/upload/csv
- name: Run to E2E testing
env:
CI: 1
FORCE_COLOR: 1
DB_TYPE: ${{ matrix.db }}
DB_USER: ${{ matrix.dbuser }}
DB_PASSWORD: ${{ matrix.dbpass }}
DB_NAME: ${{ matrix.dbname }}
DB_PORT: ${{ matrix.dbport }}
DB_SERVER: ${{ matrix.dbhost }}
run: yarn test:e2e e2e-tests/test/installer/installer.test.ts
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: linux-php${{ matrix.php }}-${{ matrix.db }}-logs
path: html/install/temp/install.log*
- name: Upload evidence
if: failure()
uses: actions/upload-artifact@v4
with:
name: linux-php${{ matrix.php }}-${{ matrix.db }}-evidence
path: 'test-results/'