Browse Source

Add comprehensive debug logging to all cache GitHub Actions

- cache-restore: Added debug steps for input params, HTTP requests, asset parsing, download logic, extraction
- cache-save: Added debug steps for archive creation, upload retries, split logic, cleanup
- cache-setup: Added debug steps for ccache installation, env vars, Bazel/LD cache setup
- cache-stats: Added debug steps for ccache checks, stats parsing, hit rate calculation, folder analysis

All debug messages use ๐Ÿ” DEBUG: prefix for easy log filtering.
TheWildJames 2 months ago
parent
commit
b9c09a9ab0

+ 191 - 108
.github/actions/cache-restore/action.yml

@@ -51,10 +51,23 @@ runs:
         fi
 
         cd "$GITHUB_WORKSPACE"
+        
+        echo "๐Ÿ” DEBUG: Starting cache restore process"
+        echo "๐Ÿ” DEBUG: GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
+        echo "๐Ÿ” DEBUG: inputs.cache_path=${{ inputs.cache_path }}"
+        echo "๐Ÿ” DEBUG: inputs.cache_key=${{ inputs.cache_key }}"
+        echo "๐Ÿ” DEBUG: inputs.restore_keys=${{ inputs.restore_keys }}"
+        echo "๐Ÿ” DEBUG: inputs.cache_bucket=${{ inputs.cache_bucket }}"
+        echo "๐Ÿ” DEBUG: inputs.debug=${{ inputs.debug }}"
 
         TAG_NAME="${{ inputs.cache_bucket }}"
         BASE_URL="https://github.com/${TARGET_REPO}/releases/download/$TAG_NAME"
         ASSETS_URL="https://github.com/${TARGET_REPO}/releases/expanded_assets/$TAG_NAME"
+        
+        echo "๐Ÿ” DEBUG: TAG_NAME=$TAG_NAME"
+        echo "๐Ÿ” DEBUG: BASE_URL=$BASE_URL"
+        echo "๐Ÿ” DEBUG: ASSETS_URL=$ASSETS_URL"
+        echo "๐Ÿ” DEBUG: TARGET_REPO=$TARGET_REPO"
 
         ARIA2_OPTS=(
           "-x16" "-s16" "-k1M" "-j5" "--file-allocation=none"
@@ -67,29 +80,41 @@ runs:
           ARIA2_OPTS+=("--quiet" "--summary-interval=0" "--console-log-level=error")
         fi
 
-        echo "::group:: Fetching Asset List"
-        HTTP_RESPONSE=$(curl -sL -A "Mozilla/5.0" -w "%{http_code}" "$ASSETS_URL" -o assets.html || echo "404")
+echo "๐Ÿ” DEBUG: Fetching asset list from GitHub Releases..."
+echo "๐Ÿ” DEBUG: HTTP request to ASSETS_URL=$ASSETS_URL"
+echo "::group:: Fetching Asset List"
+HTTP_RESPONSE=$(curl -sL -A "Mozilla/5.0" -w "%{http_code}" "$ASSETS_URL" -o assets.html || echo "404")
+echo "๐Ÿ” DEBUG: HTTP_RESPONSE=$HTTP_RESPONSE"
 
-        if [ "$HTTP_RESPONSE" -eq 200 ]; then
-          ALL_ASSETS=$(grep -oP "download/$TAG_NAME/\K[^\"' ]+" assets.html | sort -u || true)
-        else
-          echo "Status $HTTP_RESPONSE: Failed to fetch assets from scraper endpoint."
-          ALL_ASSETS=""
-        fi
-        rm -f assets.html
+if [ "$HTTP_RESPONSE" -eq 200 ]; then
+  ALL_ASSETS=$(grep -oP "download/$TAG_NAME/\K[^\"' ]+" assets.html | sort -u || true)
+  echo "๐Ÿ” DEBUG: Parsed ALL_ASSETS count=$(echo "$ALL_ASSETS" | wc -l)"
+  echo "๐Ÿ” DEBUG: First 10 assets: $(echo "$ALL_ASSETS" | head -n 10 | tr '\n' ' ')"
+else
+  echo "Status $HTTP_RESPONSE: Failed to fetch assets from scraper endpoint."
+  ALL_ASSETS=""
+  echo "๐Ÿ” DEBUG: No assets parsed due to HTTP failure"
+fi
+rm -f assets.html
+echo "๐Ÿ” DEBUG: assets.html removed"
 
-        if [ -z "$ALL_ASSETS" ]; then
-          echo "No assets found in bucket '$TAG_NAME'. Skipping search."
-          echo "cache-hit=false" >> "$GITHUB_OUTPUT"
-          echo "::endgroup::"
-          exit 0
-        fi
+if [ -z "$ALL_ASSETS" ]; then
+  echo "๐Ÿ” DEBUG: ALL_ASSETS is empty, exiting early"
+  echo "No assets found in bucket '$TAG_NAME'. Skipping search."
+  echo "cache-hit=false" >> "$GITHUB_OUTPUT"
+  echo "::endgroup::"
+  exit 0
+fi
 
-        echo "Successfully fetched asset list. Has $(echo "$ALL_ASSETS" | wc -l) assets."
-        echo "::endgroup::"
+echo "Successfully fetched asset list. Has $(echo "$ALL_ASSETS" | wc -l) assets."
+echo "๐Ÿ” DEBUG: Full asset list (first 20 lines):"
+echo "$ALL_ASSETS" | head -n 20
+echo "::endgroup::"
 
-        SEARCH_LIST=$(printf "%s\n%s" "${{ inputs.cache_key }}" "${{ inputs.restore_keys }}" | sed '/^$/d')
-        FOUND=false
+SEARCH_LIST=$(printf "%s\n%s" "${{ inputs.cache_key }}" "${{ inputs.restore_keys }}" | sed '/^$/d')
+echo "๐Ÿ” DEBUG: SEARCH_LIST (keys to search):"
+echo "$SEARCH_LIST"
+echo "๐Ÿ” DEBUG: FOUND=false initialized"
 
         download_asset() {
           local filename="$1"
@@ -97,107 +122,165 @@ runs:
           local max_retries=3
           local attempt=1
 
-          while [ "$attempt" -le "$max_retries" ]; do
-            echo "  Attempt $attempt: Downloading $filename..."
-            rm -f "$filename"
-
-            if command -v gh >/dev/null 2>&1; then
-              if timeout 10m gh release download "$TAG_NAME" --repo "$TARGET_REPO" --pattern "$filename" -D . >/dev/null 2>&1; then
-                [ -s "$filename" ] && return 0
-              fi
-            fi
-
-            if timeout 10m aria2c "${ARIA2_OPTS[@]}" --retry-wait=10 --max-tries=10 -o "$filename" "$url"; then
-              [ -s "$filename" ] && return 0
-              echo "  โš ๏ธ Downloaded file is empty. Retrying..."
-              rm -f "$filename"
-            fi
-
-            echo "  โš ๏ธ Download failed or timed out. Retrying in 5s..."
-            sleep 5
-            attempt=$((attempt + 1))
+echo "๐Ÿ” DEBUG: download_asset() function called with filename=$filename, url=$url"
+echo "๐Ÿ” DEBUG: max_retries=$max_retries, current attempt=$attempt"
+while [ "$attempt" -le "$max_retries" ]; do
+  echo "๐Ÿ” DEBUG: Attempt $attempt: Downloading $filename..."
+  echo "๐Ÿ” DEBUG: Removing old file $filename if exists"
+  rm -f "$filename"
+
+if command -v gh >/dev/null 2>&1; then
+  echo "๐Ÿ” DEBUG: 'gh' command available, attempting download via gh CLI"
+  if timeout 10m gh release download "$TAG_NAME" --repo "$TARGET_REPO" --pattern "$filename" -D . >/dev/null 2>&1; then
+    echo "๐Ÿ” DEBUG: gh CLI download succeeded, checking file size"
+    [ -s "$filename" ] && { echo "๐Ÿ” DEBUG: File $filename is non-empty, returning success"; return 0; }
+    echo "๐Ÿ” DEBUG: File $filename is empty after gh download"
+  else
+    echo "๐Ÿ” DEBUG: gh CLI download failed or timed out"
+  fi
+else
+  echo "๐Ÿ” DEBUG: 'gh' command not available, skipping gh CLI download"
+fi
+
+echo "๐Ÿ” DEBUG: Trying aria2c download with URL=$url"
+echo "๐Ÿ” DEBUG: aria2c options: ${ARIA2_OPTS[*]}"
+if timeout 10m aria2c "${ARIA2_OPTS[@]}" --retry-wait=10 --max-tries=10 -o "$filename" "$url"; then
+  echo "๐Ÿ” DEBUG: aria2c download succeeded, checking file size"
+  [ -s "$filename" ] && { echo "๐Ÿ” DEBUG: File $filename is non-empty, returning success"; return 0; }
+  echo "  โš ๏ธ Downloaded file is empty. Retrying..."
+  echo "๐Ÿ” DEBUG: File $filename is empty after aria2c download"
+  rm -f "$filename"
+else
+  echo "๐Ÿ” DEBUG: aria2c download failed or timed out"
+fi
+
+echo "  โš ๏ธ Download failed or timed out. Retrying in 5s..."
+echo "๐Ÿ” DEBUG: Sleeping 5 seconds before retry"
+sleep 5
+attempt=$((attempt + 1))
+echo "๐Ÿ” DEBUG: Incremented attempt to $attempt"
           done
 
           return 1
         }
 
-        while read -r KEY; do
-          [ -z "$KEY" ] && continue
-          echo "::group:: Searching Prefix: $KEY"
+while read -r KEY; do
+  echo "๐Ÿ” DEBUG: Reading KEY from SEARCH_LIST: KEY=$KEY"
+  [ -z "$KEY" ] && { echo "๐Ÿ” DEBUG: KEY is empty, skipping"; continue; }
+  echo "::group:: Searching Prefix: $KEY"
+  echo "๐Ÿ” DEBUG: Searching for assets matching prefix: cache-$KEY"
+
+MATCH=$(echo "$ALL_ASSETS" | grep -E "^cache-$KEY.*\.(tzst|tar)(\.part[a-z]{2})?$" | sort -r | head -n 1 || true)
+echo "๐Ÿ” DEBUG: MATCH result for KEY=$KEY: MATCH=$MATCH"
 
-          MATCH=$(echo "$ALL_ASSETS" | grep -E "^cache-$KEY.*\.(tzst|tar)(\.part[a-z]{2})?$" | sort -r | head -n 1 || true)
+if [ -z "$MATCH" ]; then
+  echo "๐Ÿ” DEBUG: No match found for KEY=$KEY, continuing to next key"
+  echo "Not found."
+  echo "::endgroup::"
+  continue
+fi
 
-          if [ -z "$MATCH" ]; then
-            echo "Not found."
-            echo "::endgroup::"
-            continue
-          fi
+BASE_FILENAME=$(echo "$MATCH" | sed -E 's/\.(tzst|tar)(\.part[a-z]{2})?$//')
+EXT=$(echo "$MATCH" | grep -oE '\.(tzst|tar)' | head -n 1)
+IS_SPLIT=false
+COMPRESSED=false
+echo "๐Ÿ” DEBUG: Parsed MATCH: BASE_FILENAME=$BASE_FILENAME, EXT=$EXT"
 
-          BASE_FILENAME=$(echo "$MATCH" | sed -E 's/\.(tzst|tar)(\.part[a-z]{2})?$//')
-          EXT=$(echo "$MATCH" | grep -oE '\.(tzst|tar)' | head -n 1)
-          IS_SPLIT=false
-          COMPRESSED=false
+case "$MATCH" in
+  *.part*) IS_SPLIT=true ;;
+esac
+echo "๐Ÿ” DEBUG: IS_SPLIT=$IS_SPLIT (based on .part* suffix)"
 
