diff options
author | Philip Paquette <pcpaquette@gmail.com> | 2018-09-26 14:54:13 -0400 |
---|---|---|
committer | Philip Paquette <pcpaquette@gmail.com> | 2019-04-18 11:15:19 -0400 |
commit | 41a8e7633a2681bbeffc9d7379cf13da6d2fcae4 (patch) | |
tree | 680e927ef9a874566f68604700075b673a6411b5 /.jenkins/get_cache.sh | |
parent | 7db5011d67a98c05e69d29c5f2ff31314a82bde4 (diff) |
Integrating with Jenkins for PR reviews
Diffstat (limited to '.jenkins/get_cache.sh')
-rwxr-xr-x | .jenkins/get_cache.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/.jenkins/get_cache.sh b/.jenkins/get_cache.sh new file mode 100755 index 0000000..a589bd2 --- /dev/null +++ b/.jenkins/get_cache.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Validating number of arguments +if [ "$#" -ne 2 ]; then + echo "Expected 2 arguments" + echo "Syntax: ./get_cache.sh <PR_NUMBER> <BRANCH>" + echo "Use PR_NUMBER=0 if not a PR" + exit 1 +fi + +RELEASE=$(lsb_release -c -s) +PYTHON_VERSION=$(python -c "import sys; print('py%d%d' % (sys.version_info.major, sys.version_info.minor))") + +# Trying to download PR cache +if [ "$1" != "0" ]; then + CACHE_FILE="cache-pr_$1-$PYTHON_VERSION-$RELEASE.zip" + CACHE_PATH="gs://ppaquette-diplomacy/cache-jenkins/game-$CACHE_FILE" + gsutil -q stat "$CACHE_PATH" + RET_VALUE=$? + + if [ $RET_VALUE == 0 ]; then + echo "Downloading cache from $CACHE_PATH" + gsutil cp $CACHE_PATH . + unzip -qo $CACHE_FILE -d / + exit 0 + else + echo "No cache found at $CACHE_PATH" + fi +fi + +# Trying to download branch cache +CACHE_FILE="cache-$2-$PYTHON_VERSION-$RELEASE.zip" +CACHE_PATH="gs://ppaquette-diplomacy/cache-jenkins/game-$CACHE_FILE" +gsutil -q stat "$CACHE_PATH" +RET_VALUE=$? + +if [ $RET_VALUE == 0 ]; then + echo "Downloading cache from $CACHE_PATH" + gsutil cp $CACHE_PATH . + unzip -qo $CACHE_FILE -d / + exit 0 +else + echo "No cache found at $CACHE_PATH" +fi |