Skip to content

feat(actions): per-ecosystem free-disk-space actions for hosted runners - #4

Merged
goastler merged 3 commits into
mainfrom
ci/free-disk-space-actions
Aug 12, 2026
Merged

feat(actions): per-ecosystem free-disk-space actions for hosted runners#4
goastler merged 3 commits into
mainfrom
ci/free-disk-space-actions

Conversation

@goastler

Copy link
Copy Markdown
Member

GitHub-hosted runners ship with ~30 GB of preinstalled toolchains and only ~14 GB free. That is what killed Protect#410 on hosted: aws-lc-sys failed with ar: … No space left on device in a PR that contained no Rust at all.

jlumbroso/free-disk-space is the usual answer, but it is monolithic — you either take all of its deletions or configure it with a wall of booleans, and the ones you don't need still cost minutes (the apt purge alone is slow). Here each ecosystem is its own composite action, so a workflow asks for exactly what it can spare:

action reclaims
free_disk_space_android /usr/local/lib/android — ~9 GB
free_disk_space_tool_cache /opt/hostedtoolcache — ~10 GB
free_disk_space_haskell /opt/ghc, .ghcup, CodeQL — ~5 GB
free_disk_space_docker all preloaded images — ~4 GB
free_disk_space_swap the swap file — ~4 GB
free_disk_space_dotnet /usr/share/dotnet — ~2 GB
free_disk_space_swift /usr/share/swift — ~2 GB
free_disk_space_apt LLVM, browsers, DBs, cloud CLIs

Each prints freed MB and remaining GB so a workflow that later hits ENOSPC has the numbers in its log.

Every step is guarded on runner.environment != 'self-hosted'. The fleet is non-ephemeral, so a deletion there is permanent and hits every later job on that host. The guard sits in the action rather than in the caller so it cannot be forgotten.

Two caveats, both documented inline: tool_cache must run before any actions/setup-* step or the version it wants is re-downloaded, and docker prunes every image, so it belongs before anything is built or pulled.

goastler added 2 commits June 17, 2026 01:34
Add a separate node_modules cache (exact lockfile-hash key, no fuzzy
fallback) to restore_npm_cache/save_npm_cache, and skip 'npm ci' in the
npm action on an exact hit. 'npm ci' wipes node_modules and reinstalls,
so caching it only pays off paired with skipping the reinstall, saving
~2 min per run when the lockfile is unchanged. A miss falls back to
'npm ci', so it is always safe.
@goastler
goastler merged commit 67e3317 into main Aug 12, 2026
1 check passed
@goastler
goastler deleted the ci/free-disk-space-actions branch August 12, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant