From e2bde377d6a5b97543e13b1c9865a9b9631c3293 Mon Sep 17 00:00:00 2001 From: Brad Ison Date: Wed, 13 Jun 2018 10:43:39 -0400 Subject: [PATCH] Use before_cache instead of after_failure to clean cache --- .travis.yml | 4 ++-- scripts/ci | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b29e012a..04043f651 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/scripts/ci b/scripts/ci index 681e76faa..6919ef30f 100755 --- a/scripts/ci +++ b/scripts/ci @@ -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 ;;