浏览代码

Make cache reporting concise: show top-level sizes + one-level deep; suppress verbose tar extraction

TheWildJames 4 月之前
父节点
当前提交
1bee712668
共有 3 个文件被更改,包括 76 次插入13 次删除
  1. 21 4
      .github/actions/cache-restore/action.yml
  2. 27 0
      .github/actions/cache-save/action.yml
  3. 28 9
      .github/actions/cache-stats/action.yml

+ 21 - 4
.github/actions/cache-restore/action.yml

@@ -207,16 +207,17 @@ runs:
             if [ "$IS_SPLIT" = "true" ]; then
               PARTS=$(ls "$FINAL_ARCHIVE.part"* | sort)
               if [ "$COMPRESSED" = "true" ]; then
-                cat $PARTS | tar -I "zstd -d -T0" -xvf - -C "$EXTRACT_DIR"
+                # Extract quietly (no verbose listing)
+                cat $PARTS | tar -I "zstd -d -T0" -xf - -C "$EXTRACT_DIR"
               else
-                cat $PARTS | tar -xvf - -C "$EXTRACT_DIR"
+                cat $PARTS | tar -xf - -C "$EXTRACT_DIR"
               fi
               rm -f $PARTS
             else
               if [ "$COMPRESSED" = "true" ]; then
-                tar -I "zstd -d -T0" -xvf "$FINAL_ARCHIVE" -C "$EXTRACT_DIR"
+                tar -I "zstd -d -T0" -xf "$FINAL_ARCHIVE" -C "$EXTRACT_DIR"
               else
-                tar -xvf "$FINAL_ARCHIVE" -C "$EXTRACT_DIR"
+                tar -xf "$FINAL_ARCHIVE" -C "$EXTRACT_DIR"
               fi
               rm -f "$FINAL_ARCHIVE"
             fi
@@ -228,6 +229,22 @@ runs:
             MATCHED_KEYS+=("$KEY")
             CACHE_SIZE=$(du -sh "$CACHE_PATH" 2>/dev/null | awk '{print $1}' || echo "unknown")
             CACHE_SIZES+=("$CACHE_SIZE")
+            # Provide a concise summary of restored path (top-level + one level deep)
+            echo "--- Cache restore summary for: $CACHE_PATH ---"
+            if [ -e "$CACHE_PATH" ]; then
+              du -sh "$CACHE_PATH" || true
+              du -h --max-depth=1 "$CACHE_PATH" 2>/dev/null | sort -hr | head -n 10 || true
+              echo "Showing one-level-deep details for top entries (up to 5 each):"
+              while read -r _entry; do
+                entry_path=$(echo "$_entry" | awk '{print $2}')
+                [ -z "$entry_path" ] && continue
+                if [ "$entry_path" = "$CACHE_PATH" ]; then
+                  continue
+                fi
+                echo "-> $entry_path :"
+                du -h --max-depth=1 "$entry_path" 2>/dev/null | sort -hr | head -n 5 || true
+              done < <(du -h --max-depth=1 "$CACHE_PATH" 2>/dev/null | sort -hr | head -n 10)
+            fi
             break
           done <<< "$SEARCH_LIST"
           

+ 27 - 0
.github/actions/cache-save/action.yml

@@ -163,6 +163,33 @@ runs:
             echo "::endgroup::"
             continue
           fi
+
+          # Print concise summary: total size, top-level entries, and one-level-deep for largest entries
+          summarize_dir() {
+            local path="$1"
+            local top_n=${2:-10}
+            local sub_n=${3:-5}
+            if [ ! -e "$path" ]; then
+              echo "Path $path not found"
+              return
+            fi
+            echo "--- Cache save summary for: $path ---"
+            du -sh "$path" || true
+            du -h --max-depth=1 "$path" 2>/dev/null | sort -hr | head -n $top_n || true
+            echo "Showing one-level-deep details for top entries (up to $sub_n each):"
+            while read -r line; do
+              entry_path=$(echo "$line" | awk '{print $2}')
+              [ -z "$entry_path" ] && continue
+              if [ "$entry_path" = "$path" ]; then
+                continue
+              fi
+              echo "-> $entry_path :"
+              du -h --max-depth=1 "$entry_path" 2>/dev/null | sort -hr | head -n $sub_n || true
+            done < <(du -h --max-depth=1 "$path" 2>/dev/null | sort -hr | head -n $top_n)
+            echo "-------------------------------------"
+          }
+
+          summarize_dir "$CACHE_PATH" 10 5 || true
           
           DIR_NAME=$(dirname "$CACHE_PATH")
           BASE_NAME=$(basename "$CACHE_PATH")

+ 28 - 9
.github/actions/cache-stats/action.yml

@@ -74,12 +74,35 @@ runs:
       working-directory: ${{ github.workspace }}
       run: |
         set -euo pipefail
+        summarize_dir() {
+          local path="$1"
+          local top_n=${2:-10}
+          local sub_n=${3:-5}
+          if [ ! -e "$path" ]; then
+            echo "Path $path not found"
+            return
+          fi
+          echo "---------------"
+          echo "Summary: $path"
+          du -sh "$path" || true
+          echo "Top ${top_n} entries at top level:"
+          du -h --max-depth=1 "$path" 2>/dev/null | sort -hr | head -n $top_n || true
+          echo "\nShowing up to ${sub_n} entries one level deeper for the largest top-level items:"
+          while read -r size name; do
+            # skip the root entry which matches the path itself
+            if [ "${name%/}" = "${path%/}" ]; then
+              continue
+            fi
+            echo "-> $name :"
+            du -h --max-depth=1 "$name" 2>/dev/null | sort -hr | head -n $sub_n || true
+          done < <(du -h --max-depth=1 "$path" 2>/dev/null | sort -hr | head -n $top_n)
+          echo "---------------"
+        }
+
         echo "==============="
         echo "=== .ccache ==="
         echo "==============="
-        du -sh /home/runner/.ccache || true
-        ls -l /home/runner/.ccache || true
-        echo "==============="
+        summarize_dir /home/runner/.ccache 10 5 || true
 
     - name: Show Bazel Cache folder Stats
       shell: bash
@@ -89,9 +112,7 @@ runs:
         echo "===================="
         echo "=== .cache/bazel ==="
         echo "===================="
-        du -sh /home/runner/.cache/bazel || true
-        ls -l /home/runner/.cache/bazel || true
-        echo "===================="
+        summarize_dir /home/runner/.cache/bazel 10 5 || true
         
     - name: Show ld cache folder Stats
       shell: bash
@@ -101,7 +122,5 @@ runs:
         echo "================="
         echo "=== .ld_cache ==="
         echo "================="
-        du -sh /home/runner/.ld_cache || true
-        ls -l /home/runner/.ld_cache || true
-        echo "================="
+        summarize_dir /home/runner/.ld_cache 10 5 || true