-          case "$MATCH" in
-            *.part*) IS_SPLIT=true ;;
-          esac
-          [ "$EXT" = ".tzst" ] && COMPRESSED=true
+[ "$EXT" = ".tzst" ] && COMPRESSED=true
+echo "๐Ÿ” DEBUG: COMPRESSED=$COMPRESSED (EXT=$EXT)"
 
           FOUND=true
           echo "โœ… Hit! Restoring $BASE_FILENAME$EXT"
           echo "::endgroup::"
 
-          echo "::group:: Downloading Cache"
-          if [ "$IS_SPLIT" = "true" ]; then
-            for part in {a..z}{a..z}; do
-              PART_NAME="$BASE_FILENAME$EXT.part$part"
-              if echo "$ALL_ASSETS" | grep -q "^$PART_NAME$"; then
-                if ! download_asset "$PART_NAME" "$BASE_URL/$PART_NAME"; then
-                  echo "::error::Failed to download $PART_NAME after multiple retries."
-                  exit 1
-                fi
-              else
-                break
-              fi
-            done
-          else
-            if ! download_asset "$BASE_FILENAME$EXT" "$BASE_URL/$BASE_FILENAME$EXT"; then
-              echo "::error::Failed to download $BASE_FILENAME$EXT after multiple retries."
-              exit 1
-            fi
-          fi
-          echo "::endgroup::"
+echo "::group:: Downloading Cache"
+echo "๐Ÿ” DEBUG: Download mode: IS_SPLIT=$IS_SPLIT, COMPRESSED=$COMPRESSED"
+if [ "$IS_SPLIT" = "true" ]; then
+  echo "๐Ÿ” DEBUG: Downloading split archive parts"
+  for part in {a..z}{a..z}; do
+    PART_NAME="$BASE_FILENAME$EXT.part$part"
+    echo "๐Ÿ” DEBUG: Checking if PART_NAME=$PART_NAME exists in ALL_ASSETS"
+    if echo "$ALL_ASSETS" | grep -q "^$PART_NAME$"; then
+      echo "๐Ÿ” DEBUG: PART_NAME=$PART_NAME found, downloading..."
+      if ! download_asset "$PART_NAME" "$BASE_URL/$PART_NAME"; then
+        echo "::error::Failed to download $PART_NAME after multiple retries."
+        echo "๐Ÿ” DEBUG: CRITICAL: Failed to download $PART_NAME"
+        exit 1
+      fi
+      echo "๐Ÿ” DEBUG: Successfully downloaded $PART_NAME"
+    else
+      echo "๐Ÿ” DEBUG: PART_NAME=$PART_NAME not found, breaking loop"
+      break
+    fi
+  done
+else
+  echo "๐Ÿ” DEBUG: Downloading single file: $BASE_FILENAME$EXT"
+  if ! download_asset "$BASE_FILENAME$EXT" "$BASE_URL/$BASE_FILENAME$EXT"; then
+    echo "::error::Failed to download $BASE_FILENAME$EXT after multiple retries."
+    echo "๐Ÿ” DEBUG: CRITICAL: Failed to download $BASE_FILENAME$EXT"
+    exit 1
+  fi
+  echo "๐Ÿ” DEBUG: Successfully downloaded $BASE_FILENAME$EXT"
+fi
+echo "::endgroup::"
 
-          echo "::group:: Extracting Cache"
-          mkdir -p "${{ inputs.cache_path }}"
-          FINAL_ARCHIVE="$BASE_FILENAME$EXT"
-          EXTRACT_DIR="$(dirname "${{ inputs.cache_path }}")"
-
-          if [ "$IS_SPLIT" = "true" ]; then
-            PARTS=$(ls "$FINAL_ARCHIVE.part"* | sort)
-            if [ "$COMPRESSED" = "true" ]; then
-              cat $PARTS | tar -I 'zstd -d -T0' -xf - -C "$EXTRACT_DIR"
-            else
-              cat $PARTS | tar -xf - -C "$EXTRACT_DIR"
-            fi
-            rm -f $PARTS
-          else
-            if [ "$COMPRESSED" = "true" ]; then
-              tar -I 'zstd -d -T0' -xf "$FINAL_ARCHIVE" -C "$EXTRACT_DIR"
-            else
-              tar -xf "$FINAL_ARCHIVE" -C "$EXTRACT_DIR"
-            fi
-            rm -f "$FINAL_ARCHIVE"
-          fi
-
-          echo "โœ… Restore complete."
-          echo "::endgroup::"
-          break
-        done <<< "$SEARCH_LIST"
-
-        if [ "$FOUND" = "false" ]; then
-          echo "โš ๏ธ No cache matches found. Proceeding with fresh run."
-          echo "cache-hit=false" >> "$GITHUB_OUTPUT"
-        else
-          echo "cache-hit=true" >> "$GITHUB_OUTPUT"
-        fi
+echo "::group:: Extracting Cache"
+echo "๐Ÿ” DEBUG: Starting extraction process"
+echo "๐Ÿ” DEBUG: cache_path=${{ inputs.cache_path }}"
+mkdir -p "${{ inputs.cache_path }}"
+echo "๐Ÿ” DEBUG: Created/verified cache_path directory"
+FINAL_ARCHIVE="$BASE_FILENAME$EXT"
+EXTRACT_DIR="$(dirname "${{ inputs.cache_path }}")"
+echo "๐Ÿ” DEBUG: FINAL_ARCHIVE=$FINAL_ARCHIVE"
+echo "๐Ÿ” DEBUG: EXTRACT_DIR=$EXTRACT_DIR"
+echo "๐Ÿ” DEBUG: IS_SPLIT=$IS_SPLIT, COMPRESSED=$COMPRESSED"
+
+if [ "$IS_SPLIT" = "true" ]; then
+  echo "๐Ÿ” DEBUG: Extracting split archive"
+  PARTS=$(ls "$FINAL_ARCHIVE.part"* | sort)
+  echo "๐Ÿ” DEBUG: Found parts: $PARTS"
+  echo "๐Ÿ” DEBUG: Parts list size: $(echo "$PARTS" | wc -w)"
+  if [ "$COMPRESSED" = "true" ]; then
+    echo "๐Ÿ” DEBUG: Using zstd decompression"
+    cat $PARTS | tar -I 'zstd -d -T0' -xf - -C "$EXTRACT_DIR"
+  else
+    echo "๐Ÿ” DEBUG: Using plain tar extraction"
+    cat $PARTS | tar -xf - -C "$EXTRACT_DIR"
+  fi
+  echo "๐Ÿ” DEBUG: Removing part files"
+  rm -f $PARTS
+else
+  echo "๐Ÿ” DEBUG: Extracting single archive"
+  if [ "$COMPRESSED" = "true" ]; then
+    echo "๐Ÿ” DEBUG: Using zstd decompression for single file"
+    tar -I 'zstd -d -T0' -xf "$FINAL_ARCHIVE" -C "$EXTRACT_DIR"
+  else
+    echo "๐Ÿ” DEBUG: Using plain tar extraction for single file"
+    tar -xf "$FINAL_ARCHIVE" -C "$EXTRACT_DIR"
+  fi
+  echo "๐Ÿ” DEBUG: Removing archive file"
+  rm -f "$FINAL_ARCHIVE"
+fi
+
+echo "๐Ÿ” DEBUG: Verifying extracted contents"
+ls -la "${{ inputs.cache_path }}" || true
+echo "โœ… Restore complete."
+echo "::endgroup::"
+break
+done <<< "$SEARCH_LIST"
+
+echo "๐Ÿ” DEBUG: Final check - FOUND=$FOUND"
+if [ "$FOUND" = "false" ]; then
+  echo "โš ๏ธ No cache matches found. Proceeding with fresh run."
+  echo "๐Ÿ” DEBUG: Setting cache-hit=false"
+  echo "cache-hit=false" >> "$GITHUB_OUTPUT"
+else
+  echo "๐Ÿ” DEBUG: Cache was found and restored"
+  echo "cache-hit=true" >> "$GITHUB_OUTPUT"
+fi
+echo "๐Ÿ” DEBUG: Cache restore process finished. cache-hit=$(cat $GITHUB_OUTPUT | grep cache-hit | cut -d= -f2)"

