From c1d0676d1039e6e478aaf3d46e882b928fb79c61 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 8 Apr 2026 18:47:59 +0200 Subject: [PATCH] ci: Clean workspace members more eagerly This relies on 1.94s --workspace option we've added to cargo --- .github/actions/run_tests/action.yml | 5 +---- .github/workflows/deploy_collab.yml | 2 +- .github/workflows/release.yml | 10 +++++----- .github/workflows/release_nightly.yml | 6 +++--- .github/workflows/run_bundling.yml | 4 ++-- .github/workflows/run_cron_unit_evals.yml | 2 +- .github/workflows/run_tests.yml | 6 +++--- .github/workflows/run_unit_evals.yml | 2 +- script/clear-target-dir-if-larger-than | 13 +++++++++++-- script/clear-target-dir-if-larger-than.ps1 | 12 +++++++++++- tooling/xtask/src/tasks/workflows/steps.rs | 6 +++--- 11 files changed, 42 insertions(+), 26 deletions(-) diff --git a/.github/actions/run_tests/action.yml b/.github/actions/run_tests/action.yml index 610c334a65c3a3817ab0ee2bb7356a923643092b..9448dfebb0e1a2d50fb308e051b80fbefd63b680 100644 --- a/.github/actions/run_tests/action.yml +++ b/.github/actions/run_tests/action.yml @@ -13,11 +13,8 @@ runs: node-version: "18" - name: Limit target directory size - env: - MAX_SIZE: ${{ runner.os == 'macOS' && 300 || 100 }} shell: bash -euxo pipefail {0} - # Use the variable in the run command - run: script/clear-target-dir-if-larger-than ${{ env.MAX_SIZE }} + run: script/clear-target-dir-if-larger-than 350 200 - name: Run tests shell: bash -euxo pipefail {0} diff --git a/.github/workflows/deploy_collab.yml b/.github/workflows/deploy_collab.yml index 5a3eff186814128ebb3973642040d9228f0e87fd..b689f303365ccff5f913f4a7a701103264e82990 100644 --- a/.github/workflows/deploy_collab.yml +++ b/.github/workflows/deploy_collab.yml @@ -68,7 +68,7 @@ jobs: - name: steps::cargo_install_nextest uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 250 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: deploy_collab::tests::run_collab_tests run: cargo nextest run --package collab --no-fail-fast services: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f20f64c7a54151fedcd3b4e36b4dc492578b827d..2372655c2065ceaa7ddb0e17a271f1ee6c47ff92 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: - name: steps::cargo_install_nextest uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 300 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: steps::setup_sccache run: ./script/setup-sccache env: @@ -83,7 +83,7 @@ jobs: - name: steps::cargo_install_nextest uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 250 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: steps::setup_sccache run: ./script/setup-sccache env: @@ -126,7 +126,7 @@ jobs: with: node-version: '20' - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than.ps1 250 + run: ./script/clear-target-dir-if-larger-than.ps1 350 200 shell: pwsh - name: steps::setup_sccache run: ./script/setup-sccache.ps1 @@ -456,7 +456,7 @@ jobs: with: token: ${{ secrets.SENTRY_AUTH_TOKEN }} - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 300 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: run_bundling::bundle_mac::bundle_mac run: ./script/bundle-mac aarch64-apple-darwin - name: '@actions/upload-artifact Zed-aarch64.dmg' @@ -501,7 +501,7 @@ jobs: with: token: ${{ secrets.SENTRY_AUTH_TOKEN }} - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 300 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: run_bundling::bundle_mac::bundle_mac run: ./script/bundle-mac x86_64-apple-darwin - name: '@actions/upload-artifact Zed-x86_64.dmg' diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml index 30d0e1fbf9c7955d1216e2e3d7ac51a9a51f4416..1adb283cc25796300be2a0ad348e0a08724371d2 100644 --- a/.github/workflows/release_nightly.yml +++ b/.github/workflows/release_nightly.yml @@ -43,7 +43,7 @@ jobs: with: node-version: '20' - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than.ps1 250 + run: ./script/clear-target-dir-if-larger-than.ps1 350 200 shell: pwsh - name: steps::setup_sccache run: ./script/setup-sccache.ps1 @@ -220,7 +220,7 @@ jobs: with: token: ${{ secrets.SENTRY_AUTH_TOKEN }} - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 300 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: run_bundling::bundle_mac::bundle_mac run: ./script/bundle-mac aarch64-apple-darwin - name: '@actions/upload-artifact Zed-aarch64.dmg' @@ -271,7 +271,7 @@ jobs: with: token: ${{ secrets.SENTRY_AUTH_TOKEN }} - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 300 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: run_bundling::bundle_mac::bundle_mac run: ./script/bundle-mac x86_64-apple-darwin - name: '@actions/upload-artifact Zed-x86_64.dmg' diff --git a/.github/workflows/run_bundling.yml b/.github/workflows/run_bundling.yml index 71b2e4d5fa0b386334bb8acab8e732f1c7d0ad93..05a951588bf6ca19d9ac45262722868a7011c8c1 100644 --- a/.github/workflows/run_bundling.yml +++ b/.github/workflows/run_bundling.yml @@ -116,7 +116,7 @@ jobs: with: token: ${{ secrets.SENTRY_AUTH_TOKEN }} - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 300 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: run_bundling::bundle_mac::bundle_mac run: ./script/bundle-mac aarch64-apple-darwin - name: '@actions/upload-artifact Zed-aarch64.dmg' @@ -160,7 +160,7 @@ jobs: with: token: ${{ secrets.SENTRY_AUTH_TOKEN }} - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 300 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: run_bundling::bundle_mac::bundle_mac run: ./script/bundle-mac x86_64-apple-darwin - name: '@actions/upload-artifact Zed-x86_64.dmg' diff --git a/.github/workflows/run_cron_unit_evals.yml b/.github/workflows/run_cron_unit_evals.yml index 7bb7f79473eb4dae170eb18edd454b7ae35d13e8..7cc0d40760a74bd0c76645e6d536e7140b403c85 100644 --- a/.github/workflows/run_cron_unit_evals.yml +++ b/.github/workflows/run_cron_unit_evals.yml @@ -40,7 +40,7 @@ jobs: - name: steps::cargo_install_nextest uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 250 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: steps::setup_sccache run: ./script/setup-sccache env: diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 13d036b128666700d45ae39013b2dd8f3da5abf9..ce7b789731b8185fee36cb23a7c36371a986e7fb 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -324,7 +324,7 @@ jobs: with: node-version: '20' - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than.ps1 250 + run: ./script/clear-target-dir-if-larger-than.ps1 350 200 shell: pwsh - name: steps::setup_sccache run: ./script/setup-sccache.ps1 @@ -379,7 +379,7 @@ jobs: - name: steps::cargo_install_nextest uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 250 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: steps::setup_sccache run: ./script/setup-sccache env: @@ -430,7 +430,7 @@ jobs: - name: steps::cargo_install_nextest uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 300 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: steps::setup_sccache run: ./script/setup-sccache env: diff --git a/.github/workflows/run_unit_evals.yml b/.github/workflows/run_unit_evals.yml index 1bf75188832668f40a24c4d3452940bf05fcd3fd..4b70d15012cd0344e3629084c2b58d3a37436131 100644 --- a/.github/workflows/run_unit_evals.yml +++ b/.github/workflows/run_unit_evals.yml @@ -43,7 +43,7 @@ jobs: - name: steps::cargo_install_nextest uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c - name: steps::clear_target_dir_if_large - run: ./script/clear-target-dir-if-larger-than 250 + run: ./script/clear-target-dir-if-larger-than 350 200 - name: steps::setup_sccache run: ./script/setup-sccache env: diff --git a/script/clear-target-dir-if-larger-than b/script/clear-target-dir-if-larger-than index 6041c0f5be00946a78b7659b1e08b8d57e2e4e36..0949cef4acd6dc25c7b2ac053c6efb2dfc0dd898 100755 --- a/script/clear-target-dir-if-larger-than +++ b/script/clear-target-dir-if-larger-than @@ -2,8 +2,8 @@ set -euxo pipefail -if [[ $# -ne 1 ]]; then - echo "usage: $0 " +if [[ $# -lt 1 || $# -gt 2 ]]; then + echo "usage: $0 [SMALL_CLEAN_SIZE_IN_GB]" exit 1 fi @@ -13,6 +13,12 @@ if ! [[ -d target ]]; then fi max_size_gb=$1 +small_clean_size_gb=${2:-} + +if [[ -n "${small_clean_size_gb}" && ${small_clean_size_gb} -ge ${max_size_gb} ]]; then + echo "error: small clean threshold (${small_clean_size_gb}gb) must be smaller than max size (${max_size_gb}gb)" + exit 1 +fi current_size=$(du -s target | cut -f1) current_size_gb=$(( ${current_size} / 1024 / 1024 )) @@ -23,4 +29,7 @@ if [[ ${current_size_gb} -gt ${max_size_gb} ]]; then echo "clearing target directory" shopt -s dotglob rm -rf target/* +elif [[ -n "${small_clean_size_gb}" && ${current_size_gb} -gt ${small_clean_size_gb} ]]; then + echo "running cargo clean --workspace (size above small clean threshold of ${small_clean_size_gb}gb)" + cargo clean --workspace fi diff --git a/script/clear-target-dir-if-larger-than.ps1 b/script/clear-target-dir-if-larger-than.ps1 index c18c308624d93937d88392ef519f331afced8077..a5a32a03eb74d85e458177644852d840a8baab5e 100644 --- a/script/clear-target-dir-if-larger-than.ps1 +++ b/script/clear-target-dir-if-larger-than.ps1 @@ -1,6 +1,8 @@ param ( [Parameter(Mandatory = $true)] - [int]$MAX_SIZE_IN_GB + [int]$MAX_SIZE_IN_GB, + [Parameter(Mandatory = $false)] + [int]$SMALL_CLEAN_SIZE_IN_GB = -1 ) $ErrorActionPreference = "Stop" @@ -12,6 +14,11 @@ if (-Not (Test-Path -Path "target")) { exit 0 } +if ($SMALL_CLEAN_SIZE_IN_GB -ge 0 -and $SMALL_CLEAN_SIZE_IN_GB -ge $MAX_SIZE_IN_GB) { + Write-Host "error: small clean threshold (${SMALL_CLEAN_SIZE_IN_GB}GB) must be smaller than max size (${MAX_SIZE_IN_GB}GB)" + exit 1 +} + $current_size_gb = (Get-ChildItem -Recurse -Force -File -Path "target" | Measure-Object -Property Length -Sum).Sum / 1GB Write-Host "target directory size: ${current_size_gb}GB. max size: ${MAX_SIZE_IN_GB}GB" @@ -19,4 +26,7 @@ Write-Host "target directory size: ${current_size_gb}GB. max size: ${MAX_SIZE_IN if ($current_size_gb -gt $MAX_SIZE_IN_GB) { Write-Host "clearing target directory" Remove-Item -Recurse -Force -Path "target\*" -ErrorAction SilentlyContinue +} elseif ($SMALL_CLEAN_SIZE_IN_GB -ge 0 -and $current_size_gb -gt $SMALL_CLEAN_SIZE_IN_GB) { + Write-Host "running cargo clean --workspace (size above small clean threshold of ${SMALL_CLEAN_SIZE_IN_GB}GB)" + cargo clean --workspace } diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index 15c2614ada81dd7c2e772f52c7072dac4324d1dc..81543444ff67b9bb210cd6138eed3d263c89f6d4 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -213,9 +213,9 @@ pub fn cleanup_cargo_config(platform: Platform) -> Step { pub fn clear_target_dir_if_large(platform: Platform) -> Step { match platform { - Platform::Windows => named::pwsh("./script/clear-target-dir-if-larger-than.ps1 250"), - Platform::Linux => named::bash("./script/clear-target-dir-if-larger-than 250"), - Platform::Mac => named::bash("./script/clear-target-dir-if-larger-than 300"), + Platform::Windows => named::pwsh("./script/clear-target-dir-if-larger-than.ps1 350 200"), + Platform::Linux => named::bash("./script/clear-target-dir-if-larger-than 350 200"), + Platform::Mac => named::bash("./script/clear-target-dir-if-larger-than 350 200"), } }