Hi all,

I'm trying to build some CI tests on GitHub (with pytest) using the official qgis/qgis Docker image. Everything works fine except for the parts of my plugin that use Processing algorithms. I'd like to run full workflow tests, but the processing plugin doesn't seem to be available in the container.

When I try to load it with qgis.utils.loadPlugin('processing') I get this error:

Python error(2): Traceback (most recent call last):
  File "/usr/share/qgis/python/qgis/utils.py", line 447, in loadPlugin
    __import__(packageName)
  File "/usr/share/qgis/python/qgis/utils.py", line 1100, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'processing'

Couldn't load plugin 'processing'(1): Couldn't load plugin 'processing'

I can't find much documentation on how to build CI tests for a QGIS plugin, so I've been trying to make it work, but I don't know if I'm doing it rightly...

I've tried installing extra packages (qgis-plugin-grass, grass, saga) in the Dockerfile, but it didn't help.

Here's my *Dockerfile*:

ARG QGIS_TEST_VERSION=latest FROM  qgis/qgis:${QGIS_TEST_VERSION} RUN apt-get update \     && apt-get install -y python3-pip qgis-plugin-grass grass saga \     && rm -rf /var/lib/apt/lists/* COPY ./test/requirements.txt /tmp/ RUN pip3 install --upgrade pip || true RUN pip3 install -r /tmp/requirements.txt || pip3 install -r /tmp/requirements.txt --break-system-packages ENV LANG=C.UTF-8 WORKDIR /

This is my *run-docker-tests.sh*:

#!/usr/bin/env bash set -e pushd /usr/src/ibergis_qgis_plugin xvfb-run pytest popd

And the relevant part of *GitHub Actions (test.yml)*:

  # Run unit tests   tests-qgis:     runs-on: ubuntu-24.04     strategy:       fail-fast: false       matrix:         qgis_version: [latest, ltr, stable]     env:       QGIS_TEST_VERSION: ${{ matrix.qgis_version }}     steps:       - name: Checkout         uses: actions/checkout@v4         with:           submodules: recursive       - name: Test         run: |           chmod +x .docker/run-docker-tests.sh           docker compose -f .docker/docker-compose.yml run qgis /usr/src/ibergis_qgis_plugin/.docker/run-docker-tests.sh

I haven't found much documentation on running QGIS plugin tests in CI environments, so I might be missing something obvious. If anyone has experience running tests that use Processing algorithms inside Docker, I'd really appreciate some guidance.

Thanks in advance!

--
*Sergi Maspons "Maspi"*
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to