+ 232 - 151
.github/actions/cache-save/action.yml

@@ -41,52 +41,84 @@ runs:
         GH_TOKEN: ${{ inputs.github_token }}
         TARGET_REPO: "${{ github.repository }}"
       run: |
-        set -euo pipefail
+set -euo pipefail
 
-        # Archive, Split, and Upload Cache
-        if [ "${{ inputs.debug }}" = "true" ]; then set -x; fi
-        
-        if [ "${{ inputs.working_dir }}" != "" ]; then 
-          cd "${{ inputs.working_dir }}"
-        fi
-        git config user.name "github-actions[bot]"
-        git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
-        
-        TAG_NAME="${{ inputs.cache_bucket }}"
-        BASE_FILENAME="cache-${{ inputs.cache_key }}"
-        
-        if [ "${{ inputs.compression_level }}" -eq 0 ]; then
-          FILENAME="$BASE_FILENAME.tar"
-        else
-          FILENAME="$BASE_FILENAME.tzst"
-        fi
-        
-        echo "::group:: Checking Release State"
-        
-        git fetch --tags --force
-        
-        if ! git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
-          echo "Tag '$TAG_NAME' not found. Creating backdated release..."
-          GIT_COMMITTER_DATE="2015-01-01T12:00:00" git tag -a "$TAG_NAME" -m "General Cache Storage"
-          if git push origin "$TAG_NAME" --force; then
-            gh release create "$TAG_NAME" --title "General Cache" --notes "Automated storage for build assets" --repo "$TARGET_REPO" || true
-          else
-            echo "Push failed, tag might have been created by a parallel job. Continuing..."
-          fi
-        else
-          echo "Release '$TAG_NAME' already exists. Ready for upload."
-        fi
-        echo "::endgroup::"
-        
-        echo "::group:: Archiving Path"
-        echo "Target: ${{ inputs.cache_path }}"
+# Archive, Split, and Upload Cache
+echo "๐Ÿ” DEBUG: cache-save action started"
+echo "๐Ÿ” DEBUG: inputs.cache_path=${{ inputs.cache_path }}"
+echo "๐Ÿ” DEBUG: inputs.cache_key=${{ inputs.cache_key }}"
+echo "๐Ÿ” DEBUG: inputs.cache_bucket=${{ inputs.cache_bucket }}"
+echo "๐Ÿ” DEBUG: inputs.compression_level=${{ inputs.compression_level }}"
+echo "๐Ÿ” DEBUG: inputs.working_dir=${{ inputs.working_dir }}"
+echo "๐Ÿ” DEBUG: inputs.debug=${{ inputs.debug }}"
+echo "๐Ÿ” DEBUG: GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
+echo "๐Ÿ” DEBUG: TARGET_REPO=$TARGET_REPO"
+
+if [ "${{ inputs.working_dir }}" != "" ]; then
+  echo "๐Ÿ” DEBUG: Changing to working_dir: ${{ inputs.working_dir }}"
+  cd "${{ inputs.working_dir }}"
+  echo "๐Ÿ” DEBUG: Current directory after change: $(pwd)"
+else
+  echo "๐Ÿ” DEBUG: No working_dir specified, using GITHUB_WORKSPACE"
+fi
+git config user.name "github-actions[bot]"
+git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+echo "๐Ÿ” DEBUG: Git config set for github-actions[bot]"
+
+TAG_NAME="${{ inputs.cache_bucket }}"
+BASE_FILENAME="cache-${{ inputs.cache_key }}"
+
+if [ "${{ inputs.compression_level }}" -eq 0 ]; then
+  FILENAME="$BASE_FILENAME.tar"
+else
+  FILENAME="$BASE_FILENAME.tzst"
+fi
+
+echo "๐Ÿ” DEBUG: TAG_NAME=$TAG_NAME"
+echo "๐Ÿ” DEBUG: BASE_FILENAME=$BASE_FILENAME"
+echo "๐Ÿ” DEBUG: FILENAME=$FILENAME"
+echo "๐Ÿ” DEBUG: compression_level=${{ inputs.compression_level }}"
+
+echo "::group:: Checking Release State"
+echo "๐Ÿ” DEBUG: Checking if git tag '$TAG_NAME' exists"
+
+git fetch --tags --force
+echo "๐Ÿ” DEBUG: Git tags fetched successfully"
+
+if ! git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
+  echo "๐Ÿ” DEBUG: Tag '$TAG_NAME' not found, creating new release"
+  echo "Tag '$TAG_NAME' not found. Creating backdated release..."
+  GIT_COMMITTER_DATE="2015-01-01T12:00:00" git tag -a "$TAG_NAME" -m "General Cache Storage"
+  echo "๐Ÿ” DEBUG: Git tag created, attempting push"
+  if git push origin "$TAG_NAME" --force; then
+    echo "๐Ÿ” DEBUG: Push successful, creating GitHub release"
+    gh release create "$TAG_NAME" --title "General Cache" --notes "Automated storage for build assets" --repo "$TARGET_REPO" || true
+  else
+    echo "๐Ÿ” DEBUG: Push failed (may be parallel job conflict)"
+    echo "Push failed, tag might have been created by a parallel job. Continuing..."
+  fi
+else
+  echo "๐Ÿ” DEBUG: Tag '$TAG_NAME' already exists"
+  echo "Release '$TAG_NAME' already exists. Ready for upload."
+fi
+echo "::endgroup::"
+echo "๐Ÿ” DEBUG: Release state check complete"
         
-        if [ ! -d "${{ inputs.cache_path }}" ] && [ ! -f "${{ inputs.cache_path }}" ]; then
-          echo "โš ๏ธ Target path not found. Skipping cache save."
-          echo "::endgroup::"
-        else
-          DIR_NAME=$(dirname "${{ inputs.cache_path }}")
-          BASE_NAME=$(basename "${{ inputs.cache_path }}")
+echo "::group:: Archiving Path"
+echo "๐Ÿ” DEBUG: Archiving process started"
+echo "Target: ${{ inputs.cache_path }}"
+echo "๐Ÿ” DEBUG: Checking if target path exists"
+
+if [ ! -d "${{ inputs.cache_path }}" ] && [ ! -f "${{ inputs.cache_path }}" ]; then
+  echo "๐Ÿ” DEBUG: Target path does not exist"
+  echo "โš ๏ธ Target path not found. Skipping cache save."
+  echo "::endgroup::"
+else
+  echo "๐Ÿ” DEBUG: Target path exists, proceeding with archive"
+  DIR_NAME=$(dirname "${{ inputs.cache_path }}")
+  BASE_NAME=$(basename "${{ inputs.cache_path }}")
+  echo "๐Ÿ” DEBUG: DIR_NAME=$DIR_NAME"
+  echo "๐Ÿ” DEBUG: BASE_NAME=$BASE_NAME"
           
           if [ "${{ inputs.debug }}" = "true" ]; then
             if [ "${{ inputs.compression_level }}" -eq 0 ]; then
@@ -106,114 +138,163 @@ runs:
           echo "Archive created: $FILENAME ($FILE_SIZE bytes)"
           echo "::endgroup::"
           
