Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ query --@aspect_rules_ts//ts:default_to_tsc_transpiler

build --incompatible_strict_action_env

# Prevent runner-provided ANDROID_HOME triggering rules_android's SDK fetch.
# Creates a harmless empty repo instead of failing on missing API platforms.
common --repo_env=ANDROID_HOME=

# Required for prebuilt protoc to be used
common --@protobuf//bazel/toolchains:prefer_prebuilt_protoc=true

Expand Down
89 changes: 20 additions & 69 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,35 +95,6 @@ jobs:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
steps:
- name: Remove extra tools to free disk space
if: inputs.os == 'ubuntu'
run: |
echo "Removing extra tools to free disk space..."
echo "Space before: $(df -BG / | tail -1 | awk '{print $4}')"
sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/.ghcup || true
sudo rm -rf /usr/local/share/boost || true
sudo rm -rf /usr/share/swift || true
sudo rm -rf /usr/local/julia* || true
sudo rm -rf /usr/lib/google-cloud-sdk || true
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
docker image prune -af 2>/dev/null || true
sync
after=$(df -BG / | tail -1 | awk '{print $4}')
echo "Space after: ${after}"
- name: Remove extra tools to free disk space (Windows)
if: inputs.os == 'windows'
shell: pwsh
run: |
Write-Host "Removing extra tools to free disk space..."
Write-Host "Space before: C: $([math]::Round((Get-PSDrive C).Free / 1GB, 1))GB free, D: $([math]::Round((Get-PSDrive D).Free / 1GB, 1))GB free"
Remove-Item -Path "C:\Miniconda" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\tools\ghc" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Program Files\LLVM" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Program Files\PostgreSQL" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Program Files\MongoDB" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Program Files\MySQL" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Space after: C: $([math]::Round((Get-PSDrive C).Free / 1GB, 1))GB free, D: $([math]::Round((Get-PSDrive D).Free / 1GB, 1))GB free"
- name: Calculate fetch depth
id: depth
shell: bash
Expand Down Expand Up @@ -160,23 +131,20 @@ jobs:
run: git pull origin "$GIT_REF"
env:
GIT_REF: ${{ github.ref }}
- name: Free disk space
if: inputs.os == 'ubuntu'
run: ./scripts/github-actions/free-disk-space.sh
- name: Free disk space (Windows)
if: inputs.os == 'windows'
shell: pwsh
run: ./scripts/github-actions/free-disk-space.ps1
- name: Restore cache
if: inputs.cache-name != ''
uses: actions/cache/restore@v5
with:
path: ${{ inputs.cache-name }}
key: ${{ inputs.cache-name }}-
restore-keys: ${{ inputs.cache-name }}-
- name: Remove driver directories Windows
if: inputs.os == 'windows'
run: |
rm "$env:ChromeWebDriver" -r -v
rm "$env:EdgeWebDriver" -r -v
rm "$env:GeckoWebDriver" -r -v
- name: Remove driver directories Non-Windows
if: inputs.os != 'windows'
run: |
sudo rm -rf "$CHROMEWEBDRIVER" "$EDGEWEBDRIVER" "$GECKOWEBDRIVER"
- name: Set Python version
if: inputs.python-version != ''
run: echo '${{ inputs.python-version }}' > py/.python-version
Expand Down Expand Up @@ -224,14 +192,6 @@ jobs:
"+pin_browsers_extension+mac_firefox": false
"+pin_browsers_extension+mac_geckodriver": false
repository-cache: true
- name: Report Bazel cache setup failure
if: steps.setup-bazel-cached.outcome == 'failure'
shell: bash
run: |
echo "::warning::Bazel cache setup failed — falling back to setup without cache"
echo "=== Disk space at time of cache failure ==="
df -h "$GITHUB_WORKSPACE" || true
if [[ "$RUNNER_OS" == "Windows" ]]; then df -h /c || true; fi
- name: Setup Bazel without caching
if: inputs.caching == false || steps.setup-bazel-cached.outcome == 'failure'
uses: bazel-contrib/setup-bazel@0.19.0
Expand All @@ -243,12 +203,14 @@ jobs:
crates: rust/Cargo.Bazel.lock
repository-cache: true
bazelrc: common --color=yes
- name: Disk usage after cache restore
- name: Disk status after cache restore
if: inputs.os != 'macos'
shell: bash
run: |
df -h "$GITHUB_WORKSPACE"
if [[ "$RUNNER_OS" == "Windows" ]]; then df -h /c; fi
if [[ "${{ steps.setup-bazel-cached.outcome }}" == "failure" ]]; then
echo "::warning::Bazel cache setup failed — fell back to setup without cache"
fi
. ./scripts/github-actions/disk-status.sh
- name: Setup Fluxbox and Xvfb
if: inputs.os == 'ubuntu' && inputs.browser != ''
run: |
Expand All @@ -274,22 +236,13 @@ jobs:
- name: Configure RubyGems credentials via OIDC
if: inputs.gem-trusted-publishing
uses: rubygems/configure-rubygems-credentials@main
- name: Check disk space before build
- name: Disk status before build
if: inputs.os != 'macos'
shell: bash
run: |
df -h "$GITHUB_WORKSPACE"
if [[ "$RUNNER_OS" == "Windows" ]]; then
# On Windows the workspace is on D: but C: is the constrained drive
avail=$(df -k /c | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
echo "Available disk space before build (C:): ${avail}GB"
df -h /c
else
avail=$(df -k "$GITHUB_WORKSPACE" | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
echo "Available disk space before build: ${avail}GB"
fi
if [ "$avail" -lt 10 ]; then
echo "::error::Insufficient disk space: ${avail}GB available (need >=10GB)"
. ./scripts/github-actions/disk-status.sh
if [ "$AVAIL_GB" -lt 10 ]; then
echo "::error::Insufficient disk space: ${AVAIL_GB}GB available (need >=10GB)"
Comment thread
titusfortner marked this conversation as resolved.
exit 1
fi
- name: Run Bazel
Expand Down Expand Up @@ -337,13 +290,11 @@ jobs:
path: ${{ inputs.artifact-path || 'changes.patch' }}
retention-days: 6
if-no-files-found: ${{ inputs.artifact-path != '' && 'error' || 'ignore' }}
- name: Check disk space
- name: Low Disk Warning
if: always()
shell: bash
run: |
avail=$(df -k "$GITHUB_WORKSPACE" | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
echo "Remaining disk space: ${avail}GB"
if [ "$avail" -lt 5 ]; then
echo "::error::Low disk space: ${avail}GB remaining"
exit 1
. ./scripts/github-actions/disk-status.sh
if [ "$AVAIL_GB" -lt 5 ]; then
echo "::warning::Low disk space: ${AVAIL_GB}GB remaining"
fi
58 changes: 58 additions & 0 deletions scripts/github-actions/disk-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
#
# Print a disk-status snapshot for use as a CI checkpoint:
# Also exports AVAIL_GB (available space in GB

echo "=== Disk space ==="
df -h "$GITHUB_WORKSPACE" || true
if [[ "$RUNNER_OS" == "Windows" ]]; then df -h /c || true; fi

# On Windows the workspace is on D: but C: is the constrained drive
if [[ "$RUNNER_OS" == "Windows" ]]; then
AVAIL_GB=$(df -k /c | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
else
AVAIL_GB=$(df -k "$GITHUB_WORKSPACE" | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
fi
if ! [[ "$AVAIL_GB" =~ ^[0-9]+$ ]]; then
echo "::error::Could not determine available disk space (got: '${AVAIL_GB}')"
AVAIL_GB=0
fi
export AVAIL_GB
echo "Available: ${AVAIL_GB}GB"

if [[ "$RUNNER_OS" == "Windows" ]]; then
external="/d/b/external"
repos="/d/b-repo"
bazelisk="/c/Users/runneradmin/AppData/Local/bazelisk"
else
external="$HOME/.bazel/external"
repos="$HOME/.cache/bazel-repo"
bazelisk="$HOME/.cache/bazelisk"
fi

echo "=== Bazel cache sizes ==="
cache_size() {
local label="$1" path="$2"
if [ -d "$path" ]; then
local size
size=$(du -sh "$path" 2>/dev/null | awk '{print $1}')
printf " %-25s %s\n" "${label}:" "$size"
else
printf " %-25s (not present)\n" "${label}:"
fi
}
cache_size "External" "$external"
if [ -d "$repos" ]; then
for sub in "$repos"/*/; do
[ -d "$sub" ] || continue
case "$(basename "$sub")" in
content_addressable) label="Repository Cache" ;;
contents) label="Repo Contents Cache" ;;
*) label="Repository/$(basename "$sub")" ;;
esac
cache_size "$label" "$sub"
done
else
cache_size "Repository Cache" "$repos"
fi
cache_size "Bazelisk" "$bazelisk"
41 changes: 41 additions & 0 deletions scripts/github-actions/free-disk-space.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env pwsh

function FreeBytes { (Get-PSDrive C).Free }

function Clean($Label, $Path) {
if (-not $Path) {
"{0} {1,-13} (path not set, skipping)" -f (Get-Date -Format HH:mm:ss), $Label
return
}
$before = FreeBytes
$t0 = Get-Date
Remove-Item -Path $Path -Recurse -Force -ErrorAction SilentlyContinue
$after = FreeBytes
$duration = [math]::Round((Get-Date).Subtract($t0).TotalSeconds, 0)
$freedMB = [math]::Round(($after - $before) / 1MB, 0)
"{0} {1,-13} {2,3}s {3,5}GB -> {4,5}GB free (freed {5}MB)" -f `
(Get-Date -Format HH:mm:ss), $Label, $duration, `
[math]::Round($before/1GB, 1), [math]::Round($after/1GB, 1), $freedMB
}

Write-Host "=== Disk before cleanup ==="
Get-PSDrive C, D | Format-Table -AutoSize | Out-String | Write-Host
Write-Host
Write-Host "=== Per-step delete (time + free-space delta on C:) ==="

# Pre-installed language toolchains
Clean "miniconda" "C:\Miniconda"
Clean "ghc" "C:\tools\ghc"
Clean "llvm" "C:\Program Files\LLVM"
Clean "postgres" "C:\Program Files\PostgreSQL"
Clean "mongo" "C:\Program Files\MongoDB"
Clean "mysql" "C:\Program Files\MySQL"

# WebDriver binaries (Selenium tests use bazel-pinned drivers)
Clean "chromedriver" $env:ChromeWebDriver
Clean "edgedriver" $env:EdgeWebDriver
Clean "geckodriver" $env:GeckoWebDriver

Write-Host
Write-Host "=== Disk after cleanup ==="
Get-PSDrive C, D | Format-Table -AutoSize | Out-String | Write-Host
61 changes: 61 additions & 0 deletions scripts/github-actions/free-disk-space.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash

set -u

free_mb() { df -BM / | awk 'NR==2 {print $4}' | tr -d 'M'; }

clean() {
local label="$1" path="$2"
local before after t0
if [ -z "$path" ]; then
printf "%s %-13s (path not set, skipping)\n" "$(date +%T)" "$label"
return
fi
before=$(free_mb)
t0=$SECONDS
# shellcheck disable=SC2086 # intentional word-split for globs (julia*)
sudo rm -rf -- $path
after=$(free_mb)
printf "%s %-13s %3ds %3sG -> %3sG free (freed %sM)\n" \
"$(date +%T)" "$label" "$((SECONDS - t0))" \
"$((before / 1024))" "$((after / 1024))" "$((after - before))"
}

echo "=== Disk before cleanup ==="
df -h /
echo
echo "=== Per-step delete (time + free-space delta) ==="

# Pre-installed language toolchains
clean ghc /opt/ghc
clean ghcup /usr/local/.ghcup
clean boost /usr/local/share/boost
clean swift /usr/share/swift
clean julia '/usr/local/julia*'
clean gcloud-sdk /usr/lib/google-cloud-sdk
clean codeql /opt/hostedtoolcache/CodeQL

# App SDKs that Selenium has no binding for
clean android /usr/local/lib/android
clean dotnet /usr/share/dotnet
clean graalvm /usr/local/graalvm
clean powershell /usr/local/share/powershell

# WebDriver binaries (Selenium tests use bazel-pinned drivers)
clean chromedriver "${CHROMEWEBDRIVER:-}"
clean edgedriver "${EDGEWEBDRIVER:-}"
clean geckodriver "${GECKOWEBDRIVER:-}"

# Docker images pre-pulled by the runner image
before=$(free_mb); t0=$SECONDS
docker image prune -af >/dev/null 2>&1 || true
after=$(free_mb)
printf "%s %-13s %3ds %3sG -> %3sG free (freed %sM)\n" \
"$(date +%T)" "docker-images" "$((SECONDS - t0))" \
"$((before / 1024))" "$((after / 1024))" "$((after - before))"

sync

echo
echo "=== Disk after cleanup ==="
df -h /
Loading