Skip to content

Commit 06181e6

Browse files
committed
Timeout Travis builds to save cache in time (#6488)
1 parent e82e521 commit 06181e6

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

.ci/travis/linux/before_install.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@
1313
# #
1414
###########################################################################
1515

16-
1716
#pip3 install termcolor

.ci/travis/linux/before_script.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ pushd .docker
1919

2020
echo "travis_fold:start:travis_env"
2121
echo "${bold}${endbold}"
22-
echo "TRAVIS_BRANCH $TRAVIS_BRANCH"
23-
echo "TRAVIS_EVENT_TYPE $TRAVIS_EVENT_TYPE"
24-
echo "DOCKER_TAG $DOCKER_TAG"
25-
echo "DOCKER_DEPS_PUSH $DOCKER_DEPS_PUSH"
26-
echo "DOCKER_DEPS_IMAGE_REBUILD $DOCKER_DEPS_IMAGE_REBUILD"
27-
echo "DOCKER_QGIS_IMAGE_BUILD_PUSH $DOCKER_QGIS_IMAGE_BUILD_PUSH"
28-
echo "QGIS_LAST_BUILD_SUCCESS $QGIS_LAST_BUILD_SUCCESS"
22+
echo "TRAVIS_BRANCH: $TRAVIS_BRANCH"
23+
echo "TRAVIS_EVENT_TYPE: $TRAVIS_EVENT_TYPE"
24+
echo "DOCKER_TAG: $DOCKER_TAG"
25+
echo "DOCKER_DEPS_PUSH: $DOCKER_DEPS_PUSH"
26+
echo "DOCKER_DEPS_IMAGE_REBUILD: $DOCKER_DEPS_IMAGE_REBUILD"
27+
echo "DOCKER_QGIS_IMAGE_BUILD_PUSH: $DOCKER_QGIS_IMAGE_BUILD_PUSH"
28+
echo "QGIS_LAST_BUILD_SUCCESS: $QGIS_LAST_BUILD_SUCCESS"
29+
echo "TRAVIS_TIMESTAMP: $TRAVIS_TIMESTAMP"
2930
echo "travis_fold:end:travis_env"
3031

3132

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,31 @@ echo "travis_fold:end:cmake"
5959
#######
6060
# Build
6161
#######
62+
# Calculate the timeout for building.
63+
# The tests should be aborted before travis times out, in order to allow uploading
64+
# the ccache and therefore speedup subsequent e builds.
65+
#
66+
# Travis will kill the job after approx 90 minutes, we subtract 8 minutes for
67+
# uploading and subtract the bootstrapping time from that.
68+
# Hopefully clocks are in sync :)
69+
TRAVIS_TIME=90
70+
UPLOAD_TIME=8
71+
CURRENT_TIME=`date +%s`
72+
TIMEOUT=$(expr \( ${TRAVIS_TIME} - ${UPLOAD_TIME} \) \* 60 - ${CURRENT_TIME} + ${TRAVIS_TIMESTAMP})
73+
TIMEOUT=$(( ${TIMEOUT} < 300 ? 300 : ${TIMEOUT} ))
74+
echo "Timeout: ${TIMEOUT}s (started at ${TRAVIS_TIMESTAMP}, current: ${CURRENT_TIME})"
75+
6276
# echo "travis_fold:start:ninja-build.1"
6377
echo "${bold}Building QGIS...${endbold}"
64-
${CTEST_BUILD_COMMAND}
78+
timeout ${TIMEOUT}s ${CTEST_BUILD_COMMAND}
6579
# echo "travis_fold:end:ninja-build.1"
6680

81+
rv=$?
82+
if [ $rv -eq 124 ] ; then
83+
printf '\n\n${bold}Build and test timeout. Please restart the build for meaningful results.${endbold}\n'
84+
exit #$rv
85+
fi
86+
6787
# Temporarily uncomment to debug ccache issues
6888
# echo "travis_fold:start:ccache-debug"
6989
# cat /tmp/cache.debug

.docker/docker-compose.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ services:
2323
- TRAVIS_OS_NAME=${TRAVIS_OS_NAME}
2424
- TRAVIS_CONFIG=${TRAVIS_CONFIG}
2525
- TRAVIS=${TRAVIS}
26+
- TRAVIS_TIMESTAMP=${TRAVIS_TIMESTAMP}
2627
- QGIS_DISABLE_MESSAGE_HOOKS=1
2728
- QGIS_NO_OVERRIDE_IMPORT=1
28-

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ matrix:
1414
# on cron job, QGIS image is built and push without testing
1515
- DOCKER_QGIS_IMAGE_BUILD_PUSH=$( [[ $TRAVIS_REPO_SLUG =~ qgis/QGIS ]] && [[ $TRAVIS_EVENT_TYPE =~ cron ]] && echo "true" || echo "false" )
1616
- QGIS_LAST_BUILD_SUCCESS=true # TODO use API to know if last build succeed https://developer.travis-ci.com/resource/builds
17+
- TRAVIS_TIMESTAMP=$(date +%s)
1718
- CCACHE_DIR=${HOME}/.ccache
1819
dist: trusty
1920
sudo: false

0 commit comments

Comments
 (0)