-          echo "::group:: Uploading Assets"
-          MAX_SIZE=2000000000 # ~1.86GB
-          
-          upload_with_retry() {
-            local file=$1
-            local max_attempts=3
-            local timeout_duration="10m"
-
-            for ((i=1; i<=max_attempts; i++)); do
-              echo "  Attempt $i for $file..."
-              
-              if [ "${{ inputs.debug }}" = "true" ]; then
-                if timeout "$timeout_duration" gh release upload "$TAG_NAME" "$file" --clobber --repo "$TARGET_REPO"; then
-                  echo "  Successfully uploaded $file"
-                  return 0
-                fi
-              else
-                if timeout "$timeout_duration" gh release upload "$TAG_NAME" "$file" --clobber --repo "$TARGET_REPO" > /dev/null 2>&1; then
-                  echo "  Successfully uploaded $file"
-                  return 0
-                fi
-              fi
-              
-              echo "  โš  Attempt $i failed or timed out after $timeout_duration. Retrying..."
-              if [ "$i" -lt "$max_attempts" ]; then
-                sleep 5
-              fi
-            done
-            return 1
-          }
+  echo "::group:: Uploading Assets"
+  echo "๐Ÿ” DEBUG: Upload process started"
+  MAX_SIZE=2000000000 # ~1.86GB
+  echo "๐Ÿ” DEBUG: MAX_SIZE=$MAX_SIZE bytes ($(( MAX_SIZE / 1024 / 1024 )) MB)"
+  
+  upload_with_retry() {
+    local file=$1
+    local max_attempts=3
+    local timeout_duration="10m"
+    echo "๐Ÿ” DEBUG: upload_with_retry() called for file=$file"
+  
+    for ((i=1; i<=max_attempts; i++)); do
+      echo "  Attempt $i for $file..."
+      echo "๐Ÿ” DEBUG: Upload attempt $i for $file"
+      
+      if [ "${{ inputs.debug }}" = "true" ]; then
+        echo "๐Ÿ” DEBUG: Running gh release upload in debug mode"
+        if timeout "$timeout_duration" gh release upload "$TAG_NAME" "$file" --clobber --repo "$TARGET_REPO"; then
+          echo "  Successfully uploaded $file"
+          echo "๐Ÿ” DEBUG: Upload successful for $file"
+          return 0
+        fi
+      else
+        echo "๐Ÿ” DEBUG: Running gh release upload in silent mode"
+        if timeout "$timeout_duration" gh release upload "$TAG_NAME" "$file" --clobber --repo "$TARGET_REPO" > /dev/null 2>&1; then
+          echo "  Successfully uploaded $file"
+          echo "๐Ÿ” DEBUG: Upload successful for $file"
+          return 0
+        fi
+      fi
+      
+      echo "  โš  Attempt $i failed or timed out after $timeout_duration. Retrying..."
+      echo "๐Ÿ” DEBUG: Upload attempt $i failed, timeout=$timeout_duration"
+      if [ "$i" -lt "$max_attempts" ]; then
+        echo "๐Ÿ” DEBUG: Sleeping 5 seconds before retry"
+        sleep 5
+      fi
+    done
+    echo "๐Ÿ” DEBUG: All $max_attempts attempts exhausted for $file"
+    return 1
+  }
           
-          # Fetch existing assets to clean up stale entries
-          ASSETS_URL="https://github.com/${TARGET_REPO}/releases/expanded_assets/$TAG_NAME"
-          HTTP_RESPONSE=$(curl -sL -A "Mozilla/5.0" -w "%{http_code}" "$ASSETS_URL" -o assets.html || echo "404")
-          if [ "$HTTP_RESPONSE" -eq 200 ]; then
-            ALL_ASSETS=$(grep -oP "download/$TAG_NAME/\K[^\"' ]+" assets.html | sort || echo "")
-          else
-            ALL_ASSETS=""
-          fi
-          rm -f assets.html
+  # Fetch existing assets to clean up stale entries
+  echo "๐Ÿ” DEBUG: Fetching existing assets for cleanup"
+  ASSETS_URL="https://github.com/${TARGET_REPO}/releases/expanded_assets/$TAG_NAME"
+  echo "๐Ÿ” DEBUG: ASSETS_URL=$ASSETS_URL"
+  HTTP_RESPONSE=$(curl -sL -A "Mozilla/5.0" -w "%{http_code}" "$ASSETS_URL" -o assets.html || echo "404")
+  echo "๐Ÿ” DEBUG: HTTP_RESPONSE=$HTTP_RESPONSE"
+  if [ "$HTTP_RESPONSE" -eq 200 ]; then
+    ALL_ASSETS=$(grep -oP "download/$TAG_NAME/\K[^\"' ]+" assets.html | sort || echo "")
+    echo "๐Ÿ” DEBUG: Parsed ALL_ASSETS, count=$(echo "$ALL_ASSETS" | wc -l)"
+  else
+    ALL_ASSETS=""
+    echo "๐Ÿ” DEBUG: Failed to fetch assets, ALL_ASSETS is empty"
+  fi
+  rm -f assets.html
+  echo "๐Ÿ” DEBUG: assets.html removed"
           
