Deltares / imod-qgis

🗺️🧭 QGIS plugin for iMOD
GNU General Public License v2.0
7 stars 1 forks source link

WIP: Automated testing #14

Closed JoerivanEngelen closed 2 years ago

JoerivanEngelen commented 3 years ago

Description

I started working on an automated test bench. Currently it supports both using pytest and the QGIS unittest framework, using qgis_testrunner.sh (comes with the Qgis docker image), as I was still unsure what we would require.

The latter has the benefit that there are plenty of examples available in the Qgis repo itsself. And this also is what the developers expect you to use when using their docker image, for which there is (spare) documentation in the Readme here

The qgis_testrunner.sh still behaves a bit oddly, as it prints that it cannot find the module, but later in the actual test it can, and the test gives an OK. The part of the qgis_testrunner.sh script that counts fails and successes is bugged as well for the created logs, changing the lines of code to grep reading the logfile directly, so grep -c FAILED /tmp/qgis_testrunner_*** instead of echo $OUTPUT | grep -c FAILED, fixed it for me in some local tests. I probally have to raise an issue for that.

TODO

Installing dependencies to run Github Actions on Windows

  1. Install WSL2 manually
  2. Install Docker Desktop
  3. Install act e.g. using Chocolatey

Run locally on Windows

For installing docker on Windows, see below.

To run the tests locally change in .github/workflows/tests.yml (assuming you have your repo under c:\src\imod-qgis:

      - name: Install qgis image
        run: docker run -d --name qgis-testing-environment -v ${GITHUB_WORKSPACE}:/tests_directory -e DISPLAY=:99 qgis/qgis:release-3_18 #Run on Github
        #run: docker run -d --name qgis-testing-environment -v c:/src/imod-qgis:/tests_directory -e DISPLAY=:99 qgis/qgis:release-3_18 #Run locally

to

      - name: Install qgis image
        #run: docker run -d --name qgis-testing-environment -v ${GITHUB_WORKSPACE}:/tests_directory -e DISPLAY=:99 qgis/qgis:release-3_18 #Run on Github
        run: docker run -d --name qgis-testing-environment -v c:/src/imod-qgis:/tests_directory -e DISPLAY=:99 qgis/qgis:release-3_18 #Run locally

This is because WSL2 + Docker apparently require absolute paths to refer to stuff on the mount, so c:/ instead of the usual /mnt/c/ (which is what is returned by ${GITHUB_WORKSPACE} locally.

You can then run the workflow by cd'ing into the repo (e.g. cd c:\src\imod-qgis) and calling act.

Tips running locally on Windows

Example repos I used ideas from:

evetion commented 1 year ago

Links to https://github.com/Deltares/Ribasim/pull/367