-
-
Notifications
You must be signed in to change notification settings - Fork 143
171 lines (145 loc) · 6.14 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
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
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@v3
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: Install Lizmap as a QGIS Server plugin
run: make build-plugins
- name: Show Lizmap environment and versions
# Not available in QGIS 3.16, which is used in LWC 3.5
if: ${{ env.BRANCH != 'release_3_5' }}
run: make show-qgis-server-versions && make env && cat .env
- 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@v3
- name: Install dependencies
run: cd end2end && npm ci
- name: Install Playwright
# No Playwright tests in LWC 3.5
if: ${{ env.BRANCH != 'release_3_5' }}
run: cd end2end && npx playwright install --with-deps chromium
- name: Run Playwright tests
id: test-playwright
# No Playwright tests in LWC 3.5
if: ${{ env.BRANCH != 'release_3_5' }}
run: cd end2end && npx playwright test --project=chromium
- name: Notify in case of playwright failure, from mainstream branches only
uses: peter-evans/commit-comment@v2
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/upload-artifact@v3.1.2
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/github-action@v5.8.3
with:
browser: chrome
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@v2
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/upload-artifact@v3.1.2
if: failure()
with:
name: cypress-screenshots
path: |
tests/end2end/cypress/screenshots
tests/end2end/cypress/downloads
# debug:
# name: "Debug"
# runs-on: ubuntu-latest
# steps:
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo "$GITHUB_CONTEXT"