From cb9972a52b87b2da20a0a7b8b77948ced1b08f66 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 | 9 +++++++++ bin/restore_gradle_dependency_cache | 14 +++++++++++++- bin/save_cache | 3 +++ bin/save_gradle_dependency_cache | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bin/restore_cache b/bin/restore_cache index 0d32345..d1df0ab 100755 --- a/bin/restore_cache +++ b/bin/restore_cache @@ -36,12 +36,21 @@ 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': $(ls -la dependency-cache)" + if [ -d "modules-2" ]; then + echo "Directory contents of 'modules-2': $(ls -la modules-2)" + else + echo "Directory 'modules-2' does not exist" + fi echo " Cleaning Up" rm "$CACHE_KEY" diff --git a/bin/restore_gradle_dependency_cache b/bin/restore_gradle_dependency_cache index 1b76181..0473106 100755 --- a/bin/restore_gradle_dependency_cache +++ b/bin/restore_gradle_dependency_cache @@ -5,14 +5,26 @@ 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" +if [ -d "modules-2" ]; then + mv "$DEP_CACHE_FOLDER_NAME/modules-2/"* modules-2/ + else + mv "$DEP_CACHE_FOLDER_NAME/modules-2/" modules-2/ +fi +echo "Directory contents of 'dependency-cache': $(ls -la dependency-cache)" +echo "Directory contents of 'modules-2': $(ls -la 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 cf28595..62f1330 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 f3cb843..f8a6626 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