Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/scripts/github-actions/disk-status.sh
10192 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
if [[ "$RUNNER_OS" == "Windows" ]]; then df -h /c || true; fi
9
10
# On Windows the workspace is on D: but C: is the constrained drive
11
if [[ "$RUNNER_OS" == "Windows" ]]; then
12
AVAIL_GB=$(df -k /c | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
13
else
14
AVAIL_GB=$(df -k "$GITHUB_WORKSPACE" | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
15
fi
16
if ! [[ "$AVAIL_GB" =~ ^[0-9]+$ ]]; then
17
echo "::error::Could not determine available disk space (got: '${AVAIL_GB}')"
18
AVAIL_GB=0
19
fi
20
export AVAIL_GB
21
echo "Available: ${AVAIL_GB}GB"
22
23
if [[ "$RUNNER_OS" == "Windows" ]]; then
24
external="/d/b/external"
25
repos="/d/b-repo"
26
bazelisk="/c/Users/runneradmin/AppData/Local/bazelisk"
27
else
28
external="$HOME/.bazel/external"
29
repos="$HOME/.cache/bazel-repo"
30
bazelisk="$HOME/.cache/bazelisk"
31
fi
32
33
echo "=== Bazel cache sizes ==="
34
cache_size() {
35
local label="$1" path="$2"
36
if [ -d "$path" ]; then
37
local size
38
size=$(du -sh "$path" 2>/dev/null | awk '{print $1}')
39
printf " %-25s %s\n" "${label}:" "$size"
40
else
41
printf " %-25s (not present)\n" "${label}:"
42
fi
43
}
44
cache_size "External" "$external"
45
if [ -d "$repos" ]; then
46
for sub in "$repos"/*/; do
47
[ -d "$sub" ] || continue
48
case "$(basename "$sub")" in
49
content_addressable) label="Repository Cache" ;;
50
contents) label="Repo Contents Cache" ;;
51
*) label="Repository/$(basename "$sub")" ;;
52
esac
53
cache_size "$label" "$sub"
54
done
55
else
56
cache_size "Repository Cache" "$repos"
57
fi
58
cache_size "Bazelisk" "$bazelisk"
59
60