Skip to content

Commit

Permalink
CI workflow for tests (#704)
Browse files Browse the repository at this point in the history
* added admin operations script and test workflow

* decreased number of QGIS images to test against

decreased number of QGIS images to test against

* full confs for running tests in ci

* added test suite

added test suite

added test suite

added test suite

added test suite

* expand QGIS test images matrix

added test suite

added test suite

added test suite

* update info about the test action workflow

* reformatted using black

* use correct link when installing plugin into the test QGIS image

* change docker compose version

* include test_ci for checking tests runs before making a PR

* update test image before running the tests

update test image before running the tests

update test image before running the tests

update test image before running the tests

update test image before running the tests

update test image before running the tests

update test image before running the tests

update test image before running the tests

* added comment about display issue workaround

* removed admin.py its changes will be implemented in another PR
  • Loading branch information
Samweli authored Nov 4, 2022
1 parent 55920b3 commit 9670050
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 10 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Runs tests on QGIS 3.16, 3.22 LTR, 3.26 and master branch
name: Continous Integration

on:
workflow_dispatch:
push:
branches:
- main
- test_ci
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- main

env:
# Global environment variable
IMAGE: qgis/qgis
WITH_PYTHON_PEP: "true"
MUTE_LOGS: "true"

jobs:
test:
runs-on: ubuntu-latest
name: Running tests on QGIS ${{ matrix.qgis_version_tag }}

strategy:
fail-fast: false
matrix:
qgis_version_tag:
- release-3_22
- release-3_26
- latest

steps:

- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Preparing docker-compose environment
env:
QGIS_VERSION_TAG: ${{ matrix.qgis_version_tag }}
run: |
cat << EOF > .env
QGIS_VERSION_TAG=${QGIS_VERSION_TAG}
IMAGE=${IMAGE}
ON_TRAVIS=true
MUTE_LOGS=${MUTE_LOGS}
WITH_PYTHON_PEP=${WITH_PYTHON_PEP}
EOF
- name: Preparing test environment
run: |
cat .env
docker pull "${IMAGE}":${{ matrix.qgis_version_tag }}
docker-compose up -d
sleep 10
- name: Run test suite
run: |
docker-compose exec -T qgis-testing-environment sh -c "apt-get update"
docker-compose exec -T qgis-testing-environment sh -c "apt-get install -y python3-opencv"
docker-compose exec -T qgis-testing-environment qgis_testrunner.sh LDMP.test.testplugin
29 changes: 19 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
version: '3'

version: '2.1'
services:
qgis:
volumes:
- ./:/tests_directory
environment:
DISPLAY: ':99'
build:
context: .
container_name: trendsearth_qgis_1
qgis-testing-environment:
image: ${IMAGE}:${QGIS_VERSION_TAG}
volumes:
- ./:/tests_directory
environment:
QGIS_VERSION_TAG: "${QGIS_VERSION_TAG}"
WITH_PYTHON_PEP: "${WITH_PYTHON_PEP}"
ON_TRAVIS: "${ON_TRAVIS}"
MUTE_LOGS: "${MUTE_LOGS}"
DISPLAY: ":99"
working_dir: /tests_directory
entrypoint: /tests_directory/docker/qgis-testing-entrypoint.sh
# Enable "command:" line below to immediately run unittests upon docker-compose up
# command: qgis_testrunner.sh test_suite.test_package
# Default behaviour of the container is to standby
command: tail -f /dev/null
# qgis_testrunner.sh needs tty for tee
tty: true
16 changes: 16 additions & 0 deletions docker/qgis-testing-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Docker entrypoint file intended for docker-compose recipe for running unittests

set -e

source /tests_directory/docker/trends-earth-test-pre-scripts.sh

# Run supervisor
# This is the default command of qgis/qgis but we will run it in background
supervisord -c /etc/supervisor/supervisord.conf &

# Wait for XVFB
sleep 10

exec "$@"
11 changes: 11 additions & 0 deletions docker/trends-earth-test-pre-scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

qgis_setup.sh

# FIX default installation because the sources must be in "trends.earth parent folder
rm -rf /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/trends.earth
ln -sf /tests_directory/LDMP /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/trends.earth
ln -sf /tests_directory/LDMP /usr/share/qgis/python/plugins/trends.earth

pip3 install -r /tests_directory/requirements.txt
pip3 install -r /tests_directory/requirements-dev.txt

0 comments on commit 9670050

Please sign in to comment.