action.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. name: 'Show Cache Folder Stats'
  2. description: 'Display directory-level cache stats for ccache and Bazel'
  3. runs:
  4. using: 'composite'
  5. steps:
  6. - name: Define cache summary helper
  7. shell: bash
  8. working-directory: ${{ github.workspace }}
  9. run: |
  10. set -euo pipefail
  11. cat > /tmp/cache_summary.sh <<'EOF'
  12. summarize_dir() {
  13. local path="$1"
  14. local top_n=${2:-10}
  15. local sub_n=${3:-5}
  16. if [ ! -e "$path" ]; then
  17. echo "Path $path not found"
  18. return
  19. fi
  20. echo "---------------"
  21. echo "Summary: $path"
  22. du -sh "$path" || true
  23. echo "Top ${top_n} entries at top level:"
  24. du -h --max-depth=1 "$path" 2>/dev/null | sort -hr | head -n "$top_n" || true
  25. echo "Showing up to ${sub_n} entries one level deeper for the largest top-level items:"
  26. while read -r line; do
  27. entry_path=$(echo "$line" | awk '{print $2}')
  28. [ -z "$entry_path" ] && continue
  29. if [ "$entry_path" = "$path" ]; then
  30. continue
  31. fi
  32. echo "-> $entry_path :"
  33. du -h --max-depth=1 "$entry_path" 2>/dev/null | sort -hr | head -n "$sub_n" || true
  34. done < <(du -h --max-depth=1 "$path" 2>/dev/null | sort -hr | head -n "$top_n")
  35. echo "---------------"
  36. }
  37. EOF
  38. - name: Show ccache folder Stats
  39. shell: bash
  40. working-directory: ${{ github.workspace }}
  41. run: |
  42. set -euo pipefail
  43. source /tmp/cache_summary.sh
  44. echo "==============="
  45. echo "=== .ccache ==="
  46. echo "==============="
  47. summarize_dir /home/runner/.ccache 10 5 || true
  48. - name: Show Bazel Cache folder Stats
  49. shell: bash
  50. working-directory: ${{ github.workspace }}
  51. run: |
  52. set -euo pipefail
  53. source /tmp/cache_summary.sh
  54. echo "===================="
  55. echo "=== .cache/bazel ==="
  56. echo "===================="
  57. summarize_dir /home/runner/.cache/bazel 10 5 || true