From 5fef742badd331246fdd339a13677910f12724b0 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 20 Dec 2024 14:50:38 +0200 Subject: [PATCH] Gradle: Echo directory variables for debugging purposes --- bin/restore_cache | 5 +++++ bin/restore_gradle_dependency_cache | 10 +++++++++- bin/save_cache | 3 +++ bin/save_gradle_dependency_cache | 3 +++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bin/restore_cache b/bin/restore_cache index 0d32345e..a0ce2edd 100755 --- a/bin/restore_cache +++ b/bin/restore_cache @@ -36,12 +36,17 @@ if aws s3api head-object --bucket "$S3_BUCKET_NAME" --key "$CACHE_KEY" > /dev/nu aws s3 cp "s3://$S3_BUCKET_NAME/$CACHE_KEY" "$CACHE_KEY" --quiet fi + echo "Current directory is: $(pwd)" + echo "Directory contents are (BEFORE): $(ls -la)" COMPRESSED_CACHE_SIZE=$(wc -c < "$CACHE_KEY") echo " Decompressing" tar -xf "$CACHE_KEY" if [ -n "$CACHE_FILE" ]; then UNCOMPRESSED_CACHE_SIZE=$(du -sb "$CACHE_FILE" | awk '{print $1}') fi + echo "Directory contents are (AFTER): $(ls -la)" + echo "Directory contents of 'dependency-cache/modules-2': $(ls -la dependency-cache/modules-2)" + echo "Directory contents of 'caches/modules-2': $(ls -la caches/modules-2)" echo " Cleaning Up" rm "$CACHE_KEY" diff --git a/bin/restore_gradle_dependency_cache b/bin/restore_gradle_dependency_cache index 1b761811..67330138 100755 --- a/bin/restore_gradle_dependency_cache +++ b/bin/restore_gradle_dependency_cache @@ -5,14 +5,22 @@ GRADLE_DEPENDENCY_CACHE_KEY="${BUILDKITE_PIPELINE_SLUG}_GRADLE_DEPENDENCY_CACHE_ echo "Restoring Gradle dependency cache..." -GRADLE_DEP_CACHE="$GRADLE_HOME/caches/modules-2" +GRADLE_DEP_CACHE="$GRADLE_HOME/dependency-cache" +echo "GRADLE_DEP_CACHE: $GRADLE_DEP_CACHE" DEP_CACHE_BASE_FOLDER=$(dirname "$GRADLE_DEP_CACHE") DEP_CACHE_FOLDER_NAME=$(basename "$GRADLE_DEP_CACHE") # `save_cache` & `restore_cache` scripts only work if they are called from the same directory +echo "DEP_CACHE_BASE_FOLDER: $DEP_CACHE_BASE_FOLDER" pushd "$DEP_CACHE_BASE_FOLDER" +echo "DEP_CACHE_FOLDER_NAME: $DEP_CACHE_FOLDER_NAME" restore_cache "$GRADLE_DEPENDENCY_CACHE_KEY" "$DEP_CACHE_FOLDER_NAME" +mv "$DEP_CACHE_FOLDER_NAME/modules-2/"* caches/modules-2/ +echo "Directory contents of 'dependency-cache/modules-2': $(ls -la dependency-cache/modules-2)" +echo "Directory contents of 'caches/modules-2': $(ls -la caches/modules-2)" +rm -r "$DEP_CACHE_FOLDER_NAME" +echo "Directory contents are (FINAL): $(ls -la)" popd echo "---" diff --git a/bin/save_cache b/bin/save_cache index cf285953..62f13308 100755 --- a/bin/save_cache +++ b/bin/save_cache @@ -53,6 +53,8 @@ if ! aws s3api head-object --bucket "$S3_BUCKET_NAME" --key "$CACHE_KEY" > /dev/ SECONDS=0 echo "No existing cache entry for $CACHE_KEY – storing in cache" + echo "Current directory is: $(pwd)" + echo "Directory contents are (BEFORE): $(ls -la)" UNCOMPRESSED_CACHE_SIZE=$(du -sb "$CACHE_FILE" | awk '{print $1}') echo " Compressing" TAR_CONFIG=${4-} @@ -67,6 +69,7 @@ if ! aws s3api head-object --bucket "$S3_BUCKET_NAME" --key "$CACHE_KEY" > /dev/ tar -czf "$CACHE_KEY" "$CACHE_FILE" fi COMPRESSED_CACHE_SIZE=$(wc -c < "$CACHE_KEY") + echo "Directory contents are (AFTER): $(ls -la)" echo " Uploading" # If the bucket has transfer acceleration enabled, use it! diff --git a/bin/save_gradle_dependency_cache b/bin/save_gradle_dependency_cache index f3cb843e..f8a6626f 100755 --- a/bin/save_gradle_dependency_cache +++ b/bin/save_gradle_dependency_cache @@ -7,6 +7,7 @@ echo "Saving Gradle dependency cache..." GRADLE_DEP_CACHE="$GRADLE_HOME/dependency-cache" +echo "GRADLE_DEP_CACHE: $GRADLE_DEP_CACHE" mkdir -p "$GRADLE_DEP_CACHE" # https://docs.gradle.org/current/userguide/dependency_resolution.html#sub:cache_copy @@ -19,8 +20,10 @@ DEP_CACHE_BASE_FOLDER=$(dirname "$GRADLE_DEP_CACHE") DEP_CACHE_FOLDER_NAME=$(basename "$GRADLE_DEP_CACHE") # `save_cache` & `restore_cache` scripts only work if they are called from the same directory +echo "DEP_CACHE_BASE_FOLDER: $DEP_CACHE_BASE_FOLDER" pushd "$DEP_CACHE_BASE_FOLDER" # For now we are using a single key - we might expand on this later by using dependency catalog version +echo "DEP_CACHE_FOLDER_NAME: $DEP_CACHE_FOLDER_NAME" save_cache "$DEP_CACHE_FOLDER_NAME" "$GRADLE_DEPENDENCY_CACHE_KEY" --force popd