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 - sudo service postgresql stop
# Clean the cache if any step fails. # Clean the cache if any step fails.
after_failure: before_cache:
- scripts/ci clean - scripts/ci fail-clean
cache: cache:
timeout: 1000 timeout: 1000

View file

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