<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi all,</p>
    <p>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.</p>
    <p>When I try to load it with qgis.utils.loadPlugin('processing') I
      get this error:<br>
    </p>
    <pre><font size="1">Python error(2): Traceback (most recent call last):</font>
<font size="1">  File "/usr/share/qgis/python/qgis/utils.py", line 447, in loadPlugin</font>
<font size="1">    __import__(packageName)</font>
<font size="1">  File "/usr/share/qgis/python/qgis/utils.py", line 1100, in _import</font>
<font size="1">    mod = _builtin_import(name, globals, locals, fromlist, level)</font>
<font size="1">          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</font>
<font size="1">ModuleNotFoundError: No module named 'processing'</font>

<font size="1">Couldn't load plugin 'processing'(1): Couldn't load plugin 'processing'</font></pre>
    <p>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...</p>
    <p>I've tried installing extra packages (qgis-plugin-grass, grass,
      saga) in the Dockerfile, but it didn't help.</p>
    <p>Here's my <b>Dockerfile</b>:<br>
    </p>
    <pre><font size="2">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 /</font></pre>
    <p>This is my <b>run-docker-tests.sh</b>:<br>
    </p>
    <pre><font size="2">#!/usr/bin/env bash
set -e
pushd /usr/src/ibergis_qgis_plugin
xvfb-run pytest
popd</font></pre>
    <p>And the relevant part of <b>GitHub Actions (test.yml)</b>:<br>
    </p>
    <pre><font size="2">  # 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</font></pre>
    <p>I haven't found much documentation on running QGIS plugin tests
      in CI environments, so I might be missing something obvious.<br>
      If anyone has experience running tests that use Processing
      algorithms inside Docker, I'd really appreciate some guidance.</p>
    <p>Thanks in advance!</p>
    <div class="moz-signature">-- <br>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <title></title>
      <div class="moz-signature"><b>Sergi Maspons "Maspi"</b><br>
      </div>
    </div>
  </body>
</html>