upload cache even when test failed
set -ue
TARGET="${1}"
+LOG_FILE="/tmp/log.txt"
echo "Environment Variables:"
env
-stages=(cache_get test)
-if [[ "${FLEXCI_BRANCH:-}" != refs/pull/* ]]; then
- # Cache will not be uploaded when testing pull-requests.
- stages+=(cache_put)
-fi
-
pull_req=""
if [[ "${FLEXCI_BRANCH:-}" == refs/pull/* ]]; then
# Extract pull-request ID
@@ -22,15 +17,22 @@ if [[ "${FLEXCI_BRANCH:-}" == refs/pull/* ]]; then
echo "Testing Pull-Request: #${pull_req}"
fi
-echo "Starting: "${TARGET}" "${stages[@]}""
+echo "Starting: "${TARGET}""
echo "****************************************************************************************************"
-CACHE_DIR=/tmp/cupy_cache PULL_REQUEST="${pull_req}" "$(dirname ${0})/run.sh" "${TARGET}" "${stages[@]}" 2>&1 | tee /tmp/log.txt
+CACHE_DIR=/tmp/cupy_cache PULL_REQUEST="${pull_req}" "$(dirname ${0})/run.sh" "${TARGET}" cache_get test 2>&1 | tee "${LOG_FILE}"
test_retval=${PIPESTATUS[0]}
echo "****************************************************************************************************"
echo "Exit with status ${test_retval}"
+if [[ "${pull_req}" != "" ]]; then
+ # Upload cache when testing a branch, even when test failed.
+ echo "Uploading cache..."
+ CACHE_DIR=/tmp/cupy_cache PULL_REQUEST="${pull_req}" "$(dirname ${0})/run.sh" "${TARGET}" cache_put | tee --append "${LOG_FILE}"
+ echo "Cache upload exit with status ${PIPESTATUS[0]}"
+fi
+
echo "Uploading the log..."
-gsutil -m -q cp /tmp/log.txt "gs://chainer-artifacts-pfn-public-ci/cupy-ci/${CI_JOB_ID}/"
+gsutil -m -q cp "${LOG_FILE}" "gs://chainer-artifacts-pfn-public-ci/cupy-ci/${CI_JOB_ID}/"
echo "****************************************************************************************************"
echo "Full log is available at:"
