-
Notifications
You must be signed in to change notification settings - Fork 18
410 lines (338 loc) · 12.7 KB
/
robot-framework.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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
name: Integration tests on Robot Framework
on:
pull_request:
push:
branches:
- main
workflow_call:
workflow_dispatch:
env:
DOCKER_COMPOSE: docker compose -f docker-compose.local.yml --progress plain
APT_INSTALL: sudo apt-get -qq install -qq -o=Dpkg::Use-Pty=0 -y
GK_INSTANCE_COUNT: 3
SHARD_COUNT: 7
PGUSER: geokrety
PGPASSWORD: geokrety
PGDATABASE: geokrety
PGHOST: localhost
PGPORT: 5106
GK_FQDN: localhost
GIT_BRANCH: ${{ github.head_ref || github.ref }}
permissions:
pull-requests: write
jobs:
robot-framework:
if: "${{ ! (contains(github.event.head_commit.message, 'skip tests-qa') || github.event.pull_request.title == 'translation: New Crowdin updates') }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
SHARD_ID: [1, 2, 3, 4, 5, 6, 7]
env:
SHARD_ID: ${{ matrix.SHARD_ID }}
steps:
- name: Debug
uses: raven-actions/debug@v1
- name: Checkout
uses: actions/checkout@v4
- name: Find node IP
uses: ./.github/actions/find-node-ip/
- name: Start selenoid
uses: ./.github/actions/start-selenoid/
- name: Build website image
uses: ./.github/actions/build-website-image/
with:
prepare-only: true
- name: Pull docker images (background)
shell: bash
run: |
${DOCKER_COMPOSE} -p gkdev0 pull --ignore-buildable &
- name: Install Robot Framework
run: |
echo "::group::Install RobotFramework"
pip3 install -r tests-qa/requirements.txt &
echo "::endgroup::"
- name: Configure Sentry
shell: bash
run: |
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .env
echo "SENTRY_ENV=dev.githubaction" >> .env
- name: Start Postgres
uses: ./.github/actions/start-postgres/
with:
wait-started: false
prepare-only: true
- name: Build website image
uses: ./.github/actions/build-website-image/
- name: Start Docker stack(s)
uses: ./.github/actions/docker-stack-start/
# - name: Install Firefox
# uses: ./.github/actions/install-firefox/
# - name: Install Robot Framework
# uses: ./.github/actions/install-robot-framework/
- name: Run Robot Framework
id: tests-qa
env:
AUTO_REMOTE_URL: true
RECORDING_ENABLED: false
uses: ./.github/actions/run-robot-framework/
- name: Save docker logs
if: always()
continue-on-error: true
run: |
mkdir docker-logs
docker ps -a > docker-logs/docker-ps.log
for j in $(seq ${{ env.GK_INSTANCE_COUNT }}); do
declare f=0
f=$((j - 1))
for container in nginx website postgres minio pictures-uploader pictures-downloader; do
${DOCKER_COMPOSE} -p gkdev${f} logs ${container} > docker-logs/${container}-${f}.log
done
done
- name: Kill the docker stack(s)
if: always()
continue-on-error: true
run: |
make kill DOCKER_COMPOSE_PARAMS="-s SIGKILL" &
- name: Upload docker logs
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: docker-logs-${{ env.SHARD_ID }}
path: |
docker-logs/
- name: Ensure access to recordings
if: always()
id: recordings
run: |
chmod +x tests-qa/video
has_recordings=false
[ "$(ls -A tests-qa/video)" ] && has_recordings=true
echo "has_recordings=${has_recordings}" | tee -a $GITHUB_OUTPUT
- name: Upload recordings
if: ${{ always() && steps.tests-qa.outcome != 'skipped' && steps.recordings.outputs.has_recordings == 'true' }}
uses: actions/upload-artifact@v4
with:
name: test-recording-${{ env.SHARD_ID }}
path: |
tests-qa/video/
- name: Upload results
if: ${{ always() && steps.tests-qa.outcome != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: test-results-${{ env.SHARD_ID }}
path: |
tests-qa/docs/${{ env.GIT_BRANCH }}/
!tests-qa/docs/${{ env.GIT_BRANCH }}/pabot_results
report-assemble:
needs: [robot-framework, phpunit-tests]
if: "${{ always() && ! (contains(github.event.head_commit.message, 'skip tests-qa') || github.event.pull_request.title == 'translation: New Crowdin updates') }}"
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: test-results-*
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: test-unit
- name: Checkout visual_images baseline
uses: actions/checkout@v4
with:
path: website
sparse-checkout: tests-qa/visual_images
- name: Move visual_images folder
continue-on-error: true
run: |
mkdir visual_images || true
mv website/tests-qa/visual_images visual_images/baseline
rm -fr website
- name: Install Robot Framework
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "::group::Obtain requirements.txt"
gh api \
/repos/${GITHUB_REPOSITORY}/contents/tests-qa/requirements.txt?ref=${{ github.ref }} \
--jq '.content' | base64 -d > /tmp/requirements.txt
echo "::endgroup::"
pip3 install -r /tmp/requirements.txt
- name: Assemble reports
id: assemble-report
continue-on-error: true
run: |
ret=0
echo "::group::list files before"
pwd
find . -type f
echo "::endgroup::"
echo
# Robot Framework report
echo "::group::Robot Framework report"
rebot --nostatusrc --merge output-*.xml || ret=$?
echo "::endgroup::"
echo
# merge xml files
echo "::group::merge xml files"
/usr/bin/env python3 - output-*.xml >> output.xml <<EOF
#!/usr/bin/env python3
import sys
from xml.etree import ElementTree
def run(files):
first = None
for filename in files:
data = ElementTree.parse(filename).getroot()
if first is None:
first = data
else:
first.extend(data)
if first is not None:
print(ElementTree.tostring(first, encoding='unicode'))
if __name__ == "__main__":
run(sys.argv[1:])
EOF
echo "::endgroup::"
echo
echo "::group::List all xml files"
ls -l *.xml
echo "::endgroup::"
# Robot Eyes report
echo "::group::Robot Eyes report"
reportgen \
--baseline=visual_images/baseline \
--results=. || ret=$?
echo "::endgroup::"
echo
echo "::group::Fix images path"
sed -i 's@\.\./@@g' visualReport.html || ret=$?
echo "::endgroup::"
echo
# Add visualReport.html link into report.html
echo "::group::Add visualReport.html link into report.html"
anchor='\(<td><a href="${$item.logURL}">${$item.logURL}\)</a></td>'
link='<tr><th>Visual Report:</th><td><a href="visualReport.html">visualReport.html</a></td></tr>'
sed -i "s@${anchor}@\1${link}@" report.html || ret=$?
echo "::endgroup::"
echo
echo
echo "::group::list files after"
pwd
find . -type f
echo "::endgroup::"
exit "${ret}"
- name: Upload report to job artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report
path: .
- name: Deploy GH pages
id: deploy-pages
env:
QA_TEST_DEPLOY_KEY: ${{ secrets.QA_TEST_DEPLOY_KEY || '' }}
if: always() && env.QA_TEST_DEPLOY_KEY != '' && steps.assemble-report.conclusion == 'success'
uses: peaceiris/actions-gh-pages@v4
with:
keep_files: true
deploy_key: ${{ secrets.QA_TEST_DEPLOY_KEY }}
external_repository: geokrety/geokrety-website-qa
publish_branch: gh-pages
publish_dir: .
destination_dir: ${{ env.GIT_BRANCH }}
user_name: geokrety-bot
user_email: geokrety-bot@geokrety.org
commit_message: "docs: Update QA tests results"
- name: Show report URL
if: always() && env.QA_TEST_DEPLOY_KEY != '' && steps.deploy-pages.outcome == 'success'
env:
QA_TEST_DEPLOY_KEY: ${{ secrets.QA_TEST_DEPLOY_KEY || '' }}
run: |
report_url="https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/report.html"
visual_report_url="https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/visualReport.html"
unit_report_url="https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/test-unit/test-unit-report.html"
echo "${report_url}"
echo "${visual_report_url}"
echo "${unit_report_url}"
echo '### Robot Framework reports' >> $GITHUB_STEP_SUMMARY
echo "* [report](${report_url})" >> $GITHUB_STEP_SUMMARY
echo "* [visualReport](${visual_report_url})" >> $GITHUB_STEP_SUMMARY
echo "* [PHPUnit](${unit_report_url})" >> $GITHUB_STEP_SUMMARY
- name: Post report URL in PR
env:
QA_TEST_DEPLOY_KEY: ${{ secrets.QA_TEST_DEPLOY_KEY || '' }}
if: env.QA_TEST_DEPLOY_KEY != '' && github.event_name == 'pull_request' && steps.deploy-pages.outcome == 'success'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
### Robot Framework reports
* [report](https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/report.html)
* [visualReport](https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/visualReport.html)
* [PHPUnit](https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/test-unit/test-unit-report.html)
comment_tag: rbfr
reactions: eyes, rocket
database-tests:
if: "${{ ! (contains(github.event.head_commit.message, 'skip tests-qa') || github.event.pull_request.title == 'translation: New Crowdin updates') }}"
runs-on: ubuntu-latest
env:
GK_INSTANCE_COUNT: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Find node IP
uses: ./.github/actions/find-node-ip/
- name: Pull docker images (background)
shell: bash
run: |
${DOCKER_COMPOSE} -p gkdev0 pull --ignore-buildable &
- name: Start Postgres
uses: ./.github/actions/start-postgres/
- name: Install PostGis data
uses: ./.github/actions/install-postgis-data/
- name: Install tools
run: |
echo "::group::Install httping"
sudo apt-get update
${APT_INSTALL} httping
echo "::endgroup::"
- name: Build website image
uses: ./.github/actions/build-website-image/
- name: Start Docker stack(s)
uses: ./.github/actions/docker-stack-start/
- name: Run database tests
uses: ./.github/actions/run-pgtap/
phpunit-tests:
if: "${{ ! (contains(github.event.head_commit.message, 'skip tests-qa') || github.event.pull_request.title == 'translation: New Crowdin updates') }}"
runs-on: ubuntu-latest
env:
GK_INSTANCE_COUNT: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pull docker images (background)
shell: bash
run: |
${DOCKER_COMPOSE} -p gkdev0 pull --ignore-buildable &
- name: Start Postgres
uses: ./.github/actions/start-postgres/
- name: Install PostGis data
uses: ./.github/actions/install-postgis-data/
- name: Install tools
run: |
echo "::group::Install httping"
sudo apt-get update
${APT_INSTALL} httping
echo "::endgroup::"
- name: Build website image
uses: ./.github/actions/build-website-image/
- name: Start Docker stack(s)
uses: ./.github/actions/docker-stack-start/
- name: Run PHPUnit tests
id: tests-unit
uses: ./.github/actions/run-phpunit/
- name: Upload results
if: ${{ always() && steps.tests-unit.outcome != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: test-unit
path: |
test-unit-report.html