Skip to content

Commit 2a21f8c

Browse files
committed
ci: Extract disk usage report as an action, make it work on macOS
It's useful for release jobs as well. Extract it to a separate action. Use `-d` instead of `--max-depth` to make it compatible with the BSD implementation of `du` that's used on macOS. Do not check the APT directory on macOS.
1 parent e101167 commit 2a21f8c

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Report disk usage
2+
description: Print disk usage for key directories on the runner
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Report disk usage
7+
shell: bash
8+
run: |
9+
set -euo pipefail
10+
11+
printf "\n== Filesystems ==\n"
12+
df -h
13+
14+
report_dir() {
15+
local dir="$1"
16+
local depth="$2"
17+
18+
[[ -d "$dir" ]] || return
19+
20+
printf "\n== %s ==\n" "$dir"
21+
sudo -n du -x -h -d "$depth" "$dir" 2>/dev/null | sort -h -r | head -n 20
22+
}
23+
24+
report_dir "${{ github.workspace }}" 2
25+
report_dir "$HOME/.cargo" 2
26+
report_dir "$HOME/.rustup" 1
27+
report_dir /tmp 1
28+
if [[ "${RUNNER_OS:-}" == "Linux" ]]; then
29+
report_dir /var/cache/apt/archives 1
30+
fi

.github/workflows/ci.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -240,24 +240,4 @@ jobs:
240240

241241
- name: Report disk usage
242242
if: ${{ always() }}
243-
run: |
244-
set -euo pipefail
245-
246-
printf "\n== Filesystems ==\n"
247-
df -h
248-
249-
report_dir() {
250-
local dir="$1"
251-
local depth="$2"
252-
253-
[[ -d "$dir" ]] || return
254-
255-
printf "\n== %s ==\n" "$dir"
256-
sudo -n du -x -h --max-depth="$depth" "$dir" 2>/dev/null | sort -h -r | head -n 20
257-
}
258-
259-
report_dir "${{ github.workspace }}" 2
260-
report_dir "$HOME/.cargo" 2
261-
report_dir "$HOME/.rustup" 1
262-
report_dir /tmp 1
263-
report_dir /var/cache/apt/archives 1
243+
uses: ./.github/actions/report-disk-usage

0 commit comments

Comments
 (0)