-
-
Notifications
You must be signed in to change notification settings - Fork 30
feat: download the qgis_setup.sh to run plugin tests #129
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
c3ff8d9
82662a3
f4e00cc
432dd6f
82d9f81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,8 @@ ARG release=noble | |
| FROM ${os}:${release} | ||
| LABEL maintainer="OPENGIS.ch <info@opengis.ch>" | ||
|
|
||
| ARG os | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not used anymore after |
||
| ARG release | ||
| ARG repo | ||
| ARG qgis_version=master | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this to where it's used, for layer caching purposes |
||
|
|
||
| RUN apt update && apt install -y gnupg wget software-properties-common && \ | ||
| wget -qO - https://qgis.org/downloads/qgis-2022.gpg.key | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg --import && \ | ||
|
|
@@ -20,6 +18,12 @@ RUN apt update && apt install -y gnupg wget software-properties-common && \ | |
| python3-pytest python3-mock xvfb qttools5-dev-tools pyqt5-dev-tools && \ | ||
| apt-get clean | ||
|
|
||
| # Test version | ||
| # Test version and download plugin test scripts | ||
| COPY scripts/check_version.sh /opt/check_version.sh | ||
| COPY scripts/qgis_test_setup.sh /opt/qgis_test_setup.sh | ||
|
|
||
| ARG qgis_version=master | ||
| ARG qgis_ref | ||
|
|
||
| RUN /opt/check_version.sh ${qgis_version} | ||
| RUN /opt/qgis_test_setup.sh ${qgis_ref} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will download and install the necessary scripts from |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,25 @@ | |
| [](https://hub.docker.com/r/qgis/qgis) | ||
|
|
||
| A simple QGIS desktop Docker image, pushed on [Docker Hub](https://hub.docker.com/r/qgis/qgis). | ||
|
|
||
| ## Python Plugin testing | ||
|
|
||
| This image can be used to set up a testing environment for plugins, e.g. | ||
|
|
||
| ``` | ||
| PLUGIN_DIR=<plugin_name> # e.g. PLUGIN_NAME=valhalla | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested this with https://github.com/nilsnolde/valhalla-qgis-plugin, should work similarly for all plugins |
||
| # it's important to map the plugin's root to /tests_directory and that $PLUGIN_DIR is the sub-directory containing the plugin sources | ||
| docker run -dt --name qgis -v ${PWD}:/tests_directory -e QT_QPA_PLATFORM="offscreen" qgis/qgis:latest | ||
| # run the qgis_setup.sh script and then your tests, e.g. | ||
| docker exec qgis bash -c "qgis_setup.sh ${PLUGIN_DIR}" | ||
| # now you can run whatever you need | ||
| docker exec qgis bash -c "apt-get update && apt-get install -y pre-commit python3-coverage" | ||
| docker exec qgis bash -c "git config --global --add safe.directory /tests_directory" | ||
| docker exec qgis bash -c "cd /tests_directory && pre-commit run --all-files" | ||
| docker exec qgis bash -c "cd /tests_directory && python3 -m coverage run -m unittest discover" | ||
| docker exec qgis bash -c "cd /tests_directory && python3 -m coverage report" | ||
| docker exec qgis bash -c "cd /tests_directory && python3 -m coverage report" | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Makes the qgis_setup.sh script available for plugin testing | ||
|
|
||
| # Usage: qgis_test_setup.sh <docker_tag> <plugin_name>, e.g. ./qgis_test_setup.sh 3.44.1 | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Check if version argument is provided | ||
| if [[ -z "$1" ]]; then | ||
| echo "Usage: $0 <QGIS git ref, e.g. final-3_44_1 or master>" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Convert docker version to branch name | ||
| QGIS_REF="$1" | ||
|
|
||
| SETUP_SCRIPT_URL="https://raw.githubusercontent.com/qgis/QGIS/${QGIS_REF}/.docker/qgis_resources/test_runner/qgis_setup.sh" | ||
| SETUP_SCRIPT_PATH="/usr/bin/$(basename ${SETUP_SCRIPT_URL})" | ||
|
|
||
| STARTUP_SCRIPT_URL="https://raw.githubusercontent.com/qgis/QGIS/${QGIS_REF}/.docker/qgis_resources/test_runner/qgis_startup.py" | ||
| STARTUP_SCRIPT_PATH="/usr/bin/$(basename ${STARTUP_SCRIPT_URL})" | ||
|
|
||
| echo "Downloading qgis_setup.sh and friends from ref ${QGIS_REF}..." | ||
|
|
||
| wget -q -O "$SETUP_SCRIPT_PATH" "$SETUP_SCRIPT_URL" | ||
| wget -q -O "$STARTUP_SCRIPT_PATH" "$STARTUP_SCRIPT_URL" | ||
|
|
||
| chmod +x "$SETUP_SCRIPT_PATH" | ||
| chmod +x "$STARTUP_SCRIPT_PATH" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as requested, the logic to get the git ref is now in in the workflow.
as you can see, this simply assumes that any
QGIS_VERSIONwill map tofinal-x_y_ztags (or simplymaster), it doesn't care aboutltr-x_ytags. I'm not entirely sure whatQGIS_VERSIONcan be, maybe you have a better idea here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, this shell code became a bit too big to be inlined. it's quite cumbersome to test changes locally. IMHO it'd be better to outsource this to a proper script and at least run shellcheck or so on the scripts, ideally even testing the image a bit (more) before pushing it. What do you think?