Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Docker for QGIS tests (once more) #1774

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .docker/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '2'

services:
qgis:
image: qgis/qgis:release-3_34
container_name: qgis
volumes:
- ../ribasim_qgis/:/tests_directory/ribasim_qgis
environment:
- CI=true
- DISPLAY=:99
tty: true
7 changes: 7 additions & 0 deletions .docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -eux

docker compose -f compose.yml up -d --force-recreate --remove-orphans
echo "Installation of the plugin Ribasim"
docker exec -t qgis sh -c "qgis_setup.sh ribasim_qgis"
echo "Containers are running"
6 changes: 6 additions & 0 deletions .docker/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eux

echo 'Stopping/killing containers'
docker compose -f compose.yml kill
docker compose -f compose.yml rm -f
4 changes: 4 additions & 0 deletions .docker/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -eux

docker exec -t qgis sh -c "cd /tests_directory && xvfb-run -a qgis_testrunner.sh ribasim_qgis.tests"
40 changes: 17 additions & 23 deletions .github/workflows/qgis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,21 @@ on:
pull_request:
paths-ignore: [".teamcity/**"]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: QGIS plugin ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
pixi-version: "latest"
- name: Run tests
run: pixi run test-ribasim-qgis-cov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
test-qgis:
name: "Test"
runs-on: ubuntu-latest
defaults:
run:
working-directory: .docker
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
pixi-version: "latest"
- name: Run tests
run: pixi run test-ribasim-qgis-docker
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
5 changes: 3 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ install-ribasim-qgis = "python ribasim_qgis/scripts/install_ribasim_qgis.py"
install-imod-qgis = "python ribasim_qgis/scripts/install_qgis_plugin.py iMOD && python ribasim_qgis/scripts/enable_plugin.py imodqgis"
install-plugin-reloader-qgis = "python ribasim_qgis/scripts/install_qgis_plugin.py \"Plugin Reloader\" && python ribasim_qgis/scripts/enable_plugin.py plugin_reloader"
install-debugvs-qgis = "python ribasim_qgis/scripts/install_qgis_plugin.py debugvs==0.7 && python ribasim_qgis/scripts/enable_plugin.py debug_vs"
test-ribasim-qgis-docker = { cmd = "sh ./start.sh; sh ./test.sh; sh ./stop.sh", cwd = ".docker" }
install-qgis-plugins = { depends_on = [
"install-plugin-reloader-qgis",
"install-ribasim-qgis",
Expand All @@ -137,10 +138,10 @@ install-qgis-plugins = { depends_on = [
test-ribasim-qgis-ui = { cmd = "python ribasim_qgis/scripts/run_qgis_ui_tests.py", depends_on = [
"install-ribasim-qgis",
] }
test-ribasim-qgis = { cmd = "pytest --numprocesses=auto ribasim_qgis/tests", depends_on = [
test-ribasim-qgis = { cmd = "pytest --numprocesses=auto ribasim_qgis/tests/core", depends_on = [
"install-ribasim-qgis",
] }
test-ribasim-qgis-cov = { cmd = "pytest --numprocesses=auto --cov=ribasim_qgis --cov-report=xml --cov-config=ribasim_qgis/.coveragerc ribasim_qgis/tests", depends_on = [
test-ribasim-qgis-cov = { cmd = "pytest --numprocesses=auto --cov=ribasim_qgis --cov-report=xml --cov-config=ribasim_qgis/.coveragerc ribasim_qgis/tests/core", depends_on = [
"install-ribasim-qgis",
] }
mypy-ribasim-qgis = "mypy ribasim_qgis"
Expand Down
8 changes: 4 additions & 4 deletions ribasim_qgis/.coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[run]
source = .
omit =
ribasim_qgis/resources.py
ribasim_qgis/tests/*
ribasim_qgis/tomllib/*
ribasim_qgis/ui_tests/*
*/resources.py
*/tests/*
*/tomllib/*
2 changes: 1 addition & 1 deletion ribasim_qgis/scripts/run_qgis_ui_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"--nologo",
"--code",
"ribasim_qgis/scripts/qgis_testrunner.py",
"ribasim_qgis.ui_tests",
"ribasim_qgis.tests",
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Expand Down
20 changes: 20 additions & 0 deletions ribasim_qgis/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys
from pathlib import Path

import coverage
from qgis.testing import unittest

testfolder = Path(__file__).parent


def run_all():
test_loader = unittest.defaultTestLoader
test_suite = test_loader.discover(".", pattern="test_*.py")

cov = coverage.Coverage(config_file=testfolder.parent / ".coveragerc")
cov.start()
unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(test_suite)

cov.stop()
cov.save()
cov.xml_report(outfile=testfolder / "coverage.xml")
Empty file.
9 changes: 0 additions & 9 deletions ribasim_qgis/ui_tests/__init__.py

This file was deleted.