Use before_cache instead of after_failure to clean cache

This commit is contained in:
Brad Ison 2018-06-13 10:43:39 -04:00
parent 23c01b40c5
commit e2bde377d6
No known key found for this signature in database
GPG key ID: 972D14B0BE6DE287
2 changed files with 12 additions and 2 deletions

View file

@ -14,8 +14,8 @@ before_script:
- sudo service postgresql stop
# Clean the cache if any step fails.
after_failure:
- scripts/ci clean
before_cache:
- scripts/ci fail-clean
cache:
timeout: 1000

View file

@ -43,6 +43,12 @@ clean_cache() {
rm "${IMAGE_TAR}"
}
fail_clean() {
if [[ $TRAVIS_TEST_RESULT -ne 0 ]]; then
echo "Job failed. Cleaning cache..."
clean_cache
fi
}
quay_run() {
docker run --net=host -e TEST_DATABASE_URI -ti "${IMAGE}:${IMAGE_TAG}" "$@"
@ -148,6 +154,10 @@ case "$1" in
postgres
;;
fail-clean)
fail_clean
;;
clean)
clean_cache
;;