Skip to content
Permalink
Browse files

Added QGIS testing environment to dockers

Also:
- renamed .docker to docker (now it's public and official)
- added dependencies for python CI testing
  • Loading branch information
elpaso committed Nov 13, 2018
1 parent 7cce9b3 commit 2094ff827e9279e1d2009054958e86b8d3c8e14d
File renamed without changes.
@@ -8,6 +8,9 @@ ARG CACHE_DIR
FROM qgis/qgis3-build-deps:${DOCKER_TAG}
MAINTAINER Denis Rouzaud <denis@opengis.ch>

LABEL Description="Docker container with QGIS for CI testing" Vendor="QGIS.org" Version="1.1"


ENV CC=/usr/lib/ccache/clang
ENV CXX=/usr/lib/ccache/clang++
ENV QT_SELECT=5
@@ -25,7 +28,7 @@ RUN cmake \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_DESKTOP=OFF \
-DWITH_DESKTOP=ON \
-DWITH_SERVER=ON \
-DWITH_3D=ON \
-DWITH_BINDINGS=ON \
@@ -42,4 +45,28 @@ RUN cmake \
&& ninja install \
&& rm -rf /usr/src/QGIS

################################################################################
# Python testing environment setup

# Add QGIS test runner
COPY docker/qgis_resources/test_runner/qgis_* /usr/bin/

# Make all scripts executable
RUN chmod +x /usr/bin/qgis_*

# Add supervisor service configuration script
COPY docker/qgis_resources/supervisor/supervisord.conf /etc/supervisor/
COPY docker/qgis_resources/supervisor/supervisor.xvfb.conf /etc/supervisor/supervisor.d/

# Python paths are for
# - kartoza images (compiled)
# - deb installed
# - built from git
# needed to find PyQt wrapper provided by QGIS
ENV PYTHONPATH=/usr/share/qgis/python/:/usr/lib/python3/dist-packages/qgis:/usr/share/qgis/python/qgis


WORKDIR /

# Run supervisor
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
@@ -1,7 +1,7 @@
FROM ubuntu:18.04
MAINTAINER Denis Rouzaud <denis@opengis.ch>

LABEL Description="Docker container with QGIS dependencies" Vendor="QGIS.org" Version="1.0"
LABEL Description="Docker container with QGIS dependencies" Vendor="QGIS.org" Version="1.1"

# && echo "deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu xenial main" >> /etc/apt/sources.list \
# && echo "deb-src http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu xenial main" >> /etc/apt/sources.list \
@@ -11,7 +11,8 @@ LABEL Description="Docker container with QGIS dependencies" Vendor="QGIS.org" Ve
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& apt-get update \
&& apt-get install -y \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
apt-transport-https \
bison \
ca-certificates \
@@ -77,6 +78,7 @@ RUN apt-get update \
python3-pyqt5.qsci \
python3-pyqt5.qtsql \
python3-pyqt5.qtsvg \
python3-pyqt5.qtwebkit \
python3-sip \
python3-sip-dev \
python3-termcolor \
@@ -103,6 +105,11 @@ RUN apt-get update \
xfonts-base \
xfonts-scalable \
xvfb \
opencl-headers \
ocl-icd-libopencl1 \
ocl-icd-opencl-dev \
supervisor \
expect \
&& pip3 install \
psycopg2 \
numpy \
@@ -114,6 +121,12 @@ RUN apt-get update \
owslib \
oauthlib \
pyopenssl \
pep8 \
pexpect \
capturer \
sphinx \
requests \
six \
&& apt-get clean


@@ -0,0 +1,7 @@
pep8
pexpect
capturer
sphinx
requests
future
six
@@ -0,0 +1,4 @@
; Supervisor config file for Xvfb

[program:Xvfb]
command=/usr/bin/Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset -nolisten tcp
@@ -0,0 +1,13 @@
; Supervisor config file.

[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/var/run/supervisord.pid
childlogdir=/var/log

[include]
files = /etc/supervisor/supervisor.d/*.conf
@@ -0,0 +1,82 @@
#!/bin/bash
# Setup QGIS for the automated tests
# This is normally called from Travis or rundockertests.sh
# before running the tests for a particular plugin
#
# Note: on QGIS3 assumes the default profile for root user
#
# - create the folders
# - install startup.py monkey patches
# - disable tips
# - enable the plugin

PLUGIN_NAME=$1
CONF_FOLDER="/root/.config/QGIS"
CONF_FILE="${CONF_FOLDER}/QGIS2.conf"
CONF_MASTER_FOLDER="/root/.local/share/QGIS/QGIS3/profiles/default/QGIS/"
CONF_MASTER_FILE="${CONF_MASTER_FOLDER}/QGIS3.ini"
QGIS_FOLDER="/root/.qgis2"

QGIS_MASTER_FOLDER="/root/.local/share/QGIS/QGIS3/profiles/default"
PLUGIN_FOLDER="${QGIS_FOLDER}/python/plugins"
PLUGIN_MASTER_FOLDER="${QGIS_MASTER_FOLDER}/python/plugins"

STARTUP_FOLDER="${QGIS_FOLDER}/python"
STARTUP_MASTER_FOLDER="/root/.local/share/QGIS/QGIS3/"

# Creates the config file
mkdir -p $CONF_FOLDER
if [ -e "$CONF_FILE" ]; then
rm -f $CONF_FILE
fi
touch $CONF_FILE


mkdir -p $CONF_MASTER_FOLDER
if [ -e "$CONF_MASTER_FILE" ]; then
rm -f $CONF_MASTER_FILE
fi
touch $CONF_MASTER_FILE

# Creates plugin folder
mkdir -p $PLUGIN_FOLDER
mkdir -p $PLUGIN_MASTER_FOLDER
mkdir -p $STARTUP_MASTER_FOLDER

# Install the monkey patches to prevent modal stacktrace on python errors
cp /usr/bin/qgis_startup.py ${STARTUP_FOLDER}/startup.py
cp /usr/bin/qgis_startup.py ${STARTUP_MASTER_FOLDER}/startup.py

# Disable tips
printf "[Qgis]\n" >> $CONF_FILE
# !!!! Note that on master it is lowercase !!!!
printf "[qgis]\n" >> $CONF_MASTER_FILE
SHOW_TIPS=`qgis --help 2>&1 | head -2 | grep 'QGIS - ' | perl -npe 'chomp; s/QGIS - (\d+)\.(\d+).*/showTips\1\2=false/'`
printf "$SHOW_TIPS\n\n" >> $CONF_FILE
printf "$SHOW_TIPS\n\n" >> $CONF_MASTER_FILE

if [ -n "$PLUGIN_NAME" ]; then
# Enable plugin
printf '[PythonPlugins]\n' >> $CONF_FILE
printf "${PLUGIN_NAME}=true\n\n" >> $CONF_FILE

printf '[PythonPlugins]\n' >> $CONF_MASTER_FILE
printf "${PLUGIN_NAME}=true\n\n" >> $CONF_MASTER_FILE
fi

# Disable firstRunVersionFlag for master
printf "\n[migration]\n" >> $CONF_MASTER_FILE
printf "fileVersion=2\n" >> $CONF_MASTER_FILE
printf "firstRunVersionFlag=29900\n" >> $CONF_MASTER_FILE
printf "settings=true\n\n" >> $CONF_MASTER_FILE


# Install the plugin
if [ ! -L "${PLUGIN_FOLDER}/${PLUGIN_NAME}" ]; then
ln -s /tests_directory/${PLUGIN_NAME} ${PLUGIN_FOLDER}
echo "Plugin folder linked in ${PLUGIN_FOLDER}/${PLUGIN_NAME}"
fi
if [ ! -d "${PLUGIN_MASTER_FOLDER}/${PLUGIN_NAME}" ]; then
ln -s /tests_directory/${PLUGIN_NAME} ${PLUGIN_MASTER_FOLDER}
echo "Plugin master folder linked in ${PLUGIN_MASTER_FOLDER}/${PLUGIN_NAME}"
fi
@@ -0,0 +1,26 @@
"""
Disable QGIS modal error dialog.
This script is meant to be run automatically when QGIS starts.
Is should be renamed to `startup.py` and placed into ~/.qgis2/python/startup.py
or ~/.qgis-dev/python/startup.py or ~/.qgis3/python/startup.py
"""
from qgis import utils
import traceback


def _showException(type, value, tb, msg, messagebar=False):
print(msg)
logmessage = ''
for s in traceback.format_exception(type, value, tb):
logmessage += s.decode('utf-8', 'replace') if hasattr(s, 'decode') else s
print(logmessage)


def _open_stack_dialog(type, value, tb, msg, pop_error=True):
print(msg)


utils.showException = _showException
utils.open_stack_dialog = _open_stack_dialog

0 comments on commit 2094ff8

Please sign in to comment.
You can’t perform that action at this time.