-
Notifications
You must be signed in to change notification settings - Fork 118
202 lines (179 loc) · 7.87 KB
/
ui-test.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
name: UI Tests
on:
## Check each PR
push:
branches:
- dev
- master
pull_request:
## Manual execution on branch
workflow_dispatch:
## Nightly
### Needs secrets
#### GC_PROJECT_ID
#### GC_SERVICE_KEY
#### NIGHTLY_TOKEN
schedule:
- cron: '0 0 * * *'
env:
CAMPAIGN: 'autoupgrade'
jobs:
ui_test_matrix:
if: github.event.pull_request.draft == false
name: UI Tests (Matrix)
runs-on: ubuntu-latest
env:
JSON_FILE: ${{ (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'dev' && github.event.pull_request.base.ref == 'master')) && 'nightly.json' || 'sanity.json' }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set matrix
id: set-matrix
run: echo "matrix=$(jq -c '. | del(.include[] | select(has("comment")))' .github/workflows/ui-test/${{ env.JSON_FILE }})" >> $GITHUB_OUTPUT
ui_test:
name: UI Tests
runs-on: ubuntu-latest
needs: ui_test_matrix
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.ui_test_matrix.outputs.matrix) }}
env:
PS_DOCKER: ${{ matrix.PS_VERSION_START }}-${{ matrix.PHP_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Start containers
working-directory: tests/UI/
env:
PS_VERSION: ${{ env.PS_DOCKER }}
run: |
docker compose -f "docker-compose.yml" up -d --build
bash -c 'while [[ "$(curl -L -s -o /dev/null -w %{http_code} http://localhost/)" != "200" ]]; do sleep 5; done'
- name: Composer install
run: composer install
- name: Backup
run: |
docker exec -t prestashop php modules/autoupgrade/bin/console backup:create admin-dev
- name: Download local ZIP and XML for local channel
if: matrix.UPGRADE_CHANNEL == 'local' && matrix.PS_VERSION_END != '9.0.0'
run: |
docker exec -t prestashop curl --fail -L https://github.com/PrestaShop/zip-archives/raw/main/prestashop_${{ matrix.PS_VERSION_END }}.zip -o admin-dev/autoupgrade/download/prestashop_${{ matrix.PS_VERSION_END }}.zip
docker exec -t prestashop curl --fail -L https://api.prestashop.com/xml/md5/${{ matrix.PS_VERSION_END }}.xml -o admin-dev/autoupgrade/download/prestashop_${{ matrix.PS_VERSION_END }}.xml
- name: Download local ZIP and XML for local channel in 9.0.0
if: matrix.PS_VERSION_END == '9.0.0'
run: |
docker exec -t prestashop curl --fail -L https://storage.googleapis.com/prestashop-core-nightly/nightly_9.0.x.zip -o admin-dev/autoupgrade/download/prestashop_${{ matrix.PS_VERSION_END }}.zip
docker exec -t prestashop curl --fail -L https://storage.googleapis.com/prestashop-core-nightly/nightly_9.0.x.xml -o admin-dev/autoupgrade/download/prestashop_${{ matrix.PS_VERSION_END }}.xml
- name: Write configuration file
run: |
docker exec -t prestashop sh -c "echo '{
\"channel\":\"${{ matrix.UPGRADE_CHANNEL }}\",
\"archive_zip\":\"prestashop_${{ matrix.PS_VERSION_END }}.zip\",
\"archive_xml\":\"prestashop_${{ matrix.PS_VERSION_END }}.xml\",
\"PS_AUTOUP_CUSTOM_MOD_DESACT\":\"true\",
\"PS_AUTOUP_CHANGE_DEFAULT_THEME\":\"false\",
\"PS_AUTOUP_KEEP_IMAGES\":\"true\",
\"PS_DISABLE_OVERRIDES\":\"true\"
}' > modules/autoupgrade/config.json"
- name: Update
run: |
docker exec -t prestashop php modules/autoupgrade/bin/console update:start --config-file-path=modules/autoupgrade/config.json --channel=${{ matrix.UPGRADE_CHANNEL }} admin-dev
docker exec -t prestashop chmod 777 -R /var/www/html/var
- name: Uninstall welcome module
if: matrix.PS_VERSION_START == '1.7.0.6' || matrix.PS_VERSION_START == '1.7.1.0' || matrix.PS_VERSION_START == '1.7.1.1' || matrix.PS_VERSION_START == '1.7.1.2'
run: |
docker exec -t prestashop php bin/console prestashop:module disable welcome
docker exec -t prestashop chmod 777 -R /var/www/html/var
- name: Install dependencies
working-directory: tests/UI/
run: npm ci
- name: Install Playwright Browsers
working-directory: tests/UI/
run: npx playwright install chromium --with-deps
- name: Run Sanity tests
working-directory: tests/UI/
env:
PS_VERSION: ${{ matrix.PS_VERSION_END }}
DB_USER: prestashop
DB_PASSWD: prestashop
DB_NAME: prestashop
DB_PREFIX: ps_
run: npx playwright test
- name: Rollback
run: |
backupName=$(docker exec -t prestashop bash -c "ls -td -- /var/www/html/admin-dev/autoupgrade/backup/*/ | head -n 1 | cut -d'/' -f8 | tr -d '\n'")
docker exec -t prestashop php modules/autoupgrade/bin/console backup:restore --backup=$backupName admin-dev
docker exec -t prestashop chmod 777 -R /var/www/html/app
- name: Run Sanity tests
working-directory: tests/UI/
env:
PS_VERSION: ${{ matrix.PS_VERSION_START }}
DB_USER: prestashop
DB_PASSWD: prestashop
DB_NAME: prestashop
DB_PREFIX: ps_
run: npx playwright test
- name: Export Docker errors
working-directory: tests/UI/
if: always()
run: docker compose logs --no-color >& docker-compose.log
- name: Upload artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-${{ matrix.PS_VERSION_START }}-${{ matrix.PS_VERSION_END }}-${{ matrix.UPGRADE_CHANNEL }}-${{ matrix.PHP_VERSION }}
path: |
tests/UI/reports/
tests/UI/report.json
tests/UI/docker-compose.log
retention-days: 30
nightly:
name: Nightly Report
if: ${{ github.event_name == 'schedule' }}
needs:
- ui_test_matrix
- ui_test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.ui_test_matrix.outputs.matrix) }}
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download report
uses: actions/download-artifact@v4
with:
name: playwright-report-${{ matrix.PS_VERSION_START }}-${{ matrix.PS_VERSION_END }}-${{ matrix.UPGRADE_CHANNEL }}-${{ matrix.PHP_VERSION }}
path: tests/UI/
# Nightly : Rename file
- name: "Nightly : Rename file"
working-directory: tests/UI/
run: |
mkdir -p nightly
REPORT_NAME="${{ env.CAMPAIGN }}_$(date +%Y-%m-%d)-${{ matrix.PS_VERSION_START }}_(Channel:_${{ matrix.UPGRADE_CHANNEL }}_PHP:_${{ matrix.PHP_VERSION }})"
mv report.json nightly/${REPORT_NAME}.json
# Nightly : Auth GCP
- name: "Nightly : Auth GCP"
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GC_SERVICE_KEY }}
project_id: ${{ secrets.GC_PROJECT_ID }}
# Nightly : Setup GCP
- name: "Nightly : Setup GCP"
uses: google-github-actions/setup-gcloud@v2
# Nightly : Upload to Google Cloud Storage (GCS)
- name: "Nightly : Upload to Google Cloud Storage (GCS)"
working-directory: tests/UI/
run: gsutil cp -r "nightly/**" gs://prestashop-core-nightly/reports
# Nightly : Push Report
- name: "Nightly : Push Report"
run: |
REPORT_NAME="${{ env.CAMPAIGN }}_$(date +%Y-%m-%d)-${{ matrix.PS_VERSION_START }}_(Channel:_${{ matrix.UPGRADE_CHANNEL }}_PHP:_${{ matrix.PHP_VERSION }})"
curl -v "https://api-nightly.prestashop-project.org/import/report/playwright?token=${{ secrets.NIGHTLY_TOKEN }}&filename=${REPORT_NAME}.json&campaign=${{ env.CAMPAIGN }}&platform=cli"