-
-
Notifications
You must be signed in to change notification settings - Fork 145
218 lines (186 loc) · 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
name: "🎳 End2end"
on:
pull_request:
types: [ labeled, opened, synchronize, reopened ]
branches:
- master
- release_3_*
workflow_dispatch:
repository_dispatch:
types: [ run-e2e-branches ]
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: "End-to-end"
runs-on: ubuntu-latest
defaults:
run:
working-directory: tests
env:
CYPRESS_CI: TRUE
# For testing only
# PHP_VERSION: 8.3
# LZMPOSTGISVERSION: 16-3
# LZMQGSRVVERSION: 3.34
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
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}
- name: Make environment and show Lizmap versions
run: |
make env
cat .env
# For testing only
# - name: Update projects
# 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 docker images ready and install Lizmap
run: |
sleep 30
./lizmap-ctl install
- 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
# Playwright
- uses: actions/setup-node@v4
- name: Install dependencies
run: |
cd end2end
npm ci
- name: Install Playwright
run: |
cd end2end
npx playwright install --with-deps chromium
- name: Run Playwright tests
id: test-playwright
run: |
cd end2end
npx playwright test --project=end2end
# - name: Generate PG dump from Playwright
# if: failure()
# run: |
# ./lizmap-ctl dump-pgsql
#
# - name: Check the database diff from Playwright
# if: failure()
# run: |
# git diff qgis-projects/tests/tests_dataset.sql
# git restore qgis-projects/tests/tests_dataset.sql
- name: Notify in case of playwright failure, from mainstream branches only
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:
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: failure()
uses: actions/[email protected]
with:
name: playwright-report
path: tests/end2end/playwright-report
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
id: test-cypress
# Always run, even if playwright has failed
if: always()
uses: cypress-io/[email protected]
with:
browser: chrome
headed: true
working-directory: tests/end2end
spec: cypress/integration/*-ghaction.js
wait-on: http://localhost:8130
- 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:
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: cypress-screenshots
path: |
tests/end2end/cypress/screenshots
tests/end2end/cypress/downloads
# - name: Generate PG dump from Cypress
# if: failure()
# run: |
# ./lizmap-ctl dump-pgsql
#
# - name: Check the database diff from Cypress
# if: failure()
# run: |
# git diff qgis-projects/tests/tests_dataset.sql
# git restore qgis-projects/tests/tests_dataset.sql
# [[ -z $(git status --porcelain -uno) ]]
# exit $?
# debug:
# name: "Debug"
# runs-on: ubuntu-latest
# steps:
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo "$GITHUB_CONTEXT"