forked from qgis/QGIS
-
Notifications
You must be signed in to change notification settings - Fork 0
448 lines (387 loc) · 15.4 KB
/
run-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
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
name: 🧪 QGIS tests
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
- release-**
- queued_ltr_backports
paths:
- 'src/**'
- 'external/**'
- 'python/**'
- 'tests/**'
- 'CMakeLists.txt'
- '.github/workflows/run-tests.yml'
- '.docker/**'
- '.ci/**'
pull_request:
branches:
- master
- release-**
- queued_ltr_backports
# paths cannot be filtered on this workflow on pull request as it is a required one in the branch protection
# feature request and hacks: https://github.community/t/feature-request-conditional-required-checks/16761
permissions:
contents: read
jobs:
build:
env:
QGIS_WORKSPACE: ${{ github.workspace }} # used in docker compose
RUN_FLAKY_TESTS: ${{ contains( github.event.pull_request.labels.*.name, 'run flaky tests') }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- distro-version: '22.04'
qt-version: 5
run-tests: true
with-qt6: OFF
with-qt5: ON
with-3d: ON
with-quick: ON
with-clazy: ON
with-grass7: OFF
with-grass8: OFF
with-webengine: OFF
with-pdf4qt: OFF
with-compile-commands: ON
# LD_PRELOAD: /lib/x86_64-linux-gnu/libSegFault.so
experimental: false
- distro-version: '39'
qt-version: 6
run-tests: true
with-qt6: ON
with-qt5: OFF
with-3d: ON
with-quick: ON
with-clazy: OFF
with-grass7: OFF
with-grass8: ON
with-webengine: ON
with-pdf4qt: ON
with-compile-commands: OFF
LD_PRELOAD: ''
experimental: false
fail-fast: false
outputs:
compile_outcome: ${{ steps.compile.outcome }}
tests_failing: ${{ steps.tests.outputs.TESTS_FAILING }}
cdash_url: ${{ steps.tests.outputs.CDASH_URL }}
runners_outcome: ${{ steps.runners.outcome }}
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: true
- name: Checkout
uses: actions/checkout@v4
- name: Set vars
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_REF: ${{ github.ref }}
GITHUB_PR_NUMBER: ${{github.event.number}}
run: |
# Be aware that these instructions are duplicated in run-tests job
DOCKER_TAG=$(echo $( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo ${GITHUB_BASE_REF} || echo ${GITHUB_REF##*/} ) | sed 's/^master$/latest/')
CTEST_BUILD_NAME=$( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo "PR${GITHUB_PR_NUMBER}" || echo ${GITHUB_REF##*/} )"_${GITHUB_SHA}"
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
echo "CTEST_BUILD_NAME=${CTEST_BUILD_NAME}" >> $GITHUB_ENV
echo "QT_VERSION=${{ matrix.qt-version }}" >> $GITHUB_ENV
- name: Print vars
run: |
echo DOCKER_TAG: ${DOCKER_TAG}
echo CTEST_BUILD_NAME: ${CTEST_BUILD_NAME}
echo QT_VERSION: ${QT_VERSION}
- name: Login to Docker Hub
if: ${{ github.event_name == 'push' && github.actor == 'qgis' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Container with Build Environment
id: docker-build
uses: docker/build-push-action@v6
with:
context: .
file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
tags: qgis/qgis3-build-deps-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}:${{ github.event.pull_request.base.ref || github.ref_name }}
push: ${{ github.event_name == 'push' && github.actor == 'qgis' }}
pull: true
build-args:
DISTRO_VERSION=${{ matrix.distro-version }}
- name: Tag image
run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps
- name: Restore build cache
uses: actions/cache/restore@v4
with:
path: /home/runner/QGIS/.ccache
key: build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-${{ github.event.pull_request.base.ref || github.ref_name }}
restore-keys: |
build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-master
- name: Compile QGIS
id: compile
run: |
docker run -t --name qgis_container \
-v $(pwd):/root/QGIS \
-v /home/runner/QGIS/.ccache:/root/.ccache \
--env-file .docker/docker-variables.env \
--env CCACHE_DIR=/root/.ccache \
--env PUSH_TO_CDASH=true \
--env WITH_QT5=${{ matrix.with-qt5 }} \
--env BUILD_WITH_QT6=${{ matrix.with-qt6 }} \
--env WITH_QUICK=${{ matrix.with-quick }} \
--env WITH_3D=${{ matrix.with-3d }} \
--env WITH_GRASS7=${{ matrix.with-grass7 }} \
--env WITH_GRASS8=${{ matrix.with-grass8 }} \
--env WITH_QTWEBENGINE=${{ matrix.with-webengine }} \
--env WITH_PDF4QT=${{ matrix.with-pdf4qt }} \
--env LD_PRELOAD=${{ matrix.LD_PRELOAD }} \
--env WITH_CLAZY=${{ matrix.with-clazy }} \
--env WITH_COMPILE_COMMANDS=${{ matrix.with-compile-commands }} \
qgis3-build-deps \
/root/QGIS/.docker/docker-qgis-build.sh
- name: Save build cache for push only
uses: actions/cache/save@v4
if: ${{ github.event_name == 'push' }}
with:
path: /home/runner/QGIS/.ccache
key: build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-${{ github.ref_name }}-${{ github.run_id }}
- name: Push artifact
id: push_artifact
if: ${{ matrix.run-tests }}
run: tar --exclude='*.o' -cvzf build.tgz build
- uses: actions/upload-artifact@v4
if: ${{ matrix.run-tests }}
with:
name: build-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}.tgz
path: ./build.tgz
retention-days: 1
# - name: Test QGIS runners
# id: runners
# if: ${{ matrix.distro-version == env.DEFAULT_DISTRO_VERSION }}
# run: |
# docker run -d --name qgis-testing-environment \
# -v $(pwd):/root/QGIS \
# -v $(pwd)/tests/src/python:/tests_directory \
# -v $(pwd)/.docker/qgis_resources/test_runner:/usr/bin/test_runner \
# -v $(pwd)/.docker/qgis_resources/supervisor:/etc/supervisor \
# -e QGIS_BUILD_PATH=/root/QGIS/build/output/bin/qgis \
# -e TEST_RUNNER_PATH=/usr/bin/test_runner/qgis_testrunner.py \
# -e DISPLAY=:99 \
# qgis_image \
# /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
# # Wait for xvfb to finish starting
# printf "Waiting for the docker...🐳..."
# sleep 10
# echo " done 🥩"
#
# declare -A testrunners
# # Passing cases:
# testrunners["test_testrunner.run_passing"]=0
# testrunners["test_testrunner.run_skipped_and_passing"]=0
# # Failing cases:
# testrunners["test_testrunner"]=1
# testrunners["test_testrunner.run_all"]=1
# testrunners["test_testrunner.run_failing"]=1
# set +e # do not exit on error
# # Run tests in the docker
# for i in "${!testrunners[@]}"
# do
# echo "::group::docker_test_runner_${i}"
# echo "test ${i}..."
# docker exec -i qgis-testing-environment sh -c "cd /tests_directory && /usr/bin/test_runner/qgis_testrunner.sh ${i}"
# [[ $? -eq "${testrunners[$i]}" ]] && echo "success" || exit 1
# echo "::endgroup::"
# done
# set -e # switch back
# docker stop qgis-testing-environment
run-tests:
name: Run tests
env:
QGIS_WORKSPACE: ${{ github.workspace }} # used in docker compose
runs-on: ubuntu-latest
needs: build
if: always()
strategy:
matrix:
qt-version: [5, 6]
test-batch: [ALL_BUT_PROVIDERS, POSTGRES, HANA]
include:
- qt-version: 5
distro-version: 22.04
docker-target: binary-only
- qt-version: 6
distro-version: 39
docker-target: binary-only
- qt-version: 5
distro-version: 22.04
test-batch: ORACLE
docker-target: binary-for-oracle
exclude:
- qt-version: 6
test-batch: HANA
- qt-version: 6
test-batch: POSTGRES
fail-fast: false
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: true
- name: Checkout
uses: actions/checkout@v4
- name: Set vars
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_REF: ${{ github.ref }}
GITHUB_PR_NUMBER: ${{github.event.number}}
run: |
# Be aware that these instructions are duplicated in build job
CTEST_BUILD_NAME=$( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo "PR${GITHUB_PR_NUMBER}" || echo ${GITHUB_REF##*/} )"_${GITHUB_SHA}_${{ matrix.test-batch }}"
echo "CTEST_BUILD_NAME=${CTEST_BUILD_NAME}" >> $GITHUB_ENV
echo "QT_VERSION=${{ matrix.qt-version }}" >> $GITHUB_ENV
- name: Print vars
run: |
echo CTEST_BUILD_NAME: ${CTEST_BUILD_NAME}
- name: Login to Docker Hub
if: ${{ github.event_name == 'push' && github.actor == 'qgis' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Container with Testing Environment
id: docker-build
uses: docker/build-push-action@v6
with:
context: .
file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
tags: qgis/qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only:${{ github.event.pull_request.base.ref || github.ref_name }}
push: ${{ github.event_name == 'push' && github.actor == 'qgis' }}
pull: true
target: ${{ matrix.docker-target }}
build-args:
DISTRO_VERSION=${{ matrix.distro-version }}
- name: Tag image
run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps-binary-image
- name: Print disk space
run: |
echo "DOCKER IMAGES"
docker images
echo "DF -H"
sudo df -h
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}.tgz
path: .
- name: Extract build artifact
run: |
tar xvzf build.tgz
rm -Rf build.tgz
- name: Print disk space
run: |
echo "DF -H"
sudo df -h
- name: Run tests
id: tests
env:
TEST_BATCH: ${{matrix.test-batch}}
QGIS_COMMON_GIT_DIR: ${{ github.workspace }}
GITHUB_SHA: ${{ github.sha }}
run: |
DOCKERFILE=$( ( [[ ${{ matrix.test-batch }} == "ORACLE" ]] && echo "docker-compose-testing-oracle.yml" ) \
|| ( [[ ${{ matrix.test-batch }} == "POSTGRES" ]] && echo "docker-compose-testing-postgres.yml" ) \
|| echo "docker-compose-testing.yml" )
[[ ${{ matrix.test-batch }} == "ORACLE" ]] && sudo rm -rf /usr/share/dotnet/sdk
echo "TEST_BATCH=$TEST_BATCH"
echo "DOCKERFILE=$DOCKERFILE"
mkdir -p /tmp/webdav_tests && chmod 777 /tmp/webdav_tests
mkdir -p /tmp/minio_tests/test-bucket && chmod -R 777 /tmp/minio_tests
docker compose -f .docker/$DOCKERFILE run -e GITHUB_SHA=$GITHUB_SHA qgis-deps /root/QGIS/.docker/docker-qgis-test.sh $TEST_BATCH
- name: Fix permissions on test report
if: ${{ failure() }}
run: |
sudo chmod -R 777 qgis_test_report
- name: Dump report contents
if: ${{ failure() }}
run: |
MD_REPORT_FILE="qgis_test_report/summary.md"; [ -f "$MD_REPORT_FILE" ] && cat "$MD_REPORT_FILE" || true
- name: Save PR number to test report
if: ${{ failure() }}
run: |
echo ${{ github.event.number }} | tee qgis_test_report/pr_number
echo ${{ github.event.pull_request.head.sha }} | tee qgis_test_report/git_commit
- name: Archive test results report
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: test-results-qt${{ matrix.qt-version }}
path: qgis_test_report
clang-tidy:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
- distro-version: '22.04'
qt-version: 5
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: true
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Login to Docker Hub
if: ${{ github.event_name == 'push' && github.actor == 'qgis' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Container with Testing Environment
id: docker-build
uses: docker/build-push-action@v6
with:
context: .
file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
tags: qgis/qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only:${{ github.event.pull_request.base.ref || github.ref_name }}
push: ${{ github.event_name == 'push' && github.actor == 'qgis' }}
pull: true
target: ${{ matrix.docker-target }}
build-args:
DISTRO_VERSION=${{ matrix.distro-version }}
- name: Tag image
run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps-binary-image
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}.tgz
path: .
- name: Extract build artifact
run: |
tar xvzf build.tgz
rm -Rf build.tgz
- name: Run Clang-Tidy
run: |
docker run -t --name qgis_container \
-v $(pwd):/root/QGIS \
-v /home/runner/QGIS/.ccache:/root/.ccache \
--env-file .docker/docker-variables.env \
qgis3-build-deps-binary-image \
/root/QGIS/.docker/docker-qgis-clangtidy.sh