Fix Gitlab cache issues (#3160)

* Make parent cache download quiet

This spammed logs quite a bit

* Add "-p" to "mkdir $CI_PROJECT_DIR/cache-artifact"

Otherwise the after_script is silently aborted when the dir already exists.

* Extract parent cache artifact in own directory and later delete it

Otherwise we end up having "testlogs" (and maybe other stuff) in the
project directory, which causes future failures.
This commit is contained in:
Alexander Block 2019-10-17 11:52:26 +02:00 committed by GitHub
parent e9ed354822
commit 4db91c605b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,13 +33,17 @@ stages:
if [ "$CI_COMMIT_REF_SLUG" != "develop" -a "$CI_COMMIT_TAG" == "" ]; then
if [ ! -d $CACHE_DIR/ccache ]; then
echo "Downloading cache from develop branch"
if wget -O cache-artifact.zip https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/-/jobs/artifacts/develop/download?job=$CI_JOB_NAME; then
unzip cache-artifact.zip
mkdir cache-artifact
cd cache-artifact
if wget --quiet -O cache-artifact.zip https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/-/jobs/artifacts/develop/download?job=$CI_JOB_NAME; then
unzip -q cache-artifact.zip
rm cache-artifact.zip
mv cache-artifact/* $CACHE_DIR/
else
echo "Failed to download cache"
fi
cd ..
rm -rf cache-artifact
else
echo "Not touching cache (was initialized from previous build)"
fi
@ -97,7 +101,7 @@ stages:
after_script:
# Copy all cache files into cache-artifact so that they get uploaded. We only do this for develop so that artifacts
# stay minimal for PRs and branches (we never need them)
- mkdir $CI_PROJECT_DIR/cache-artifact
- mkdir -p $CI_PROJECT_DIR/cache-artifact
- mkdir -p $CI_PROJECT_DIR/testlogs
- |
if [ "$CI_COMMIT_REF_SLUG" = "develop" ]; then