Skip to content

Commit 83bc2ee

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 55f7771 commit 83bc2ee

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
@@ -239,24 +239,4 @@ jobs:
239239

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

0 commit comments

Comments
 (0)