Skip to content

Update test_plugin.yml #163

Update test_plugin.yml

Update test_plugin.yml #163

Workflow file for this run

name: Test plugin
on:
push:
branches:
- main
- dev
paths:
- "geovita_processing_plugin/**"
- ".github/workflows/test_plugin.yml"
pull_request:
branches:
- main
- dev
paths:
- "geovita_processing_plugin/**"
- ".github/workflows/test_plugin.yml"
workflow_dispatch:
env:
# plugin name/directory where the code for the plugin is stored
PLUGIN_NAME: geovita_processing_plugin
# Docker settings
DOCKER_IMAGE: qgis/qgis
jobs:
Test-geovita_processing_plugin:
runs-on: ubuntu-latest
strategy:
matrix:
docker_tags: [release-3_36, 3.40.11, 3.44.4]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Docker pull and create qgis-testing-environment
run: |
docker pull "$DOCKER_IMAGE":${{ matrix.docker_tags }}
docker run -d -e XDG_RUNTIME_DIR=/tmp/runtime-root --name qgis-testing-environment -v ${{ github.workspace }}:/tests_directory -e DISPLAY=:99 "$DOCKER_IMAGE":${{ matrix.docker_tags }} tail -f /dev/null
- name: Docker set up QGIS
run: |
docker exec qgis-testing-environment sh -c "mkdir -p /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/"
docker exec qgis-testing-environment sh -c "rm -f /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/$PLUGIN_NAME"
docker exec qgis-testing-environment sh -c "ln -s /tests_directory/$PLUGIN_NAME /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/$PLUGIN_NAME"
docker exec qgis-testing-environment sh -c "pip3 install --break-system-packages -r /tests_directory/REQUIREMENTS_TESTING.txt coverage"
docker exec qgis-testing-environment sh -c "ls -l /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/"
docker exec qgis-testing-environment sh -c "ls -l /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/$PLUGIN_NAME"
- name: Prepare REMEDY_GIS_RiskTool submodule
run: |
docker exec qgis-testing-environment sh -c "touch /tests_directory/$PLUGIN_NAME/REMEDY_GIS_RiskTool/__init__.py"
docker exec qgis-testing-environment ls -la /tests_directory/$PLUGIN_NAME/REMEDY_GIS_RiskTool
- name: Create Pytest configuration (conftest.py)
run: |
docker exec qgis-testing-environment sh -c 'cat <<EOF > /tests_directory/conftest.py
import pytest

Check failure on line 66 in .github/workflows/test_plugin.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/test_plugin.yml

Invalid workflow file

You have an error in your yaml syntax on line 66
from qgis.core import QgsApplication
import os
import sys
# Legg til plugin-roten og submodule-mappen i sys.path
plugin_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "geovita_processing_plugin"))
submodule_path = os.path.join(plugin_root, "REMEDY_GIS_RiskTool")
sys.path.insert(0, plugin_root)
sys.path.insert(0, submodule_path)
@pytest.fixture(scope="session", autouse=True)
def init_qgis_processing(qgis_app):
"""Initialiserer QGIS Processing framework og registrerer plugin-provider."""
print("Initializing QGIS Processing Framework...")
try:
from processing.core.Processing import Processing
Processing.initialize()
print("Processing Framework Initialized.")
except ImportError as e:
print(f"Could not import Processing: {e}")
pytest.skip("Failed to import QGIS Processing framework")
print("Registering Geovita provider...")
try:
from geovita_processing_plugin_provider import Geovita_processing_pluginProvider
provider = Geovita_processing_pluginProvider()
if QgsApplication.processingRegistry().addProvider(provider):
print(f"Successfully added provider: {provider.id()}")
else:
print("Failed to add provider.")
except ImportError as e:
print(f"Could not import Geovita provider: {e}")
pytest.skip("Failed to import Geovita provider")
yield
# Nedrigging
print("Deinitializing Processing Framework...")
QgsApplication.processingRegistry().removeProvider(provider.id())
Processing.deinitialize()
EOF'
- name: Docker run plugin tests
run: |
# conftest.py håndterer nå all nødvendig oppsett
docker exec qgis-testing-environment sh -c "cd /tests_directory && xvfb-run pytest"
Check-code-quality:
runs-on: ubuntu-latest
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
architecture: 'x64'
- name: Checkout
uses: actions/checkout@v4
- name: Install packages
run: |
pip install -r REQUIREMENTS_TESTING.txt
pip install pylint pycodestyle
- name: Pylint
run: make pylint
- name: Pycodestyle
run: make pycodestyle