ci: enforce macOS runner disk reserve#4189
Conversation
📝 WalkthroughWalkthroughThe Swift SDK macOS workflow now checks available workspace disk space, conditionally removes generated build artifacts and temporary files, re-checks capacity, and fails early when the minimum reserve is unavailable. ChangesSwift SDK CI
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
⛔ Blockers found — Sonnet deferred (commit c2f0082) |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/swift-sdk-build.yml:
- Around line 30-40: Update the cleanup flow in the Swift SDK workflow to remove
the RUNNER_TEMP deletion entirely, preserving runner-managed files and command
directories. Move the unconditional Xcode DerivedData and Swift package cache
cleanup step before the first free-space calculation, then remove the later
duplicate “Clean Xcode derived data and Swift package caches” step. Keep the
existing threshold-based Rust target and xcframework cleanup behavior after the
accurate disk measurement.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 753bfc03-6780-4503-a967-4c286fc6f7a6
📒 Files selected for processing (1)
.github/workflows/swift-sdk-build.yml
| cleanup_at_kib=$((120 * 1024 * 1024)) | ||
| minimum_free_kib=$((100 * 1024 * 1024)) | ||
| free_before_kib=$(df -Pk "$GITHUB_WORKSPACE" | awk 'NR == 2 { print $4 }') | ||
| free_before_gib=$((free_before_kib / 1024 / 1024)) | ||
|
|
||
| if (( free_before_kib < cleanup_at_kib )); then | ||
| echo "::warning::Only ${free_before_gib}GiB is free; removing generated Swift and Rust build output" | ||
| rm -rf target | ||
| rm -rf packages/swift-sdk/DashSDKFFI.xcframework | ||
| find "$RUNNER_TEMP" -mindepth 1 -delete 2>/dev/null || true | ||
| fi |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Prevent runner corruption and avoid unnecessary cache eviction.
There are two significant issues in this cleanup block:
- Critical: Deleting the contents of
$RUNNER_TEMPis dangerous and will corrupt the GitHub Actions runner state. This directory contains internal runner files, including the currently executing shell script and the_runner_file_commandsdirectory which hosts$GITHUB_ENVand$GITHUB_PATH. If deleted, subsequent steps attempting to export environment variables (such as theVerify protoc and export envstep) will fail with a "No such file or directory" error. - Major (Performance): Xcode DerivedData caches are unconditionally deleted in a later step. Because these large directories remain on disk during this check, they artificially inflate the used space. This can cause the workflow to unnecessarily evict the valuable Rust
target/cache or fail the build entirely.
Recommendation: Remove the $RUNNER_TEMP deletion. Instead, move the unconditional cleanup of Xcode and Swift caches from the later step to before the first disk space calculation. This ensures a safe and accurate measurement of free space before deciding whether to drop the Rust cache.
(Note: Remember to also remove the duplicate Clean Xcode derived data and Swift package caches step on lines 109-114 if you apply this fix.)
🛠️ Proposed fix to accurately clean and measure disk space
- cleanup_at_kib=$((120 * 1024 * 1024))
- minimum_free_kib=$((100 * 1024 * 1024))
- free_before_kib=$(df -Pk "$GITHUB_WORKSPACE" | awk 'NR == 2 { print $4 }')
- free_before_gib=$((free_before_kib / 1024 / 1024))
-
- if (( free_before_kib < cleanup_at_kib )); then
- echo "::warning::Only ${free_before_gib}GiB is free; removing generated Swift and Rust build output"
- rm -rf target
- rm -rf packages/swift-sdk/DashSDKFFI.xcframework
- find "$RUNNER_TEMP" -mindepth 1 -delete 2>/dev/null || true
- fi
+ # Clean unconditionally-deleted caches first to accurately reflect free space
+ rm -rf ~/Library/Developer/Xcode/DerivedData/* || true
+ rm -rf packages/swift-sdk/.build || true
+ rm -rf packages/swift-sdk/SwiftExampleApp/.build || true
+
+ cleanup_at_kib=$((120 * 1024 * 1024))
+ minimum_free_kib=$((100 * 1024 * 1024))
+ free_before_kib=$(df -Pk "$GITHUB_WORKSPACE" | awk 'NR == 2 { print $4 }')
+ free_before_gib=$((free_before_kib / 1024 / 1024))
+
+ if (( free_before_kib < cleanup_at_kib )); then
+ echo "::warning::Only ${free_before_gib}GiB is free; removing generated Swift and Rust build output"
+ rm -rf target
+ rm -rf packages/swift-sdk/DashSDKFFI.xcframework
+ fi🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/swift-sdk-build.yml around lines 30 - 40, Update the
cleanup flow in the Swift SDK workflow to remove the RUNNER_TEMP deletion
entirely, preserving runner-managed files and command directories. Move the
unconditional Xcode DerivedData and Swift package cache cleanup step before the
first free-space calculation, then remove the later duplicate “Clean Xcode
derived data and Swift package caches” step. Keep the existing threshold-based
Rust target and xcframework cleanup behavior after the accurate disk
measurement.
thepastaclaw
left a comment
There was a problem hiding this comment.
Preliminary review — Codex only
The disk-reserve preflight uses appropriate binary-unit thresholds, but it can fail before reclaiming Xcode DerivedData that the workflow already treats as disposable. Move that cleanup into the low-space recovery block so the 100 GiB failure represents an actually unrecoverable runner state.
Validated blockers were found in the Codex precheck. Sonnet is deferred until a fresh Codex revalidation clears the blocker gate.
Review provenance
- Codex reviewers:
gpt-5.6-sol— general (completed) - Verifier:
gpt-5.6-sol— verifier - Sonnet: not run (deferred by blocker gate)
🔴 1 blocking
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `.github/workflows/swift-sdk-build.yml`:
- [BLOCKING] .github/workflows/swift-sdk-build.yml:37-39: Clean DerivedData before declaring the disk reserve unrecoverable
The low-space recovery omits `$HOME/Library/Developer/Xcode/DerivedData`, even though this workflow unconditionally deletes that directory later at lines 109-113. On this self-hosted macOS setup, Xcode DerivedData and the workspace normally reside on the same data volume, and DerivedData can consume enough space to raise the workspace filesystem above the 100 GiB minimum. The preflight currently exits before reaching that existing cleanup, producing an avoidable infrastructure failure. Deleting it in the recovery block is safe because the workflow already discards it before the build, and none of the intervening Rust, cache, or Protobuf setup steps require it.
| rm -rf target | ||
| rm -rf packages/swift-sdk/DashSDKFFI.xcframework | ||
| find "$RUNNER_TEMP" -mindepth 1 -delete 2>/dev/null || true |
There was a problem hiding this comment.
🔴 Blocking: Clean DerivedData before declaring the disk reserve unrecoverable
The low-space recovery omits $HOME/Library/Developer/Xcode/DerivedData, even though this workflow unconditionally deletes that directory later at lines 109-113. On this self-hosted macOS setup, Xcode DerivedData and the workspace normally reside on the same data volume, and DerivedData can consume enough space to raise the workspace filesystem above the 100 GiB minimum. The preflight currently exits before reaching that existing cleanup, producing an avoidable infrastructure failure. Deleting it in the recovery block is safe because the workflow already discards it before the build, and none of the intervening Rust, cache, or Protobuf setup steps require it.
| rm -rf target | |
| rm -rf packages/swift-sdk/DashSDKFFI.xcframework | |
| find "$RUNNER_TEMP" -mindepth 1 -delete 2>/dev/null || true | |
| rm -rf target | |
| rm -rf packages/swift-sdk/DashSDKFFI.xcframework | |
| rm -rf "$HOME/Library/Developer/Xcode/DerivedData"/* || true | |
| find "$RUNNER_TEMP" -mindepth 1 -delete 2>/dev/null || true |
source: ['codex']
Summary
Context
Job 88561517581 failed in rustc/LLVM with ENOSPC while the workflow preserved a large Rust target directory. Host-level idle-only disk guards are now also installed on both self-hosted Macs.
Verification
git diff --checkbash -nSummary by CodeRabbit
Bug Fixes
Chores