Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/scripts/github-actions/disk-status.sh
11810 views
1
#!/usr/bin/env bash
2
#
3
# Print a disk-status snapshot for use as a CI checkpoint:
4
# Also exports AVAIL_GB (available space in GB
5
6
echo "=== Disk space ==="
7
df -h "$GITHUB_WORKSPACE" || true
8
# Also show the Windows system drive (C:) for reference. The build runs on the
9
# workspace drive (D: on Windows, / on Linux), so that is what we measure below.
10
if [[ "$RUNNER_OS" == "Windows" ]]; then df -h /c || true; fi
11
12
# Available space on the drive the build actually uses (the workspace).
13
AVAIL_GB=$(df -k "$GITHUB_WORKSPACE" | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
14
if ! [[ "$AVAIL_GB" =~ ^[0-9]+$ ]]; then
15
echo "::error::Could not determine available disk space (got: '${AVAIL_GB}')"
16
AVAIL_GB=0
17
fi
18
export AVAIL_GB
19
echo "Available: ${AVAIL_GB}GB"
20
21
if [[ "$RUNNER_OS" == "Windows" ]]; then
22
external="/d/b/external"
23
repos="/d/b-repo"
24
bazelisk="/c/Users/runneradmin/AppData/Local/bazelisk"
25
else
26
external="$HOME/.bazel/external"
27
repos="$HOME/.cache/bazel-repo"
28
bazelisk="$HOME/.cache/bazelisk"
29
fi
30
31
echo "=== Bazel cache sizes ==="
32
cache_size() {
33
local label="$1" path="$2"
34
if [ -d "$path" ]; then
35
local size
36
size=$(du -sh "$path" 2>/dev/null | awk '{print $1}')
37
printf " %-25s %s\n" "${label}:" "$size"
38
else
39
printf " %-25s (not present)\n" "${label}:"
40
fi
41
}
42
cache_size "External" "$external"
43
if [ -d "$repos" ]; then
44
for sub in "$repos"/*/; do
45
[ -d "$sub" ] || continue
46
case "$(basename "$sub")" in
47
content_addressable) label="Repository Cache" ;;
48
contents) label="Repo Contents Cache" ;;
49
*) label="Repository/$(basename "$sub")" ;;
50
esac
51
cache_size "$label" "$sub"
52
done
53
else
54
cache_size "Repository Cache" "$repos"
55
fi
56
cache_size "Bazelisk" "$bazelisk"
57
58