-
Notifications
You must be signed in to change notification settings - Fork 720
219 lines (194 loc) · 7.56 KB
/
Copy pathe2e-test.yml
File metadata and controls
219 lines (194 loc) · 7.56 KB
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
name: E2E test for EC-CUBE
on:
workflow_call:
inputs:
php-versions:
description: 'テスト対象 PHP バージョンの JSON 配列'
type: string
default: "['8.2', '8.3', '8.4', '8.5']"
workflow_dispatch:
inputs:
php-versions:
description: 'テスト対象 PHP バージョンの JSON 配列'
type: string
default: "['8.2', '8.3', '8.4', '8.5']"
permissions:
contents: read
jobs:
playwright:
name: Playwright (${{ matrix.suite }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php: ${{ fromJSON(inputs.php-versions) }}
db: [ pgsql ]
suite:
- admin-top
- admin-auth
- admin-product
- admin-order
- admin-shipping
- admin-customer
- admin-contents
- admin-basicinfo
- admin-system
- front-top
- front-product
- front-customer
- front-other
- front-order
- front-mypage
- front-invoice
- front-password-nist
include:
- db: pgsql
database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db
database_server_version: 18
services:
mailcatcher:
image: schickling/mailcatcher
ports:
- 1080:1080
- 1025:1025
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
## Docker Hub からの pull はタイムアウトで CI が不安定になるため、
## DB はコンテナではなく setup アクション (apt) でインストールする
- name: Setup PostgreSQL
uses: ankane/setup-postgres@6d3ffa1aa7498a42b79e9f9f5838b99971839300 # v1
with:
postgres-version: '18'
user: postgres
- name: Configure PostgreSQL
run: |
for _ in $(seq 1 30); do pg_isready -h 127.0.0.1 && break; sleep 1; done
pg_isready -h 127.0.0.1 || { echo 'PostgreSQL did not become ready within 30s'; exit 1; }
psql -h 127.0.0.1 -U postgres -c "ALTER USER postgres PASSWORD 'password'"
## DATABASE_URL と同一経路 (TCP/postgres/password) で接続できることを検証
PGPASSWORD=password psql -h 127.0.0.1 -U postgres -c 'SELECT VERSION()'
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: ${{ matrix.php }}
extensions: redis
- name: Enable register_argc_argv for Codeception
if: matrix.php == '8.5'
run: |
INI_FILE=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||" | tr -d '"')
echo "Using php.ini: $INI_FILE"
echo "register_argc_argv = On" | sudo tee -a "$INI_FILE"
php -i | grep register_argc_argv
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 20
- name: Initialize Composer
uses: ./.github/actions/composer
- name: Generate ECCUBE_AUTH_MAGIC
run: echo "ECCUBE_AUTH_MAGIC=$(openssl rand -hex 32)" >> $GITHUB_ENV
- name: Cache npm dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Cache build artifacts
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
id: build-cache
with:
path: |
html/template/**/css
html/bundle
key: ${{ runner.os }}-build-${{ hashFiles('html/template/**/scss/**/*.scss', 'html/template/**/js/**/*.js', 'package-lock.json', 'gulpfile.js', 'webpack.config.js', 'gulp/**/*.js') }}
restore-keys: |
${{ runner.os }}-build-
- name: Build Sass and JavaScript
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
npm ci
npm run build
- name: Setup to EC-CUBE
env:
APP_ENV: 'codeception'
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
ECCUBE_AUTH_MAGIC: ${{ env.ECCUBE_AUTH_MAGIC }}
run: |
echo "APP_ENV=${APP_ENV}" > .env
echo "TRUSTED_HOSTS=127.0.0.1,localhost" >> .env
echo "ECCUBE_AUTH_MAGIC=${ECCUBE_AUTH_MAGIC}" >> .env
bin/console doctrine:database:create --env=dev
bin/console doctrine:schema:create --env=dev
bin/console eccube:fixtures:load --env=dev
- name: Install Playwright dependencies
working-directory: e2e
run: npm ci
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('e2e/package-lock.json') }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: e2e
run: npx playwright install --with-deps chromium
- name: Install Playwright system deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
working-directory: e2e
run: npx playwright install-deps chromium
- name: Cache apt packages
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # latest
with:
packages: fonts-ipafont fonts-ipaexfont
version: 1.0
- name: Start PHP Development Server
env:
APP_ENV: 'codeception'
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
MAILER_DSN: 'smtp://127.0.0.1:1025'
ECCUBE_PACKAGE_API_URL: 'http://127.0.0.1:8080'
ECCUBE_AUTH_MAGIC: ${{ env.ECCUBE_AUTH_MAGIC }}
run: php -S 127.0.0.1:8000 codeception/router.php &
- name: Determine Playwright project
id: project
run: |
SUITE="${{ matrix.suite }}"
if [[ "$SUITE" == admin-* ]]; then
echo "project=admin-tests" >> $GITHUB_OUTPUT
elif [[ "$SUITE" == front-* ]]; then
echo "project=front-tests" >> $GITHUB_OUTPUT
fi
- name: Run Playwright tests
working-directory: e2e
env:
BASE_URL: 'http://127.0.0.1:8000'
DATABASE_URL: ${{ matrix.database_url }}
ECCUBE_ADMIN_ROUTE: 'admin'
ADMIN_USER: 'admin'
ADMIN_PASSWORD: 'password'
APP_ENV: 'codeception'
CI: 'true'
run: |
npx playwright test --project=setup --project=${{ steps.project.outputs.project }} ${{ matrix.suite }}.spec.ts
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: playwright-${{ matrix.suite }}-report
path: e2e/playwright-report/
- name: Upload ScreenShots
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: playwright-${{ matrix.suite }}-results
path: e2e/test-results/
- name: Upload logs
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: playwright-${{ matrix.suite }}-logs
path: var/log/