QGIS LTR integration tests IRMT vs Engine (LTR and latest) #435
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: QGIS LTR integration tests IRMT vs Engine (LTR and latest) | |
on: | |
# NOTE: enables only scheduled or triggered manually, NOT on pull requests | |
workflow_dispatch: | |
inputs: | |
git-ref: | |
description: Git Ref | |
default: master | |
required: true | |
# push: | |
# branches: | |
# - '**' | |
schedule: | |
- cron: "0 3 * * *" | |
jobs: | |
Tests_and_docs: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
# NOTE: it would be better to point to lts and latest if possible | |
# NOTE: checking also master to make sure risk workshop demos keep working also on master | |
ENGINE_BR: ['engine-3.16', 'engine-3.21', 'master'] | |
# NOTE: we might test also for qgis/qgis:3.22 that is the version of qgis-server that we are currently using in the Geoviewer, but it currently causes a segfault | |
# NOTE: qgis:stable points to the latest release, wheread qgis:latest points to qgis master | |
QGIS_DOCKER_VERSION: ['qgis/qgis:ltr', 'qgis/qgis:stable'] | |
DEMOS: ['oqdata', 'risk-oqdata'] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: 🐍 Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
ref: ${{ matrix.ENGINE_BR }} | |
- name: Prepare Start file for docker | |
run: | | |
set -x | |
$(cat << EOF > ./startX.sh | |
apt update --allow-releaseinfo-change | |
DEBIAN_FRONTEND=noninteractive apt install -y python3-scipy python3-matplotlib python3-pyqt5.qtwebkit python3-pytest python3-pexpect xvfb git expect | |
chmod +x /tests_directory/qgis_startup.py | |
cp /tests_directory/qgis_startup.py /usr/bin/ | |
cp /tests_directory/qgis_testrunner.py /usr/bin/ | |
export DISPLAY=:1.0 | |
Xvfb :1 -screen 0 1024x768x16 | |
EOF | |
) | |
curl -O https://raw.githubusercontent.com/qgis/QGIS/master/.docker/qgis_resources/test_runner/qgis_setup.sh | |
curl -O https://raw.githubusercontent.com/qgis/QGIS/master/.docker/qgis_resources/test_runner/qgis_testrunner.sh | |
curl -O https://raw.githubusercontent.com/qgis/QGIS/master/.docker/qgis_resources/test_runner/qgis_testrunner.py | |
curl -O https://raw.githubusercontent.com/qgis/QGIS/master/.docker/qgis_resources/test_runner/qgis_startup.py | |
chmod +x ./qgis_setup.sh | |
chmod +x ./qgis_testrunner.sh | |
chmod +x ./qgis_testrunner.py | |
chmod +x ./startX.sh | |
- name: ⏳ Clone engine and restore oqdata and docker container | |
run: | | |
set -x | |
ENGINE_BR=${{ matrix.ENGINE_BR }} | |
IRMT_BR=$ENGINE_BR | |
git fetch | |
git checkout $IRMT_BR | |
curl -O https://raw.githubusercontent.com/gem/oq-engine/master/install.py | |
ls -lrt install.py | |
echo "Using branch ${ENGINE_BR}" | |
if [ "$(git ls-remote --heads https://github.com/gem/oq-engine.git ${ENGINE_BR})" = "" ]; then | |
echo "Branch ${ENGINE_BR} not found in gem/oq-engine repository" | |
exit 1 | |
fi | |
# get release version from branch name (e.g. 'engine-3.16' -> '3.16') | |
prefix="engine-" | |
if [[ $ENGINE_BR == ${prefix}* ]]; then | |
RELEASE_VERSION="${ENGINE_BR#${prefix}}" | |
else | |
RELEASE_VERSION=$ENGINE_BR | |
fi | |
python3 install.py user --version=${RELEASE_VERSION} | |
export PIP_DEFAULT_TIMEOUT=100 | |
echo "Restore ${{matrix.DEMOS}} demos for $ENGINE_BR branch " | |
source $HOME/openquake/bin/activate | |
oq reset -y | |
oq restore https://artifacts.openquake.org/travis/${{matrix.DEMOS}}-${ENGINE_BR}.zip ~/oqdata | |
oq webui start 172.17.0.1:8800 --skip-browser &> webui.log & | |
echo "Waiting WEBUI up on port 8800...." | |
while ! nc -z 172.17.0.1 8800; do | |
sleep 5 | |
done | |
curl http://172.17.0.1:8800/v1/engine_version | |
# | |
DOCKER_HOST=`ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+'` | |
ENGINE_HOST=`echo http://$DOCKER_HOST:8800` | |
docker run -d -t --name qgis -v /tmp/.X11-unix:/tmp/.X11-unix -v ${PWD}:/tests_directory -e OQ_ENGINE_HOST='http://172.17.0.1:8800' \ | |
-e BRANCH="$IRMT_BR" -e ONLY_CALC_ID="$ONLY_CALC_ID" -e ONLY_OUTPUT_TYPE="$ONLY_OUTPUT_TYPE" -e GEM_QGIS_TEST=y ${{ matrix.QGIS_DOCKER_VERSION }} \ | |
bash -c "/tests_directory/startX.sh" | |
sleep 10 | |
- name: ℧ Run unit test | |
run: | | |
set -x | |
ENGINE_BR=${{ matrix.ENGINE_BR }} | |
IRMT_BR=$ENGINE_BR | |
git fetch | |
git checkout $IRMT_BR | |
# OGR_SQLITE_JOURNAL=delete prevents QGIS from using WAL, which modifies geopackages even if they are just read | |
docker exec -t qgis bash -c "export DISPLAY=:1.0; export PYTHONPATH=/usr/share/qgis/python/plugins/:$PYTHONPATH; OGR_SQLITE_JOURNAL=delete python3 -m pytest -v /tests_directory/svir/test/unit/" | |
- name: ⨕ Run Integration test | |
run: | | |
set -x | |
ENGINE_BR=${{ matrix.ENGINE_BR }} | |
IRMT_BR=$ENGINE_BR | |
git fetch | |
git checkout $IRMT_BR | |
# get release version from branch name (e.g. 'engine-3.16' -> '3.16') | |
prefix="engine-" | |
if [[ $ENGINE_BR == ${prefix}* ]]; then | |
RELEASE_VERSION="${ENGINE_BR#${prefix}}" | |
else | |
RELEASE_VERSION=$ENGINE_BR | |
fi | |
# NOTE: if we want to enable it, we need to use the proper folder after engine user installation | |
OQ_TEST_RUN_CALC=0 | |
if [ "${{ matrix.DEMOS }}" != "risk-oqdata" -a "${RELEASE_VERSION}" != "3.16" ]; then | |
OQ_CHECK_MISSING_OUTPUTS=1 | |
else | |
OQ_CHECK_MISSING_OUTPUTS=0 | |
fi | |
echo "OQ_CHECK_MISSING_OUTPUTS: ${OQ_CHECK_MISSING_OUTPUTS}" | |
echo "OQ_TEST_RUN_CALC: ${OQ_TEST_RUN_CALC}" | |
# NOTE: the check on the existence of the engine branch is already done in the previous step | |
docker exec qgis sh -c "export DISPLAY=:1.0; echo 'Running against oq-engine on branch ${ENGINE_BR}'" | |
docker exec qgis sh -c "export DISPLAY=:1.0; /tests_directory/qgis_setup.sh svir" | |
docker exec -e OQ_CHECK_MISSING_OUTPUTS=${OQ_CHECK_MISSING_OUTPUTS} -e OQ_TEST_RUN_CALC=${OQ_TEST_RUN_CALC} \ | |
-t qgis sh -c "export DISPLAY=:1.0; cd /tests_directory && ./qgis_testrunner.sh svir.test.integration.test_drive_oq_engine" | |
- name: ㏒ Display web logs | |
run: | | |
set -x | |
cat webui.log |