-          chunk_size="1500M"
-          split_required=false
-
-          if [ "$FILE_SIZE" -gt "$MAX_SIZE" ]; then
-            split_required=true
-          fi
-
-          if [ "$split_required" = "true" ]; then
-            echo "โš  Splitting into ${chunk_size} chunks..."
-            split -b "$chunk_size" -a 2 "$FILENAME" "${FILENAME}.part"
-            
-            NEW_PARTS=(${FILENAME}.part*)
-            NEW_PARTS_COUNT=${#NEW_PARTS[@]}
-            
-            # Remove old single-file asset if switching to split parts
-            if echo "$ALL_ASSETS" | grep -xF "${FILENAME}" >/dev/null 2>&1; then
-              echo "Removing old single asset to make way for split parts: ${FILENAME}"
-              gh release delete-asset "$TAG_NAME" "${FILENAME}" --repo "$TARGET_REPO" -y || true
-            fi
+  chunk_size="1500M"
+  split_required=false
+  echo "๐Ÿ” DEBUG: Evaluating split requirement"
+  echo "๐Ÿ” DEBUG: FILE_SIZE=$FILE_SIZE, MAX_SIZE=$MAX_SIZE"
+  
+  if [ "$FILE_SIZE" -gt "$MAX_SIZE" ]; then
+    split_required=true
+    echo "๐Ÿ” DEBUG: Split required (FILE_SIZE > MAX_SIZE)"
+  else
+    echo "๐Ÿ” DEBUG: No split required (FILE_SIZE <= MAX_SIZE)"
+  fi
+  
+  if [ "$split_required" = "true" ]; then
+    echo "โš  Splitting into ${chunk_size} chunks..."
+    echo "๐Ÿ” DEBUG: Executing split command with chunk_size=1500M"
+    split -b "$chunk_size" -a 2 "$FILENAME" "${FILENAME}.part"
+    
+    NEW_PARTS=(${FILENAME}.part*)
+    NEW_PARTS_COUNT=${#NEW_PARTS[@]}
+    echo "๐Ÿ” DEBUG: Split complete, NEW_PARTS_COUNT=$NEW_PARTS_COUNT"
             
-            # Clean up excess trailing parts from previous builds
-            OLD_PARTS=$(echo "$ALL_ASSETS" | grep -F "${FILENAME}.part" || echo "")
-            if [ -n "$OLD_PARTS" ]; then
-              OLD_PARTS_COUNT=$(echo "$OLD_PARTS" | wc -l)
-              if [ "$OLD_PARTS_COUNT" -gt "$NEW_PARTS_COUNT" ]; then
-                echo "Old build had $OLD_PARTS_COUNT parts, new has $NEW_PARTS_COUNT. Cleaning up excess parts..."
-                EXT_PARTS=$(echo "$OLD_PARTS" | awk -v skip="$NEW_PARTS_COUNT" 'NR>skip')
-                for asset in $EXT_PARTS; do
-                  echo "Removing leftover trailing part: $asset"
-                  gh release delete-asset "$TAG_NAME" "$asset" --repo "$TARGET_REPO" -y || true
-                done
-              fi
-            fi
-            
-            for part in "${FILENAME}".part*; do
-              echo "Uploading $part..."
-              if ! upload_with_retry "$part"; then
-                echo "::error::Failed to upload part $part after multiple attempts."
-                exit 1
-              fi
-              rm -f "$part"
-            done
-            rm -rf "$FILENAME"
-          else
-            # Remove old split parts if new build fits in a single file
-            OLD_PARTS=$(echo "$ALL_ASSETS" | grep -F "${FILENAME}.part" || echo "")
-            if [ -n "$OLD_PARTS" ]; then
-              echo "New build shrunk to single file. Cleaning up old split parts for ${FILENAME}..."
-              while read -r asset; do
-                [ -z "$asset" ] && continue
-                echo "Removing ghost split part: $asset"
-                gh release delete-asset "$TAG_NAME" "$asset" --repo "$TARGET_REPO" -y || true
-              done <<< "$OLD_PARTS"
-            fi
-            
-            echo "Uploading $FILENAME..."
-            if ! upload_with_retry "$FILENAME"; then
-              echo "::error::Failed to upload $FILENAME after multiple attempts."
-              exit 1
-            fi
-            rm -f "$FILENAME"
-          fi
-          # Cleanup any leftover archive artifacts (single-file or split parts)
-          if [ "${{ inputs.debug }}" = "true" ]; then
-            echo "Cleaning archive artifacts: ${BASE_FILENAME}*"
-          fi
-          rm -f "${BASE_FILENAME}"* || true
-
-          echo "::endgroup::"
+  # Remove old single-file asset if switching to split parts
+  if echo "$ALL_ASSETS" | grep -xF "${FILENAME}" >/dev/null 2>&1; then
+    echo "๐Ÿ” DEBUG: Found old single-file asset, removing it"
+    echo "Removing old single asset to make way for split parts: ${FILENAME}"
+    gh release delete-asset "$TAG_NAME" "${FILENAME}" --repo "$TARGET_REPO" -y || true
+  else
+    echo "๐Ÿ” DEBUG: No old single-file asset to remove"
+  fi
+  
+  # Clean up excess trailing parts from previous builds
+  OLD_PARTS=$(echo "$ALL_ASSETS" | grep -F "${FILENAME}.part" || echo "")
+  echo "๐Ÿ” DEBUG: OLD_PARTS count=$(echo "$OLD_PARTS" | grep -c . || echo 0)"
+  if [ -n "$OLD_PARTS" ]; then
+    OLD_PARTS_COUNT=$(echo "$OLD_PARTS" | wc -l)
+    echo "๐Ÿ” DEBUG: OLD_PARTS_COUNT=$OLD_PARTS_COUNT, NEW_PARTS_COUNT=$NEW_PARTS_COUNT"
+    if [ "$OLD_PARTS_COUNT" -gt "$NEW_PARTS_COUNT" ]; then
+      echo "Old build had $OLD_PARTS_COUNT parts, new has $NEW_PARTS_COUNT. Cleaning up excess parts..."
+      EXT_PARTS=$(echo "$OLD_PARTS" | awk -v skip="$NEW_PARTS_COUNT" 'NR>skip')
+      for asset in $EXT_PARTS; do
+        echo "๐Ÿ” DEBUG: Removing old part: $asset"
+        echo "Removing leftover trailing part: $asset"
+        gh release delete-asset "$TAG_NAME" "$asset" --repo "$TARGET_REPO" -y || true
+      done
+    else
+      echo "๐Ÿ” DEBUG: No excess parts to clean up"
+    fi
+  fi
+  
+  for part in "${FILENAME}".part*; do
+    echo "๐Ÿ” DEBUG: Uploading part: $part"
+    echo "Uploading $part..."
+    if ! upload_with_retry "$part"; then
+      echo "::error::Failed to upload part $part after multiple attempts."
+      echo "๐Ÿ” DEBUG: CRITICAL - Upload failed for $part"
+      exit 1
+    fi
+    echo "๐Ÿ” DEBUG: Successfully uploaded $part, removing local copy"
+    rm -f "$part"
+  done
+  echo "๐Ÿ” DEBUG: All parts uploaded, removing original archive"
+  rm -rf "$FILENAME"
+  else
+    # Remove old split parts if new build fits in a single file
+    echo "๐Ÿ” DEBUG: Checking for old split parts to clean up"
+    OLD_PARTS=$(echo "$ALL_ASSETS" | grep -F "${FILENAME}.part" || echo "")
+    if [ -n "$OLD_PARTS" ]; then
+      echo "New build shrunk to single file. Cleaning up old split parts for ${FILENAME}..."
+      echo "๐Ÿ” DEBUG: Found old split parts, removing them"
+      while read -r asset; do
+        [ -z "$asset" ] && continue
+        echo "๐Ÿ” DEBUG: Removing ghost split part: $asset"
+        echo "Removing ghost split part: $asset"
+        gh release delete-asset "$TAG_NAME" "$asset" --repo "$TARGET_REPO" -y || true
+      done <<< "$OLD_PARTS"
+    else
+      echo "๐Ÿ” DEBUG: No old split parts to clean up"
+    fi
+    
+    echo "๐Ÿ” DEBUG: Uploading single file: $FILENAME"
+    echo "Uploading $FILENAME..."
+    if ! upload_with_retry "$FILENAME"; then
+      echo "::error::Failed to upload $FILENAME after multiple attempts."
+      echo "๐Ÿ” DEBUG: CRITICAL - Upload failed for $FILENAME"
+      exit 1
+    fi
+    echo "๐Ÿ” DEBUG: Successfully uploaded $FILENAME, removing local copy"
+    rm -f "$FILENAME"
+  fi
+  # Cleanup any leftover archive artifacts (single-file or split parts)
+  echo "๐Ÿ” DEBUG: Final cleanup phase"
+  if [ "${{ inputs.debug }}" = "true" ]; then
+    echo "Cleaning archive artifacts: ${BASE_FILENAME}*"
+    echo "๐Ÿ” DEBUG: Listing files matching ${BASE_FILENAME}*"
+    ls -la "${BASE_FILENAME}"* 2>/dev/null || true
+  fi
+  rm -f "${BASE_FILENAME}"* || true
+  echo "๐Ÿ” DEBUG: Cleanup complete"
+  
+  echo "::endgroup::"
+  echo "๐Ÿ” DEBUG: cache-save action finished successfully"
         fi

+ 156 - 90
.github/actions/cache-setup/action.yml

@@ -25,76 +25,119 @@ runs:
         inputs.version == 'android13-5.15'
       working-directory: ${{ github.workspace }}
       run: |
-        set -euo pipefail
-        # Install ccache from shared artifact (downloaded once by prepare-ccache job)
-        echo "Installing ccache..."
-        if [ -s "${{ github.workspace }}/ccache-dl/ccache" ]; then
-          sudo cp -f "${{ github.workspace }}/ccache-dl/ccache" /usr/bin/ccache || { echo "โŒ Failed to install ccache"; exit 1; }
-          sudo chmod +x /usr/bin/ccache
-          rm -rf "${{ github.workspace }}/ccache-dl"
-          echo "โœ… installed custom ccache from shared artifact"
-        else
-          # Fallback: download directly (prepare-ccache may have failed)
-          echo "โš ๏ธ shared ccache artifact unavailable; downloading directly..."
-          curl -LfsS --retry 5 --retry-delay 5 --retry-all-errors --connect-timeout 30 --tcp-fastopen -H "User-Agent: Mozilla/5.0" "https://github.com/WildKernels/kernel_patches/raw/refs/heads/main/ccache/ccache-x86-64" -o ccache || { echo "โŒ Failed to download ccache"; exit 1; }
-          sudo cp -f ./ccache /usr/bin/ccache || { echo "โŒ Failed to install ccache"; exit 1; }
-          sudo chmod +x /usr/bin/ccache
-          rm -f ./ccache
-        fi
-        
-        # Verify ccache
-        if ! /usr/bin/ccache --version > /dev/null 2>&1; then
-          echo "โŒ ccache installation failed or binary is corrupted"
-          exit 1
-        fi
-        echo "โœ… ccache binary verified: $(/usr/bin/ccache --version | head -1)"
-        
-        # Setup cache directories
-        export CCACHE_DIR="/home/runner/.ccache"
-        echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
-        mkdir -p "$CCACHE_DIR"
+set -euo pipefail
+echo "๐Ÿ” DEBUG: cache-setup action started"
+echo "๐Ÿ” DEBUG: inputs.version=${{ inputs.version }}"
+echo "๐Ÿ” DEBUG: inputs.kernel_version=${{ inputs.kernel_version }}"
+echo "๐Ÿ” DEBUG: inputs.android_version=${{ inputs.android_version }}"
+echo "๐Ÿ” DEBUG: inputs.sublevel=${{ inputs.sublevel }}"
+echo "๐Ÿ” DEBUG: github.workspace=${{ github.workspace }}"
+
+# Install ccache from shared artifact (downloaded once by prepare-ccache job)
+echo "๐Ÿ” DEBUG: Starting ccache installation"
+echo "Installing ccache..."
+echo "๐Ÿ” DEBUG: Checking for shared ccache artifact at ${{ github.workspace }}/ccache-dl/ccache"
+if [ -s "${{ github.workspace }}/ccache-dl/ccache" ]; then
+  echo "๐Ÿ” DEBUG: Shared ccache artifact found, installing from artifact"
+  sudo cp -f "${{ github.workspace }}/ccache-dl/ccache" /usr/bin/ccache || { echo "โŒ Failed to install ccache"; exit 1; }
+  sudo chmod +x /usr/bin/ccache
+  rm -rf "${{ github.workspace }}/ccache-dl"
+  echo "โœ… installed custom ccache from shared artifact"
+  echo "๐Ÿ” DEBUG: Installed ccache from shared artifact"
+else
+  # Fallback: download directly (prepare-ccache may have failed)
+  echo "๐Ÿ” DEBUG: Shared ccache artifact NOT found, downloading directly"
+  echo "โš ๏ธ shared ccache artifact unavailable; downloading directly..."
+  echo "๐Ÿ” DEBUG: Downloading ccache from https://github.com/WildKernels/kernel_patches/raw/refs/heads/main/ccache/ccache-x86-64"
+  curl -LfsS --retry 5 --retry-delay 5 --retry-all-errors --connect-timeout 30 --tcp-fastopen -H "User-Agent: Mozilla/5.0" "https://github.com/WildKernels/kernel_patches/raw/refs/heads/main/ccache/ccache-x86-64" -o ccache || { echo "โŒ Failed to download ccache"; exit 1; }
+  echo "๐Ÿ” DEBUG: ccache downloaded successfully"
+  sudo cp -f ./ccache /usr/bin/ccache || { echo "โŒ Failed to install ccache"; exit 1; }
+  sudo chmod +x /usr/bin/ccache
+  rm -f ./ccache
+  echo "๐Ÿ” DEBUG: Installed ccache from download"
+fi
+
+# Verify ccache
+echo "๐Ÿ” DEBUG: Verifying ccache installation"
+if ! /usr/bin/ccache --version > /dev/null 2>&1; then
+  echo "๐Ÿ” DEBUG: ccache version check FAILED"
+  echo "โŒ ccache installation failed or binary is corrupted"
+  exit 1
+fi
+echo "๐Ÿ” DEBUG: ccache binary verified successfully"
+echo "โœ… ccache binary verified: $(/usr/bin/ccache --version | head -1)"
 
-        export CCACHE_MAXSIZE="12G"
-        echo CCACHE_MAXSIZE="$CCACHE_MAXSIZE" >> $GITHUB_ENV
-        export CCACHE_COMPILERCHECK="content"
-        echo CCACHE_COMPILERCHECK="$CCACHE_COMPILERCHECK" >> $GITHUB_ENV
-        export CCACHE_BASEDIR="${{ github.workspace }}"
-        echo CCACHE_BASEDIR="${{ github.workspace }}" >> $GITHUB_ENV
-        export CCACHE_NOHASHDIR="true"
-        echo CCACHE_NOHASHDIR="true" >> $GITHUB_ENV
-        export CCACHE_IGNOREOPTIONS="--sysroot*"
-        echo CCACHE_IGNOREOPTIONS="--sysroot*" >> $GITHUB_ENV
-        export CCACHE_COMPRESSION="true"
-        echo CCACHE_COMPRESSION="true" >> $GITHUB_ENV
-        export CCACHE_COMPRESSLEVEL="3"
-        echo CCACHE_COMPRESSION_LEVEL="3" >> $GITHUB_ENV
-        export CCACHE_DIRECT="true"
-        echo CCACHE_DIRECT="true" >> "$GITHUB_ENV"
-        export CCACHE_FILE_CLONE="true"
-        echo CCACHE_FILE_CLONE="true" >> "$GITHUB_ENV"
-        export CCACHE_INODE_CACHE="true"
-        echo CCACHE_INODE_CACHE="true" >> "$GITHUB_ENV"
-        export CCACHE_IS_KERNEL_COMPILING="true"
-        echo CCACHE_IS_KERNEL_COMPILING="true" >> $GITHUB_ENV
-        export CCACHE_UMASK="002"
-        echo CCACHE_UMASK="002" >> $GITHUB_ENV
-        export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
-        echo CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale" >> $GITHUB_ENV
-        #export CCACHE_HARDLINK="true"
-        #echo CCACHE_HARDLINK="$CCACHE_HARDLINK" >> $GITHUB_ENV
+# Setup cache directories
+echo "๐Ÿ” DEBUG: Setting up ccache directories and environment"
+export CCACHE_DIR="/home/runner/.ccache"
+echo "๐Ÿ” DEBUG: CCACHE_DIR=$CCACHE_DIR"
+echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
+mkdir -p "$CCACHE_DIR"
+echo "๐Ÿ” DEBUG: Created CCACHE_DIR directory"
+echo "๐Ÿ” DEBUG: CCACHE_DIR contents: $(ls -la $CCACHE_DIR 2>/dev/null | head -5 || echo 'empty')"
 
-        if ccache --help 2>&1 | grep -q 'depend_mode'; then
-          export CCACHE_DEPEND=true
-          echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
-        fi
+export CCACHE_MAXSIZE="12G"
+echo "๐Ÿ” DEBUG: CCACHE_MAXSIZE=$CCACHE_MAXSIZE"
+echo CCACHE_MAXSIZE="$CCACHE_MAXSIZE" >> $GITHUB_ENV
+export CCACHE_COMPILERCHECK="content"
+echo "๐Ÿ” DEBUG: CCACHE_COMPILERCHECK=$CCACHE_COMPILERCHECK"
+echo CCACHE_COMPILERCHECK="$CCACHE_COMPILERCHECK" >> $GITHUB_ENV
+export CCACHE_BASEDIR="${{ github.workspace }}"
+echo "๐Ÿ” DEBUG: CCACHE_BASEDIR=$CCACHE_BASEDIR"
+echo CCACHE_BASEDIR="${{ github.workspace }}" >> $GITHUB_ENV
+export CCACHE_NOHASHDIR="true"
+echo "๐Ÿ” DEBUG: CCACHE_NOHASHDIR=$CCACHE_NOHASHDIR"
+echo CCACHE_NOHASHDIR="true" >> $GITHUB_ENV
+export CCACHE_IGNOREOPTIONS="--sysroot*"
+echo "๐Ÿ” DEBUG: CCACHE_IGNOREOPTIONS=$CCACHE_IGNOREOPTIONS"
+echo CCACHE_IGNOREOPTIONS="--sysroot*" >> $GITHUB_ENV
+export CCACHE_COMPRESSION="true"
+echo "๐Ÿ” DEBUG: CCACHE_COMPRESSION=$CCACHE_COMPRESSION"
+echo CCACHE_COMPRESSION="true" >> $GITHUB_ENV
+export CCACHE_COMPRESSLEVEL="3"
+echo "๐Ÿ” DEBUG: CCACHE_COMPRESSLEVEL=$CCACHE_COMPRESSLEVEL"
+echo CCACHE_COMPRESSION_LEVEL="3" >> $GITHUB_ENV
+export CCACHE_DIRECT="true"
+echo "๐Ÿ” DEBUG: CCACHE_DIRECT=$CCACHE_DIRECT"
+echo CCACHE_DIRECT="true" >> "$GITHUB_ENV"
+export CCACHE_FILE_CLONE="true"
+echo "๐Ÿ” DEBUG: CCACHE_FILE_CLONE=$CCACHE_FILE_CLONE"
+echo CCACHE_FILE_CLONE="true" >> "$GITHUB_ENV"
+export CCACHE_INODE_CACHE="true"
+echo "๐Ÿ” DEBUG: CCACHE_INODE_CACHE=$CCACHE_INODE_CACHE"
+echo CCACHE_INODE_CACHE="true" >> "$GITHUB_ENV"
+export CCACHE_IS_KERNEL_COMPILING="true"
+echo "๐Ÿ” DEBUG: CCACHE_IS_KERNEL_COMPILING=$CCACHE_IS_KERNEL_COMPILING"
+echo CCACHE_IS_KERNEL_COMPILING="true" >> $GITHUB_ENV
+export CCACHE_UMASK="002"
+echo "๐Ÿ” DEBUG: CCACHE_UMASK=$CCACHE_UMASK"
+echo CCACHE_UMASK="002" >> $GITHUB_ENV
+export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
+echo "๐Ÿ” DEBUG: CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS"
+echo CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale" >> $GITHUB_ENV
+#export CCACHE_HARDLINK="true"
+#echo CCACHE_HARDLINK="$CCACHE_HARDLINK" >> $GITHUB_ENV
+
+echo "๐Ÿ” DEBUG: Checking if depend_mode is available"
+if ccache --help 2>&1 | grep -q 'depend_mode'; then
+  export CCACHE_DEPEND=true
+  echo "๐Ÿ” DEBUG: depend_mode available, setting CCACHE_DEPEND=true"
+  echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
+else
+  echo "๐Ÿ” DEBUG: depend_mode NOT available"
+fi
         
-        echo "=== ccache config ==="
-        echo "====================="
-        ccache -p
-        echo "====================="
+echo "๐Ÿ” DEBUG: Displaying ccache configuration"
+echo "=== ccache config ==="
+echo "====================="
+ccache -p
+echo "====================="
+echo "๐Ÿ” DEBUG: ccache config displayed successfully"
 
-        echo "โœ… ccache ready"
-        echo "CCACHE_DIR: $CCACHE_DIR"
+echo "โœ… ccache ready"
+echo "๐Ÿ” DEBUG: CCACHE_DIR=$CCACHE_DIR"
+echo "CCACHE_DIR: $CCACHE_DIR"
+echo "๐Ÿ” DEBUG: cache-setup ccache step complete"
 
     - name: Setup Bazel Cache
       shell: bash
@@ -105,36 +148,59 @@ runs:
         inputs.version == 'android16-6.12'
       working-directory: ${{ github.workspace }}
       run: |
-        set -euo pipefail
-        export BAZEL_CACHE_DIR="/home/runner/.cache/bazel"
-        mkdir -p "$BAZEL_CACHE_DIR"
-        
-        # Set bazel disk cache size limit to 8GB
-        #export BAZEL_DISK_CACHE_SIZE="8589934592"
-        #echo "BAZEL_DISK_CACHE_SIZE=$BAZEL_DISK_CACHE_SIZE" >> $GITHUB_ENV
+set -euo pipefail
+echo "๐Ÿ” DEBUG: Setup Bazel Cache started"
+export BAZEL_CACHE_DIR="/home/runner/.cache/bazel"
+echo "๐Ÿ” DEBUG: BAZEL_CACHE_DIR=$BAZEL_CACHE_DIR"
+mkdir -p "$BAZEL_CACHE_DIR"
+echo "๐Ÿ” DEBUG: Created Bazel cache directory"
+echo "๐Ÿ” DEBUG: Bazel cache directory contents: $(ls -la $BAZEL_CACHE_DIR 2>/dev/null | head -5 || echo 'empty')"
 
-        #echo "โœ… Bazel Cache ready (max 8GB)"
-        echo "BAZEL_CACHE_DIR: $BAZEL_CACHE_DIR"
+# Set bazel disk cache size limit to 8GB
+#export BAZEL_DISK_CACHE_SIZE="8589934592"
+#echo "BAZEL_DISK_CACHE_SIZE=$BAZEL_DISK_CACHE_SIZE" >> $GITHUB_ENV
+
+#echo "โœ… Bazel Cache ready (max 8GB)"
+echo "BAZEL_CACHE_DIR: $BAZEL_CACHE_DIR"
+echo "๐Ÿ” DEBUG: Setup Bazel Cache complete"
 
     - name: Setup ld cache
       shell: bash
       working-directory: ${{ github.workspace }}
       run: |
-        set -euo pipefail
-        export LDCACHE_DIR="/home/runner/.ld_cache"
-        echo "LDCACHE_DIR=$LDCACHE_DIR" >> $GITHUB_ENV
-        mkdir -p "$LDCACHE_DIR"
-          
-        # Create LD wrapper for thin-LTO caching
-        cat > "${{ github.workspace }}/kernel/common/ld-wrapper" << 'EOF'
-        #!/bin/bash
-        ld.lld "$@" --thinlto-cache-dir="$LDCACHE_DIR" --thinlto-jobs="$(nproc --all)"
-        EOF
-        chmod +x "${{ github.workspace }}/kernel/common/ld-wrapper"
+set -euo pipefail
+echo "๐Ÿ” DEBUG: Setup ld cache started"
+export LDCACHE_DIR="/home/runner/.ld_cache"
+echo "๐Ÿ” DEBUG: LDCACHE_DIR=$LDCACHE_DIR"
+echo "LDCACHE_DIR=$LDCACHE_DIR" >> $GITHUB_ENV
+mkdir -p "$LDCACHE_DIR"
+echo "๐Ÿ” DEBUG: Created ld cache directory"
+echo "๐Ÿ” DEBUG: LDCACHE_DIR contents: $(ls -la $LDCACHE_DIR 2>/dev/null | head -5 || echo 'empty')"
+  
+# Create LD wrapper for thin-LTO caching
+echo "๐Ÿ” DEBUG: Creating LD wrapper script at ${{ github.workspace }}/kernel/common/ld-wrapper"
+cat > "${{ github.workspace }}/kernel/common/ld-wrapper" << 'EOF'
+#!/bin/bash
+ld.lld "$@" --thinlto-cache-dir="$LDCACHE_DIR" --thinlto-jobs="$(nproc --all)"
+EOF
+chmod +x "${{ github.workspace }}/kernel/common/ld-wrapper"
+echo "๐Ÿ” DEBUG: LD wrapper created and made executable"
+
+# Verify LD wrapper exists
+if [ -f "${{ github.workspace }}/kernel/common/ld-wrapper" ]; then
+  echo "๐Ÿ” DEBUG: LD wrapper verified at ${{ github.workspace }}/kernel/common/ld-wrapper"
+  echo "๐Ÿ” DEBUG: LD wrapper contents:"
+  cat "${{ github.workspace }}/kernel/common/ld-wrapper"
+else
+  echo "๐Ÿ” DEBUG: WARNING - LD wrapper not found after creation!"
+fi
 
-        # Set size limit via environment (4GB)
-        echo "LDCACHE_MAX_SIZE=4294967296" >> "$GITHUB_ENV"
+# Set size limit via environment (4GB)
+echo "LDCACHE_MAX_SIZE=4294967296" >> "$GITHUB_ENV"
+echo "๐Ÿ” DEBUG: LDCACHE_MAX_SIZE=4294967296 set"
 
-        echo "โœ… LD Cache ready (max 4GB)"
-        echo "LDCACHE_DIR: $LDCACHE_DIR"
+echo "โœ… LD Cache ready (max 4GB)"
+echo "๐Ÿ” DEBUG: LDCACHE_DIR=$LDCACHE_DIR"
+echo "LDCACHE_DIR: $LDCACHE_DIR"
+echo "๐Ÿ” DEBUG: Setup ld cache complete"
         

+ 159 - 87
.github/actions/cache-stats/action.yml

@@ -14,8 +14,12 @@ runs:
       shell: bash
       working-directory: ${{ github.workspace }}
       run: |
-        set -euo pipefail
-        cat > /tmp/cache_summary.sh <<'EOF'
+set -euo pipefail
+echo "๐Ÿ” DEBUG: cache-stats action started"
+echo "๐Ÿ” DEBUG: inputs.clear_stats=${{ inputs.clear_stats }}"
+echo "๐Ÿ” DEBUG: github.workspace=${{ github.workspace }}"
+
+cat > /tmp/cache_summary.sh <<'EOF'
         summarize_dir() {
           local path="$1"
           local top_n=${2:-10}
@@ -47,107 +51,175 @@ runs:
       shell: bash
       working-directory: ${{ github.workspace }}
       run: |
-        set -euo pipefail
-        echo "===================="
-        echo "=== ccache stats ==="
-        echo "===================="
-        
-        if ! command -v ccache >/dev/null 2>&1; then
-          echo "โš ๏ธ  ccache not installed, skipping ccache stats"
-          echo "===================="
-          exit 0
-        fi
-        
-        ccache -s || true
-        echo "====================="
-        echo "=== ccache config ==="
-        echo "====================="
-        ccache -p || true
-        echo "====================="
-
-        STATS="$(ccache -s)"
-        
-        CACHEABLE=$(echo "$STATS" | awk '/Cacheable calls:/ {
-          match($0, /[0-9]+/); 
-          print substr($0, RSTART, RLENGTH)
-        }' | head -n1)
-        
-        HITS=$(echo "$STATS" | awk '/^[[:space:]]*Hits:/ {
-          match($0, /[0-9]+/); 
-          print substr($0, RSTART, RLENGTH)
-        }' | head -n1)
-        
-        DIRECT=$(echo "$STATS" | awk '/Direct:/ {
-          match($0, /[0-9]+/); 
-          print substr($0, RSTART, RLENGTH)
-        }' | head -n1)
+set -euo pipefail
+echo "===================="
+echo "=== ccache stats ==="
+echo "===================="
+echo "๐Ÿ” DEBUG: Starting ccache stats collection"
+
+if ! command -v ccache >/dev/null 2>&1; then
+  echo "๐Ÿ” DEBUG: ccache command not found"
+  echo "โš ๏ธ  ccache not installed, skipping ccache stats"
+  echo "===================="
+  exit 0
+fi
+echo "๐Ÿ” DEBUG: ccache command found at: $(which ccache)"
+
+# Get ccache version
+CCACHE_VERSION=$(ccache --version | head -1)
+echo "๐Ÿ” DEBUG: ccache version: $CCACHE_VERSION"
+
+# Check ccache directory
+echo "๐Ÿ” DEBUG: Checking ccache directory: /home/runner/.ccache"
+if [ -d /home/runner/.ccache ]; then
+  echo "๐Ÿ” DEBUG: ccache directory exists"
+  echo "๐Ÿ” DEBUG: ccache directory size: $(du -sh /home/runner/.ccache 2>/dev/null | cut -f1)"
+  echo "๐Ÿ” DEBUG: ccache directory file count: $(find /home/runner/.ccache -type f 2>/dev/null | wc -l)"
+else
+  echo "๐Ÿ” DEBUG: ccache directory does NOT exist"
+fi
+
+echo "๐Ÿ” DEBUG: Running ccache -s (statistics)"
+ccache -s || true
+echo "๐Ÿ” DEBUG: ccache -s completed"
+echo "====================="
+echo "=== ccache config ==="
+echo "====================="
+echo "๐Ÿ” DEBUG: Running ccache -p (config)"
+ccache -p || true
+echo "๐Ÿ” DEBUG: ccache -p completed"
+echo "====================="
+
+echo "๐Ÿ” DEBUG: Running ccache -s for stats parsing"
+STATS="$(ccache -s)"
+echo "๐Ÿ” DEBUG: Raw ccache stats captured"
         
-        if [ "${CACHEABLE:-0}" -gt 0 ]; then
-          HIT_RATE=$(awk -v h="${HITS:-0}" -v c="$CACHEABLE" 'BEGIN{printf "%.1f", (h/c)*100}')
-          DIRECT_RATE=$(awk -v d="${DIRECT:-0}" -v c="$CACHEABLE" 'BEGIN{printf "%.1f", (d/c)*100}')
-        else
-          HIT_RATE="0.0"
-          DIRECT_RATE="0.0"
-        fi
+echo "๐Ÿ” DEBUG: Parsing ccache statistics"
+echo "๐Ÿ” DEBUG: Raw STATS (first 10 lines):"
+echo "$STATS" | head -n 10
+
+CACHEABLE=$(echo "$STATS" | awk '/Cacheable calls:/ {
+  match($0, /[0-9]+/);
+  print substr($0, RSTART, RLENGTH)
+}' | head -n1)
+echo "๐Ÿ” DEBUG: CACHEABLE=$CACHEABLE"
+
+HITS=$(echo "$STATS" | awk '/^[[:space:]]*Hits:/ {
+  match($0, /[0-9]+/);
+  print substr($0, RSTART, RLENGTH)
+}' | head -n1)
+echo "๐Ÿ” DEBUG: HITS=$HITS"
+
+DIRECT=$(echo "$STATS" | awk '/Direct:/ {
+  match($0, /[0-9]+/);
+  print substr($0, RSTART, RLENGTH)
+}' | head -n1)
+echo "๐Ÿ” DEBUG: DIRECT=$DIRECT"
         
-        echo "hit_rate=${HIT_RATE}%"
-        echo "direct_rate=${DIRECT_RATE}%"
-
-        if [ "${{ inputs.clear_stats }}" = "true" ]; then
-          echo "=== ccache reset ==="
-          echo "====================="
-          ccache -z || true
-          echo "====================="
-          
-          # Touch all files to prevent LRU eviction of freshly restored cache
-          if [ -d /home/runner/.ccache ] && find /home/runner/.ccache -type f -print -quit 2>/dev/null | grep -q .; then
-            echo "Updating ccache atime to prevent cache eviction..."
-            find /home/runner/.ccache -type f -exec touch -t $(date -d "1 day ago" +%Y%m%d%H%M) {} +
-            echo "โœ… ccache atime updated"
-          fi
-          if [ -d /home/runner/.ld_cache ] && find /home/runner/.ld_cache -type f -print -quit 2>/dev/null | grep -q .; then
-            echo "Updating LTO cache atime to prevent cache eviction..."
-            find /home/runner/.ld_cache -type f -exec touch -t $(date -d "1 day ago" +%Y%m%d%H%M) {} +
-            echo "โœ… LTO cache atime updated"
-          fi
-        else
-          echo "Keeping ccache stats for next run"
-        fi
+echo "๐Ÿ” DEBUG: Calculating hit rates"
+echo "๐Ÿ” DEBUG: CACHEABLE=${CACHEABLE:-0}, HITS=${HITS:-0}, DIRECT=${DIRECT:-0}"
+if [ "${CACHEABLE:-0}" -gt 0 ]; then
+  HIT_RATE=$(awk -v h="${HITS:-0}" -v c="$CACHEABLE" 'BEGIN{printf "%.1f", (h/c)*100}')
+  DIRECT_RATE=$(awk -v d="${DIRECT:-0}" -v c="$CACHEABLE" 'BEGIN{printf "%.1f", (d/c)*100}')
+  echo "๐Ÿ” DEBUG: Calculated HIT_RATE=$HIT_RATE%, DIRECT_RATE=$DIRECT_RATE%"
+else
+  HIT_RATE="0.0"
+  DIRECT_RATE="0.0"
+  echo "๐Ÿ” DEBUG: CACHEABLE is 0, setting rates to 0.0%"
+fi
+
+echo "hit_rate=${HIT_RATE}%"
+echo "direct_rate=${DIRECT_RATE}%"
+echo "๐Ÿ” DEBUG: Hit rates output complete"
+
+echo "๐Ÿ” DEBUG: clear_stats check: ${{ inputs.clear_stats }}"
+if [ "${{ inputs.clear_stats }}" = "true" ]; then
+  echo "๐Ÿ” DEBUG: Clearing ccache stats (ccache -z)"
+  echo "=== ccache reset ==="
+  echo "====================="
+  ccache -z || true
+  echo "๐Ÿ” DEBUG: ccache -z completed"
+  echo "====================="
+  
+  # Touch all files to prevent LRU eviction of freshly restored cache
+  echo "๐Ÿ” DEBUG: Checking if ccache directory needs atime update"
+  if [ -d /home/runner/.ccache ] && find /home/runner/.ccache -type f -print -quit 2>/dev/null | grep -q .; then
+    echo "๐Ÿ” DEBUG: ccache directory has files, updating atime"
+    echo "Updating ccache atime to prevent cache eviction..."
+    echo "๐Ÿ” DEBUG: Executing find touch command for ccache files"
+    find /home/runner/.ccache -type f -exec touch -t $(date -d "1 day ago" +%Y%m%d%H%M) {} +
+    echo "โœ… ccache atime updated"
+    echo "๐Ÿ” DEBUG: ccache atime update completed"
+  else
+    echo "๐Ÿ” DEBUG: Skipping ccache atime update (directory empty or missing)"
+  fi
+  
+  echo "๐Ÿ” DEBUG: Checking if ld_cache directory needs atime update"
+  if [ -d /home/runner/.ld_cache ] && find /home/runner/.ld_cache -type f -print -quit 2>/dev/null | grep -q .; then
+    echo "๐Ÿ” DEBUG: ld_cache directory has files, updating atime"
+    echo "Updating LTO cache atime to prevent cache eviction..."
+    echo "๐Ÿ” DEBUG: Executing find touch command for ld_cache files"
+    find /home/runner/.ld_cache -type f -exec touch -t $(date -d "1 day ago" +%Y%m%d%H%M) {} +
+    echo "โœ… LTO cache atime updated"
+    echo "๐Ÿ” DEBUG: LTO cache atime update completed"
+  else
+    echo "๐Ÿ” DEBUG: Skipping ld_cache atime update (directory empty or missing)"
+  fi
+else
+  echo "๐Ÿ” DEBUG: clear_stats is false, keeping ccache stats for next run"
+  echo "Keeping ccache stats for next run"
+fi
+echo "๐Ÿ” DEBUG: ccache stats section complete"
 
     - name: Show ccache folder Stats
       shell: bash
       working-directory: ${{ github.workspace }}
       run: |
-        set -euo pipefail
-        # shellcheck disable=SC1091
-        source /tmp/cache_summary.sh
+set -euo pipefail
+echo "๐Ÿ” DEBUG: ccache folder stats section started"
+# shellcheck disable=SC1091
+source /tmp/cache_summary.sh
+echo "๐Ÿ” DEBUG: cache_summary.sh loaded successfully"
 
-        echo "==============="
-        echo "=== .ccache ==="
-        echo "==============="
-        summarize_dir /home/runner/.ccache 10 5 || true
+echo "๐Ÿ” DEBUG: Calling summarize_dir for /home/runner/.ccache with top_n=10, sub_n=5"
+echo "==============="
+echo "=== .ccache ==="
+echo "==============="
+summarize_dir /home/runner/.ccache 10 5 || true
+echo "๐Ÿ” DEBUG: ccache folder stats section complete"
 
     - name: Show Bazel Cache folder Stats
       shell: bash
       working-directory: ${{ github.workspace }}
       run: |
-        set -euo pipefail
-        # shellcheck disable=SC1091
-        source /tmp/cache_summary.sh
-        echo "===================="
-        echo "=== .cache/bazel ==="
-        echo "===================="
-        summarize_dir /home/runner/.cache/bazel 10 5 || true
+set -euo pipefail
+echo "๐Ÿ” DEBUG: Bazel cache folder stats section started"
+# shellcheck disable=SC1091
+source /tmp/cache_summary.sh
+echo "๐Ÿ” DEBUG: cache_summary.sh loaded successfully"
+
+echo "๐Ÿ” DEBUG: Calling summarize_dir for /home/runner/.cache/bazel with top_n=10, sub_n=5"
+echo "===================="
+echo "=== .cache/bazel ==="
+echo "===================="
+summarize_dir /home/runner/.cache/bazel 10 5 || true
+echo "๐Ÿ” DEBUG: Bazel cache folder stats section complete"
         
     - name: Show ld cache folder Stats
       shell: bash
       working-directory: ${{ github.workspace }}
       run: |
-        set -euo pipefail
-        # shellcheck disable=SC1091
-        source /tmp/cache_summary.sh
-        echo "================="
-        echo "=== .ld_cache ==="
-        echo "================="
-        summarize_dir /home/runner/.ld_cache 10 5 || true
+set -euo pipefail
+echo "๐Ÿ” DEBUG: ld cache folder stats section started"
+# shellcheck disable=SC1091
+source /tmp/cache_summary.sh
+echo "๐Ÿ” DEBUG: cache_summary.sh loaded successfully"
+
+echo "๐Ÿ” DEBUG: Calling summarize_dir for /home/runner/.ld_cache with top_n=10, sub_n=5"
+echo "================="
+echo "=== .ld_cache ==="
+echo "================="
+summarize_dir /home/runner/.ld_cache 10 5 || true
+echo "๐Ÿ” DEBUG: ld cache folder stats section complete"
+echo "๐Ÿ” DEBUG: cache-stats action finished successfully"