-
-
Notifications
You must be signed in to change notification settings - Fork 146
346 lines (306 loc) · 12.7 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
name: "🎳 End2end"
on:
pull_request:
types: [ labeled, opened, synchronize, reopened ]
branches:
- master
- release_3_*
workflow_dispatch:
repository_dispatch:
types: [ run-e2e-branches ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
end2end:
# The first condition is triggered when we set the new label
# The second one when we update the PR with new commits without changing labels
# The third one when external workflow
# The fourth one is for the manual button
if: |
github.event.label.name == 'run end2end' ||
contains(github.event.pull_request.labels.*.name, 'run end2end') ||
github.event_name == 'repository_dispatch' ||
github.event_name == 'workflow_dispatch'
name: "E2E QGIS ${{ matrix.qgis-server }} PG ${{ matrix.pg-postgis }} PHP ${{ matrix.php }}"
runs-on: ubuntu-latest
defaults:
run:
working-directory: tests
strategy:
fail-fast: false
matrix:
include:
- name: "LEGACY"
php: "8.1"
pg-postgis: "14-3"
qgis-server: "3.34"
update-projects: "FALSE"
- name: "BLEEDING_EDGE"
php: "8.3"
pg-postgis: "17-3"
qgis-server: "3.40"
update-projects: "FALSE"
env:
CYPRESS_CI: TRUE
PLAYWRIGHT_FORCE_TTY: true
PLAYWRIGHT_LIST_PRINT_STEPS: true
PLAYWRIGHT_JSON_OUTPUT_DIR: ${{ github.workspace }}/tests/end2end/playwright-report
PLAYWRIGHT_OPTIONS: --project=end2end --fail-on-flaky-tests
FORCE_COLOR: true
steps:
# - name: Debug
# working-directory: .
# run: |
# echo ${{ github.event.pull_request.head.sha }}
# echo ${{ github.head_ref }}
# echo ${{ github.ref_name }}
- name: Define branch name from env for the checkout
working-directory: .
run: |
if ${{ github.event_name == 'repository_dispatch' }}
then
# repository_dispatch is from an external workflow, for instance a cron workflow
echo "Set branch from manual input: ${{ github.event.client_payload.branch }}"
BRANCH="${{ github.event.client_payload.branch }}"
elif ${{ github.event_name == 'workflow_dispatch' }}
then
# workflow_dispatch is the the button in UI
echo "Set branch from default value: ${{ github.ref }}"
BRANCH="${{ github.ref }}"
else
# From a PR
echo "Event type ${{ github.event_name }}"
echo "Set branch from default value : ${{ github.event.pull_request.head.sha }} "
BRANCH="${{ github.event.pull_request.head.sha }}"
fi
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
id: checkout
with:
ref: ${{ env.BRANCH }}
token: ${{ secrets.BOT_HUB_TOKEN || github.token }} # Important to launch CI on a commit from a bot
- name: Branch name
run: echo running on branch ${GITHUB_REF##*/} with CYPRESS = ${CYPRESS_CI} and commit ${{ steps.checkout.outputs.commit }}
- name: Make environment and show Lizmap versions
env:
PHP_VERSION: ${{ matrix.php }}
LZMPOSTGISVERSION: ${{ matrix.pg-postgis }}
LZMQGSRVVERSION: ${{ matrix.qgis-server }}
run: |
mkdir -p ${{env.PLAYWRIGHT_JSON_OUTPUT_DIR}}
make env
cat .env
- name: Read environment file and set variables
uses: cosq-network/[email protected]
with:
# Somehow, the working-directory is not taken into account
env-file: tests/.env
# For testing only
- name: Update projects
if: ${{ matrix.update-projects == 'TRUE' }}
run: |
make upgrade-projects
git status
- name: Install QGIS server plugins
run: make build-plugins
- name: Show QGIS server environment
run: |
make show-qgis-server-versions
- name: Pull docker images
run: ./run-docker pull
- name: Build and start docker images
run: ./run-docker up --build -d
- name: Wait 30 secondes for docker images to be ready
run: |
sleep 30
- name: Install Lizmap
# Quick dirty hack "| true" about duplicated key
# Error: An error occured during the installation of the module lizmapdemo:
# invalid query (ERROR: duplicate key value violates unique constraint "jacl2_group_id_aclgrp_pk"
# DETAIL: Key (id_aclgrp)=(__priv_lizadmin) already exists.(INSERT INTO "jacl2_group" (
# "id_aclgrp","name","grouptype","ownerlogin"
# ) VALUES (
# '__priv_lizadmin', 'lizadmin', 2, 'lizadmin'
# )))
# Installation is finished
run: |
./lizmap-ctl install | true
- name: Wait and check about QGIS Server status
run: |
curl \
--user 'admin:admin' \
--retry 30 \
--retry-delay 5 \
-N \
"http://localhost:8130/index.php/view/app/metadata" \
-o /tmp/test-qgis-server.json
cat /tmp/test-qgis-server.json | jq .qgis_server_info
qgis_info=$(cat /tmp/test-qgis-server.json | jq --raw-output '.qgis_server_info.error')
echo $qgis_info
if [[ "$qgis_info" != "null" ]]; then
echo "QGIS Server is not well configured"
echo "::warning QGIS Server was not up"
else
echo "JSON metadata OK about QGIS Server"
fi
- name: Check about updated files after a build (PHP or JS)
run: |
if [[ -z $(git status --porcelain -uno) ]]; then
echo "No updated files 👍"
else
echo "Updated files"
git status
echo "::warning Git status is not clean"
# exit 1
fi
- name: Load SQL data
run: |
cd qgis-projects/tests
./load_sql.sh
- name: Add hosts to /etc/hosts
run: |
sudo echo "127.0.0.1 othersite.local" | sudo tee -a /etc/hosts
- uses: actions/setup-node@v4
with:
node-version: 21
cache: 'npm'
cache-dependency-path: ${{ github.workspace }}/package.json
- name: Install dependencies
working-directory: ./
run: |
npm ci
- name: Install Playwright
working-directory: tests/end2end
run: |
npx playwright install --with-deps chromium
- name: Run Playwright tests read-only
id: test-playwright-read-only
working-directory: tests/end2end
env:
CRTF_JSON_FILE: ${{ matrix.name }}
PLAYWRIGHT_JSON_OUTPUT_NAME: tests-results-readonly.json
run: |
npx playwright test --grep @readonly ${{ env.PLAYWRIGHT_OPTIONS }}
- name: Prepare the database diff from Playwright read only
run: |
./lizmap-ctl dump-pgsql
git diff --exit-code qgis-projects/tests/tests_dataset.sql
db_diff=$?
echo "db_diff=${db_diff}" >> "$GITHUB_OUTPUT"
if [[ -z ${db_diff} ]]; then
echo "No updated files 👍"
else
echo "Updated files"
git diff qgis-projects/tests/tests_dataset.sql > qgis-projects/tests/tests_dataset.patch
git restore qgis-projects/tests/tests_dataset.sql
echo "::warning Git status is not clean after running tests about the DB"
exit 0
fi
- name: Upload DB results
if: success() || steps.test-playwright-read-only.conclusion == 'failure'
uses: actions/[email protected]
with:
name: ${{ matrix.name }}-DB-diff-read-only
path: |
${{ github.workspace }}/tests/qgis-projects/tests/tests_dataset.patch
- name: Check about updated files after a read only tests
run: |
if [[ -z $(git status --porcelain -uno) ]]; then
echo "No updated files 👍"
else
echo "Updated files"
git status
echo "::warning Git status is not clean after running tests about tracked files"
fi
- name: Run Playwright tests not tagged read-only
id: test-playwright-not-read-only
working-directory: tests/end2end
env:
PLAYWRIGHT_JSON_OUTPUT_NAME: tests-results-not-readonly.json
if: success() || steps.test-playwright-read-only.conclusion == 'failure'
run: |
npx playwright test --workers 1 --grep-invert @readonly ${{ env.PLAYWRIGHT_OPTIONS }}
- name: Publish test report
if: always()
uses: ctrf-io/github-test-reporter@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
report-path: './tests/end2end/ctrf/*.json'
summary-report: true
flaky-report: true
# pull-request-report: true
summary: true
pull-request: true
title: Read and write tests ${{ matrix.NAME }}
annotate: false
overwrite-comment: true
comment-tag: '${{ github.workflow }}-${{ github.job }}'
- name: Notify in case of playwright failure, from mainstream branches only
# Check for playwright tests with and without tags "readonly"
uses: peter-evans/commit-comment@v3
if: github.repository == '3liz/lizmap-web-client' && failure() && steps.test-playwright.outcome != 'success' && github.event_name == 'repository_dispatch'
with:
sha: ${{ steps.checkout.outputs.commit }}
token: ${{ secrets.BOT_HUB_TOKEN }}
body: |
The latest **weekly** run of end2end "playwright" tests failed with this latest commit on the branch **${{ env.BRANCH }}** 😣
CC @nboisteault and @Gustry, please have a look to the logs. Maybe it's a false positive ?
Visit ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Upload test results
if: success() || steps.test-playwright-read-only.conclusion == 'failure' || steps.test-playwright-not-read-only.conclusion == 'failure'
uses: actions/[email protected]
with:
name: ${{ matrix.name }}-playwright-report
path: ${{ github.workspace }}/tests/end2end/playwright-report
- name: Cypress run
id: test-cypress
# Always run, even if playwright has failed
if: success() || steps.test-playwright-read-only.conclusion == 'failure' || steps.test-playwright-not-read-only.conclusion == 'failure'
uses: cypress-io/[email protected]
with:
install: false
browser: chrome
headed: true
working-directory: tests/end2end
spec: cypress/integration/*-ghaction.js
wait-on: http://localhost:8130
- name: Export some logs to files
if: always()
run: |
mkdir -p /tmp/e2e/lwc
mkdir -p /tmp/e2e/docker
docker logs lizmap${{ env.LZMBRANCH }}_test_qgis &> /tmp/e2e/docker/qgis-server.log | true
docker logs lizmap${{ env.LZMBRANCH }}_test_php &> /tmp/e2e/docker/php.log | true
docker logs lizmap${{ env.LZMBRANCH }}_test_nginx &> /tmp/e2e/docker/nginx.log | true
cp -r ../lizmap/var/log /tmp/e2e/lwc/
- name: Upload all logs as artifact
uses: actions/[email protected]
if: always()
with:
name: ${{ matrix.name }}-E2E-all-logs
path: |
/tmp/e2e/
- name: Notify in case of cypress failure, from mainstream branches only
uses: peter-evans/commit-comment@v3
if: github.repository == '3liz/lizmap-web-client' && failure() && steps.test-cypress.outcome != 'success' && github.event_name == 'repository_dispatch'
with:
sha: ${{ steps.checkout.outputs.commit }}
token: ${{ secrets.BOT_HUB_TOKEN }}
body: |
The latest **weekly** run of end2end "cypress" tests failed with this latest commit on the branch **${{ env.BRANCH }}** 😣
CC @nboisteault and @Gustry, please have a look to the logs. Maybe it's a false positive ?
Visit ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Save screenshots as artifacts if a test fails to ease debug
uses: actions/[email protected]
if: failure()
with:
name: ${{ matrix.name }}-cypress-screenshots
path: |
tests/end2end/cypress/screenshots
tests/end2end/cypress/downloads
- name: Database diff check after readonly tests
run:
exit ${{ env.db_diff }}