QGIS/.ci/travis/linux/docker-build-test.sh

169 lines
4.6 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2017-09-21 09:07:37 +02:00
set -e
2017-09-21 09:07:37 +02:00
##############
# Setup ccache
##############
export CCACHE_TEMPDIR=/tmp
2017-10-29 10:44:08 +01:00
ccache -M 1G
2017-10-29 09:51:51 +01:00
# Temporarily uncomment to debug ccache issues
# export CCACHE_LOGFILE=/tmp/cache.debug
ccache -z
2017-09-21 09:07:37 +02:00
############################
# Setup the (c)test environment
############################
export LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
2017-11-09 21:33:38 +01:00
export SEGFAULT_SIGNALS="abrt segv"
2017-09-21 09:07:37 +02:00
export CTEST_BUILD_COMMAND="/usr/bin/ninja"
export CTEST_PARALLEL_LEVEL=1
2017-08-08 09:13:16 +02:00
2017-10-07 11:40:21 +02:00
##############################
# Variables for output styling
##############################
bold=$(tput bold)
endbold=$(tput sgr0)
2017-09-21 09:07:37 +02:00
###########
# Configure
###########
2017-10-07 09:42:05 +02:00
pushd /root/QGIS > /dev/null
2017-09-21 09:07:37 +02:00
mkdir -p build
2017-10-07 09:42:05 +02:00
pushd build > /dev/null
2017-10-07 09:50:19 +02:00
echo "travis_fold:start:cmake"
2017-10-07 11:40:21 +02:00
echo "${bold}Running cmake...${endbold}"
cmake \
-GNinja \
2018-04-04 13:17:57 +02:00
-DUSE_CCACHE=OFF \
-DWITH_QUICK=ON \
-DWITH_3D=ON \
-DWITH_STAGED_PLUGINS=ON \
-DWITH_GRASS=OFF \
-DSUPPRESS_QT_WARNINGS=ON \
-DENABLE_MODELTEST=ON \
-DENABLE_PGTEST=ON \
2018-10-09 09:01:50 +10:00
-DENABLE_MSSQLTEST=ON \
-DWITH_QSPATIALITE=ON \
-DWITH_QWTPOLAR=OFF \
-DWITH_APIDOC=OFF \
-DWITH_ASTYLE=OFF \
-DWITH_DESKTOP=ON \
-DWITH_BINDINGS=ON \
2017-11-03 17:13:47 +01:00
-DWITH_SERVER=ON \
-DDISABLE_DEPRECATED=ON \
2018-06-10 18:16:57 +02:00
-DPYTHON_TEST_WRAPPER="timeout -sSIGSEGV 55s"\
2018-09-06 08:24:41 +02:00
-DCXX_EXTRA_FLAGS="${CLANG_WARNINGS}" \
-DWERROR=TRUE \
2018-11-16 22:32:25 +01:00
-DQT5_3DEXTRA_LIBRARY="/usr/lib/x86_64-linux-gnu/libQt53DExtras.so" \
-DQT5_3DEXTRA_INCLUDE_DIR="/root/QGIS/external/qt3dextra-headers" \
-DCMAKE_PREFIX_PATH="/root/QGIS/external/qt3dextra-headers/cmake" \
2018-09-06 08:24:41 +02:00
..
2017-10-07 09:50:19 +02:00
echo "travis_fold:end:cmake"
2017-09-21 09:07:37 +02:00
#######
# Build
#######
# Calculate the timeout for building.
# The tests should be aborted before travis times out, in order to allow uploading
# the ccache and therefore speedup subsequent e builds.
#
2018-05-17 09:56:33 -04:00
# Travis will kill the job after approx 120 minutes, we subtract 8 minutes for
# uploading and subtract the bootstrapping time from that.
# Hopefully clocks are in sync :)
2018-05-17 09:56:33 -04:00
TRAVIS_TIME=120
2018-04-04 12:19:03 -04:00
UPLOAD_TIME=5
CURRENT_TIME=$(date +%s)
TIMEOUT=$((( TRAVIS_TIME - UPLOAD_TIME ) * 60 - CURRENT_TIME + TRAVIS_TIMESTAMP))
TIMEOUT=$(( TIMEOUT < 300 ? 300 : TIMEOUT ))
echo "Timeout: ${TIMEOUT}s (started at ${TRAVIS_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
2017-10-29 09:51:51 +01:00
# Temporarily uncomment to debug ccache issues
# echo "travis_fold:start:ccache-debug"
# cat /tmp/cache.debug
# echo "travis_fold:end:ccache-debug"
2017-09-21 09:07:37 +02:00
############################
# Restore postgres test data
2017-09-21 09:07:37 +02:00
############################
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
2017-10-07 09:42:05 +02:00
pushd /root/QGIS > /dev/null
/root/QGIS/tests/testdata/provider/testdata_pg.sh
2017-10-07 09:42:05 +02:00
popd > /dev/null # /root/QGIS
2018-10-09 09:01:50 +10:00
##############################
# 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
2017-09-21 09:07:37 +02:00
###########
# Run tests
###########
CURRENT_TIME=$(date +%s)
TIMEOUT=$((( TRAVIS_TIME - UPLOAD_TIME) * 60 - CURRENT_TIME + TRAVIS_TIMESTAMP))
2018-04-04 12:19:03 -04:00
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
2017-09-21 09:07:37 +02:00
########################
# Show ccache statistics
########################
2017-10-07 11:43:52 +02:00
echo "travis_fold:start:ccache.stats"
echo "ccache statistics"
ccache -s
2017-10-07 11:43:52 +02:00
echo "travis_fold:end:ccache.stats"
2017-10-07 09:42:05 +02:00
popd > /dev/null # build
popd > /dev/null # /root/QGIS
2017-09-28 11:43:30 +02:00
[ -r /tmp/ctest-important.log ] && cat /tmp/ctest-important.log || true