-
Notifications
You must be signed in to change notification settings - Fork 12
243 lines (199 loc) · 8.64 KB
/
Copy pathplaywright.yml
File metadata and controls
243 lines (199 loc) · 8.64 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Playwright
on:
push:
branches:
- master
- '*.x'
pull_request:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
update_all_screenshots:
description: 'Update all screenshots?'
type: boolean
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./rapidez/rapidez
strategy:
fail-fast: false
matrix:
include:
- magento-version: 2.4.7-p10
magento-php-version: php83-fpm
rapidez-php-version: 8.3
- magento-version: 2.4.8-p5
magento-php-version: php84-fpm
rapidez-php-version: 8.4
- magento-version: 2.4.9
magento-php-version: php85-fpm
rapidez-php-version: 8.5
screenshots: true
services:
magento:
image: michielgerritsen/magento-project-community-edition:${{matrix.magento-php-version}}-magento${{matrix.magento-version}}-sample-data
env:
URL: http://localhost:1234/
FLAT_TABLES: true
CUSTOM_ENTRYPOINT_COMMAND: "php bin/magento encryption:key:change -k 5AM3SD5SkwT8iwIxL6L1q8XQhzK3wk51; magerun2 config:store:set system/smtp/disable 1; magerun2 config:store:set checkout/options/enable_guest_checkout_login 1; magerun2 config:store:delete design/head/includes"
ports:
- 3307:3306
- 1234:80
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.2
ports:
- 9200:9200
env:
discovery.type: single-node
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
http.cors.enabled: "true"
http.cors.allow-credentials: "true"
http.cors.allow-origin: "http://localhost:8000"
http.cors.allow-headers: X-Requested-With, X-Auth-Token, Content-Type, Content-Length, Authorization, Access-Control-Allow-Headers, Accept
xpack.security.enabled: "false"
options: >-
--health-cmd="curl http://localhost:9200/_cluster/health"
--health-interval=10s
--health-timeout=5s
--health-retries=10
name: P${{ matrix.rapidez-php-version }} - M${{matrix.magento-version}} on ${{matrix.magento-php-version}}
steps:
- uses: actions/checkout@v4
with:
path: rapidez/core
fetch-depth: 0
lfs: true
- uses: actions/checkout@v4
with:
repository: rapidez/rapidez
path: rapidez/rapidez
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.rapidez-php-version }}
extensions: mbstring, dom, fileinfo, mysql
coverage: none
- name: Copy testing .env
run: cp ../core/tests/playwright/.env.testing .env
- name: Use rapidez/core from source
run: composer config repositories.core path ../core
- name: Make the Magento version available as env variable
run: echo "MAGENTO_VERSION=${{ matrix.magento-version }}" >> $GITHUB_ENV
- name: Get commit hash and tag of the core
working-directory: ./rapidez/core
run: |
echo "CORE_HASH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse HEAD | sed 's|/|_|g')" >> $GITHUB_ENV
echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Get correct version name for require
run: echo "REQUIRE_VERSION=$([[ '${{ env.CORE_HASH }}' =~ ^[0-9]+\.[xX]$ ]] && echo '${{ env.CORE_HASH }}-dev' || echo 'dev-${{ env.CORE_HASH }}')" >> $GITHUB_ENV
- name: Composer require the local rapidez/core
run: composer require rapidez/core:"${{ env.REQUIRE_VERSION }} as ${{ env.LATEST_TAG }}"
- name: Install Rapidez command
run: php artisan rapidez:install --frontendonly
- name: Publish payment icons
run: php artisan vendor:publish --tag=payment-icons
- name: Install Yarn dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Frontend Build
run: yarn run prod
- name: Install Playwright tests
run: php artisan rapidez:install:tests
- name: Wait for index to finish
run: for i in {1..60}; do [[ $(mysql -h 127.0.0.1 -P 3307 -u magento -ppassword -ss -r -e "CALL sys.table_exists('magento', 'catalog_product_flat_1', @exists); SELECT @exists;") == *"BASE TABLE"* ]] && break || sleep 5; done
- name: Add tier prices
run: mysql -h 127.0.0.1 -P 3307 -u magento -ppassword magento -ss < vendor/rapidez/core/tests/database/tier-prices.sql
- name: Rapidez index
run: php artisan rapidez:index
- name: Start the webserver
run: php artisan serve &
- name: Run Playwright tests
if: ${{ !inputs.update_all_screenshots }}
run: yarn playwright test
# Screenshots
- name: Collect failed tests
if: ${{ failure() && !inputs.update_all_screenshots }}
run: yarn playwright test --last-failed --list --reporter=dot --pass-with-no-tests > failed-tests.txt
- name: Update screenshots
if: ${{ failure() && !inputs.update_all_screenshots && matrix.screenshots == true && github.event_name != 'schedule' && !(github.event_name == 'push' && (github.ref_name == 'master' || endsWith(github.ref_name, '.x'))) }}
run: |
while read -r test_name; do
yarn playwright test "$test_name" --update-snapshots --reporter=list
done < <(awk -F ' › ' 'NF>1{print $2}' failed-tests.txt | sort -u)
- name: Update all screenshots
if: ${{ inputs.update_all_screenshots && matrix.screenshots == true }}
run: yarn playwright test --update-snapshots
- name: Move the screenshots
if: (failure() || inputs.update_all_screenshots) && matrix.screenshots == true && github.event_name != 'schedule' && !(github.event_name == 'push' && (github.ref_name == 'master' || endsWith(github.ref_name, '.x')))
run: cp -r tests/playwright/. ../core/tests/playwright/
- name: Commit the screenshots
if: (failure() || inputs.update_all_screenshots) && matrix.screenshots == true && github.event_name != 'schedule' && !(github.event_name == 'push' && (github.ref_name == 'master' || endsWith(github.ref_name, '.x')))
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[CI] Update Snapshots"
repository: rapidez/core
# Artifact
- name: Dump docker logs
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: './docker-logs'
- name: Dump magento logs
if: failure()
working-directory: ${{ github.workspace }}
run: |
mkdir -p magento/var
docker cp ${{ job.services.magento.id }}:/data/var/log magento/var/log
- name: Upload Artifact
if: failure()
uses: actions/upload-artifact@v4
with:
name: artifact-P${{ matrix.rapidez-php-version }}-M${{matrix.magento-version}}-on-${{matrix.magento-php-version}}
path: |
rapidez/rapidez/blob-report
rapidez/rapidez/storage/logs/laravel.log
docker-logs
magento/var/log
report:
if: failure()
needs: [test]
runs-on: ubuntu-latest
env:
HTML_REPORT_PATH: ${{ github.repository }}/${{ github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }}
steps:
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install @playwright/test
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./reports
merge-multiple: true
- name: Generate HTML report
run: npx playwright merge-reports --reporter html ./reports/rapidez/rapidez/blob-report
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report
- name: Push to Cloudflare R2
uses: ryand56/r2-upload-action@v1.4
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: ./playwright-report
destination-dir: ${{ env.HTML_REPORT_PATH }}
- name: URL in summary
run: echo "### Test results - https://playwright.rapidez.io/${{ env.HTML_REPORT_PATH }}/index.html" >> $GITHUB_STEP_SUMMARY