Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
build and test in 2 steps
  • Loading branch information
3nids committed Mar 7, 2019
1 parent 9cdf051 commit a294fc7
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 86 deletions.
7 changes: 7 additions & 0 deletions .ci/travis/linux/script.sh
Expand Up @@ -16,5 +16,12 @@

set -e

docker run -t --name qgis_container -v ${TRAVIS_BUILD_DIR}:/root/QGIS -v ${CCACHE_DIR}:/root/.ccache qgis/qgis3-build-deps:${DOCKER_TAG} /root/QGIS/.ci/travis/linux/scripts/docker-qgis-build.sh
docker commit qgis_container qgis_image

docker-compose -f ${TRAVIS_BUILD_DIR}/.docker/docker-compose.travis.yml run qgis-deps

docker run -it qgis-deps

# running QGIS tests
docker-compose -f ${TRAVIS_BUILD_DIR}/.docker/docker-compose.travis.yml run qgis-deps
Expand Up @@ -75,99 +75,17 @@ echo "travis_fold:end:cmake"
# Travis will kill the job after approx 150 minutes, we subtract 5 minutes for
# uploading and subtract the bootstrapping time from that.
# Hopefully clocks are in sync :)
TRAVIS_TIME=150
UPLOAD_TIME=5

CURRENT_TIME=$(date +%s)
TIMEOUT=$((( TRAVIS_TIME - UPLOAD_TIME ) * 60 - CURRENT_TIME + TRAVIS_TIMESTAMP))
TIMEOUT=$((( TRAVIS_AVAILABLE_TIME - UPLOAD_TIME ) * 60 - CURRENT_TIME + TRAVIS_AVAILABLE_TIMESTAMP))
TIMEOUT=$(( TIMEOUT < 300 ? 300 : TIMEOUT ))
echo "Timeout: ${TIMEOUT}s (started at ${TRAVIS_TIMESTAMP}, current: ${CURRENT_TIME})"
echo "Timeout: ${TIMEOUT}s (started at ${TRAVIS_AVAILABLE_TIMESTAMP}, current: ${CURRENT_TIME})"

# echo "travis_fold:start:ninja-build.1"
echo "${bold}Building QGIS...${endbold}"
timeout ${TIMEOUT}s ${CTEST_BUILD_COMMAND}
# echo "travis_fold:end:ninja-build.1"

rv=$?
if [ $rv -eq 124 ] ; then
printf '\n\n${bold}Build and test timeout. Please restart the build for meaningful results.${endbold}\n'
exit #$rv
fi

##############################
# Run Python Tests on QGIS app
##############################
# Passing cases:
echo "QGIS tests runner"
pushd /root/qgis_test_runner
./qgis_testrunner.sh test_testrunner.run_passing && echo "1/5 succeeded" || exit 1
./qgis_testrunner.sh test_testrunner.run_skipped_and_passing && echo "2/5 succeeded" || exit 1
# Failing cases:
./qgis_testrunner.sh test_testrunner && exit 1 || echo "3/5 succeeded"
./qgis_testrunner.sh test_testrunner.run_all && exit 1 || echo "5/5 succeeded"
./qgis_testrunner.sh test_testrunner.run_failing && exit 1 || echo "5/5 succeeded"
popd


# Temporarily uncomment to debug ccache issues
# echo "travis_fold:start:ccache-debug"
# cat /tmp/cache.debug
# echo "travis_fold:end:ccache-debug"

############################
# Restore postgres test data
############################
printf "[qgis_test]\nhost=postgres\nport=5432\ndbname=qgis_test\nuser=docker\npassword=docker" > ~/.pg_service.conf
export PGUSER=docker
export PGHOST=postgres
export PGPASSWORD=docker
export PGDATABASE=qgis_test

pushd /root/QGIS > /dev/null
/root/QGIS/tests/testdata/provider/testdata_pg.sh
popd > /dev/null # /root/QGIS

##############################
# Restore SQL Server test data
##############################

echo "Importing SQL Server test data..."

export SQLUSER=sa
export SQLHOST=mssql
export SQLPORT=1433
export SQLPASSWORD='<YourStrong!Passw0rd>'
export SQLDATABASE=qgis_test

export PATH=$PATH:/opt/mssql-tools/bin

pushd /root/QGIS > /dev/null
/root/QGIS/tests/testdata/provider/testdata_mssql.sh
popd > /dev/null # /root/QGIS

echo "Setting up DSN for test SQL Server"

cat <<EOT > /etc/odbc.ini
[ODBC Data Sources]
testsqlserver = ODBC Driver 17 for SQL Server
[testsqlserver]
Driver = ODBC Driver 17 for SQL Server
Description = Test SQL Server
Server = mssql
EOT

###########
# Run tests
###########
CURRENT_TIME=$(date +%s)
TIMEOUT=$((( TRAVIS_TIME - UPLOAD_TIME) * 60 - CURRENT_TIME + TRAVIS_TIMESTAMP))
echo "Timeout: ${TIMEOUT}s (started at ${TRAVIS_TIMESTAMP}, current: ${CURRENT_TIME})"
timeout ${TIMEOUT}s python3 /root/QGIS/.ci/travis/scripts/ctest2travis.py xvfb-run ctest -V -E "$(cat /root/QGIS/.ci/travis/linux/blacklist.txt | sed -r '/^(#.*?)?$/d' | paste -sd '|' -)" -S /root/QGIS/.ci/travis/travis.ctest --output-on-failure
rv=$?
if [ $rv -eq 124 ] ; then
printf '\n\n${bold}Build and test timeout. Please restart the build for meaningful results.${endbold}\n'
exit #$rv
fi

########################
# Show ccache statistics
Expand All @@ -182,3 +100,10 @@ popd > /dev/null # /root/QGIS

[ -r /tmp/ctest-important.log ] && cat /tmp/ctest-important.log || true

############################
# Exit with error if timeout
############################
if [ $rv -eq 124 ] ; then
printf '\n\n${bold}Build and test timeout. Please restart the build for meaningful results.${endbold}\n'
exit #$rv
fi
82 changes: 82 additions & 0 deletions .ci/travis/linux/scripts/docker-qgis-test.sh
@@ -0,0 +1,82 @@
#!/usr/bin/env bash

set -e

##############################
# Run Python Tests on QGIS app
##############################
# Passing cases:
echo "QGIS tests runner"
pushd /root/qgis_test_runner
./qgis_testrunner.sh test_testrunner.run_passing && echo "1/5 succeeded" || exit 1
./qgis_testrunner.sh test_testrunner.run_skipped_and_passing && echo "2/5 succeeded" || exit 1
# Failing cases:
./qgis_testrunner.sh test_testrunner && exit 1 || echo "3/5 succeeded"
./qgis_testrunner.sh test_testrunner.run_all && exit 1 || echo "5/5 succeeded"
./qgis_testrunner.sh test_testrunner.run_failing && exit 1 || echo "5/5 succeeded"
popd


# Temporarily uncomment to debug ccache issues
# echo "travis_fold:start:ccache-debug"
# cat /tmp/cache.debug
# echo "travis_fold:end:ccache-debug"

############################
# Restore postgres test data
############################
printf "[qgis_test]\nhost=postgres\nport=5432\ndbname=qgis_test\nuser=docker\npassword=docker" > ~/.pg_service.conf
export PGUSER=docker
export PGHOST=postgres
export PGPASSWORD=docker
export PGDATABASE=qgis_test

pushd /root/QGIS > /dev/null
/root/QGIS/tests/testdata/provider/testdata_pg.sh
popd > /dev/null # /root/QGIS

##############################
# Restore SQL Server test data
##############################

echo "Importing SQL Server test data..."

export SQLUSER=sa
export SQLHOST=mssql
export SQLPORT=1433
export SQLPASSWORD='<YourStrong!Passw0rd>'
export SQLDATABASE=qgis_test

export PATH=$PATH:/opt/mssql-tools/bin

pushd /root/QGIS > /dev/null
/root/QGIS/tests/testdata/provider/testdata_mssql.sh
popd > /dev/null # /root/QGIS

echo "Setting up DSN for test SQL Server"

cat <<EOT > /etc/odbc.ini
[ODBC Data Sources]
testsqlserver = ODBC Driver 17 for SQL Server
[testsqlserver]
Driver = ODBC Driver 17 for SQL Server
Description = Test SQL Server
Server = mssql
EOT

###########
# Run tests
###########
CURRENT_TIME=$(date +%s)
TIMEOUT=$((( TRAVIS_AVAILABLE_TIME - UPLOAD_TIME) * 60 - CURRENT_TIME + TRAVIS_AVAILABLE_TIMESTAMP))
echo "Timeout: ${TIMEOUT}s (started at ${TRAVIS_AVAILABLE_TIMESTAMP}, current: ${CURRENT_TIME})"
timeout ${TIMEOUT}s python3 /root/QGIS/.ci/travis/scripts/ctest2travis.py xvfb-run ctest -V -E "$(cat /root/QGIS/.ci/travis/linux/blacklist.txt | sed -r '/^(#.*?)?$/d' | paste -sd '|' -)" -S /root/QGIS/.ci/travis/travis.ctest --output-on-failure
rv=$?
if [ $rv -eq 124 ] ; then
printf '\n\n${bold}Build and test timeout. Please restart the build for meaningful results.${endbold}\n'
exit #$rv
fi



File renamed without changes.
2 changes: 1 addition & 1 deletion .docker/docker-compose.travis.yml
Expand Up @@ -13,7 +13,7 @@ services:

qgis-deps:
tty: true
image: qgis/qgis3-build-deps:${DOCKER_TAG}
image: qgis_image
volumes:
- ${TRAVIS_BUILD_DIR}:/root/QGIS
- ${CCACHE_DIR}:/root/.ccache # if changed, also change env var
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -16,6 +16,8 @@ if: NOT branch =~ /^(cherry-pick-)?backport-\d+-on-/
env:
global:
- TRAVIS_TIMESTAMP=$(date +%s)
- TRAVIS_AVAILABLE_TIME=150 # in minutes
- UPLOAD_TIME=5 # time considered to start the machine and the container (minutes)
# Docker hub username and passowrd
- secure: "b7eMDIolaAnq1voGKC1ez7Kcf+/A0WZDJEHBvNwk2KubBfrGOE83GMDrFNF4NqjIprqIAvVKj+TrX1ckCvs24re3IqUJo71TaF1IgxzDDPwSsmNh5UMmvZkeiJys9bWjqDO9wYR5ietNmIE18qyMc8ToJk8oKm6AXuAG2n6znmM="
- secure: "PHCp7F3nApp38Mz6b4/OLxgfBiikRGzPQDHg3R5LX+SQOll24c/DMtwpPwizNuFEiCFcRmJ9uc1t0HWEerIZe5uqm7AtE/nMXBsvDZ+hj4Tz/fEBF98a1k4WLYheN1exFidVkJgdAeiwMOOUQXw5KuIX62bxBdzsdcd0QGwxiXo="
Expand Down

0 comments on commit a294fc7

Please sign in to comment.