| 1 | #!/usr/bin/env bash |
| 2 | # Fixed provisioning for ephemeral GitHub-hosted Ubuntu jobs only. |
| 3 | # Earlier Safety/Lint exit 143 and runner shutdown do not prove OOM or timeout. |
| 4 | # Keep the existing SDK removal, swap size, warning fallback, and diagnostics. |
| 5 | set -euo pipefail |
| 6 | |
| 7 | if [ "${GITHUB_ACTIONS:-}" != true ] || [ "${RUNNER_OS:-}" != Linux ] \ |
| 8 | || [ "${RUNNER_ENVIRONMENT:-}" != github-hosted ]; then |
| 9 | echo "Refusing build-headroom cleanup outside GitHub-hosted Linux CI" >&2 |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | df -h / /mnt; free -m |
| 14 | sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/.ghcup /opt/hostedtoolcache/CodeQL |
| 15 | if sudo fallocate -l 8G /mnt/cw-swapfile && sudo chmod 600 /mnt/cw-swapfile \ |
| 16 | && sudo mkswap /mnt/cw-swapfile >/dev/null && sudo swapon /mnt/cw-swapfile; then |
| 17 | echo "Added 8 GiB swap at /mnt/cw-swapfile" |
| 18 | else |
| 19 | echo "::warning::Could not add swap; continuing with the runner default" |
| 20 | fi |
| 21 | df -h / /mnt; free -m |
| 22 |