-
Notifications
You must be signed in to change notification settings - Fork 18
261 lines (228 loc) · 9.1 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
name: Integration tests on Robot Framework
on:
pull_request:
branches-ignore:
- main
- master
- l10n_main
- l10n_master
- l10n_new-theme
push:
branches-ignore:
- main
- master
- l10n_main
- l10n_master
- l10n_new-theme
workflow_call:
env:
PGUSER: geokrety
PGPASSWORD: geokrety
PGDATABASE: geokrety
PGHOST: localhost
PGPORT: 5433
DOCKER_COMPOSE: docker compose -p gk -f docker-compose.local.yml --progress quiet
APT_INSTALL: sudo apt-get -qq install -qq -o=Dpkg::Use-Pty=0 -y
jobs:
# debug:
# runs-on: ubuntu-latest
# steps:
# - name: Debug
# uses: raven-actions/debug@v1
robot-framework:
if: "${{ (github.event_name == 'push' || github.event.pull_request.merged == true) && !contains(github.event.head_commit.message, 'skip tests-qa') }}"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set output
id: vars
run: |
echo "short_ref=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
git status
- name: Configure Sentry
run: |
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" > .env
echo "SENTRY_ENV=dev.githubaction" >> .env
- name: Install tools
run: |
sudo apt-get update
${APT_INSTALL} postgresql-client postgis httping
- name: Cache PUBLIC data
uses: actions/cache@v4
with:
path: ./website/db/dumps/11_public-data.sql
key: public-data-cache
restore-keys: |
public-data-cache
- name: Cache SRTM data
uses: actions/cache@v4
with:
path: ./website/db/srtm/*.zip
key: srtm-cache
restore-keys: |
srtm-cache
- name: Pull/Start postgres
id: db-start
run: |
./website/db/get_huge_dump_files.sh
# Create srtm dir now, so it gets right permissions
mkdir ./website/db/srtm || ls -la ./website/db/srtm
echo "Getting postgres docker image…"
${DOCKER_COMPOSE} pull -q postgres
echo "Starting postgres…"
${DOCKER_COMPOSE} up -d --no-build postgres
echo "Wait postgres to become available…"
timeout 60s bash -c "while ! pg_isready; do sleep 1; done" || { docker ps -a; ${DOCKER_COMPOSE} logs postgres; false; }
- name: Get postgres logs on failure
if: "${{ failure() && steps.db-start.outcome == 'failure' }}"
run: ${DOCKER_COMPOSE} logs postgres
- name: Prevent DNS issue with new GH Runner on Ubuntu 22.04
run: |
for i in $(seq 60); do
httping -sGc1 -o 200,302 https://srtm.geokrety.org/Eurasia/N52E021.hgt.zip && { echo OK; break; } || { sleep 1; }
done || exit 1
- name: Import SRTM data
run: |
./website/db/tests-srtm-import.sh
- name: Test SRTM data
run: |
psql -c "SELECT count(*) FROM public.srtm"
psql -c "SELECT iso_a2 FROM public.countries WHERE public.ST_Intersects(geom::public.geometry, '0101000020E6100000F6285C8FC2F51C405C8FC2F528DC4540'::public.geometry);"
psql -c "SELECT public.ST_Value(rast, '0101000020E6100000F6285C8FC2F51C405C8FC2F528DC4540'::public.geometry) As elevation FROM public.srtm WHERE public.ST_Intersects(rast, '0101000020E6100000F6285C8FC2F51C405C8FC2F528DC4540'::public.geometry) LIMIT 2;"
- name: Check for existing website-base image for current branch
if: "${{ !startsWith(github.ref, 'refs/tags/v') }}"
id: existing-image
run: |
if docker pull geokrety/website-base:${{ github.ref_name }}; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Override base image tag from branch name
if: "${{ !startsWith(github.ref, 'refs/tags/v') && steps.existing-image.outputs.exists == 'true' }}"
run: |
sed -i "s/^ARG BASE_TAG=.*$/ARG BASE_TAG=${{ github.ref_name }}/" Dockerfile
- name: Build images website
run: |
${DOCKER_COMPOSE} build website --build-arg GIT_COMMIT=${{ steps.vars.outputs.short_ref }}
- name: Start the whole stack
run: |
${DOCKER_COMPOSE} --env-file .env up -d --no-build
- name: Check the stack has started
id: start-stack
run: |
${DOCKER_COMPOSE} ps -a
sleep 5
${DOCKER_COMPOSE} logs website; ${DOCKER_COMPOSE} logs nginx;
for i in $(seq 60); do
httping -sGc1 -o 200,302 http://localhost:3001/health && { echo OK; break; } || { ${DOCKER_COMPOSE} ps; sleep 1; }
done || exit 1
${DOCKER_COMPOSE} exec -T website make test-health
- name: Get nginx logs on failure
if: "${{ failure() && steps.start-stack.outcome == 'failure' }}"
run: ${DOCKER_COMPOSE} logs nginx
- name: Get php logs on failure
if: "${{ failure() && steps.start-stack.outcome == 'failure' }}"
run: ${DOCKER_COMPOSE} logs website
- name: Run database tests
id: db-unit-tests
run: |
# Tests need the website to be up, as it needs db migrations
env | grep PG
${APT_INSTALL} libtap-parser-sourcehandler-pgtap-perl
PGOPTIONS=--search_path=public,pgtap,geokrety pg_prove -ot website/db/tests/test*.sql
- name: Get postgres logs on failure
if: "${{ failure() && steps.db-unit-tests.outcome == 'failure' }}"
run: ${DOCKER_COMPOSE} logs postgres
- name: Install Firefox
run: |
if command -v firefox; then
echo "Already available. Skip install…"
exit 0
fi
sudo tee -a "/etc/apt/preferences.d/mozilla-firefox" > /dev/null << EOF
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
EOF
sudo add-apt-repository -y ppa:mozillateam/ppa
sudo apt update
- name: Ensure available fonts on system for Robot Framework/Firefox
run: |
${APT_INSTALL} firefox ttf-bitstream-vera fonts-urw-base35
- name: Install geckodriver
run: |
(cd tests-qa && make download_geckodriver)
- name: Install Robot Framework
run: |
pip3 install -r tests-qa/requirements.txt
- name: Run Robot Framework tests
env:
GEOKRETY_URL: http://localhost:3001/
GIT_BRANCH: ${{ steps.vars.outputs.short_ref }}
run: |
make test-qa-headless
# - name: Get geckodriver.log
# if: failure()
# run: |
# cat tests-qa/geckodriver.log
#
# - name: Get geckodriver.log
# if: failure()
# run: |
# cat tests-qa/docs/debugfile.log
#
# - name: Get pictures-downloader logs
# if: failure()
# run: |
# ${DOCKER_COMPOSE} logs pictures-downloader
# echo "---------- /tmp/headers ------------"
# cat /tmp/headers || true
# echo "---------- /tmp/body ------------"
# cat /tmp/body || true
#
# - name: Get pictures-uploader logs
# if: failure()
# run: ${DOCKER_COMPOSE} logs pictures-uploader
#
# - name: Get svg-to-png logs
# if: failure()
# run: ${DOCKER_COMPOSE} logs svg-to-png
#
# - name: Get minio logs
# if: failure()
# run: ${DOCKER_COMPOSE} logs minio
- name: Deploy
env:
super_secret: ${{ secrets.QA_TEST_DEPLOY_KEY }}
if: "${{ always() && env.QA_TEST_DEPLOY_KEY != '' }}"
continue-on-error: true
uses: peaceiris/actions-gh-pages@v3
with:
# force_orphan: true ## see https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-keeping-existing-files-keep_files
keep_files: true
deploy_key: ${{ secrets.QA_TEST_DEPLOY_KEY }}
external_repository: geokrety/geokrety-website-qa
publish_branch: gh-pages
publish_dir: ./tests-qa/docs/${{ steps.vars.outputs.short_ref }}
destination_dir: ${{ steps.vars.outputs.short_ref }}
user_name: geokrety-bot
user_email: geokrety-bot@geokrety.org
commit_message: "docs: Update QA tests results"
- name: Show report URL
env:
super_secret: ${{ secrets.QA_TEST_DEPLOY_KEY }}
if: "${{ always() && env.QA_TEST_DEPLOY_KEY != '' }}"
continue-on-error: true
run: |
echo https://geokrety.github.io/geokrety-website-qa/${{ steps.vars.outputs.short_ref }}/report.html
echo https://geokrety.github.io/geokrety-website-qa/${{ steps.vars.outputs.short_ref }}/visualReport.html
echo '### Robot Framework reports' >> $GITHUB_STEP_SUMMARY
echo '* [report](https://geokrety.github.io/geokrety-website-qa/${{ steps.vars.outputs.short_ref }}/report.html)' >> $GITHUB_STEP_SUMMARY
echo '* [visualReport](https://geokrety.github.io/geokrety-website-qa/${{ steps.vars.outputs.short_ref }}/visualReport.html)' >> $GITHUB_STEP_SUMMARY
- name: Stop the docker stack
if: always()
continue-on-error: true
run: |
${DOCKER_COMPOSE} down