ci: Clean workspace members more eagerly (#53427)

This relies on 1.94s --workspace option we've added to cargo

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2026-04-09 00:21:02 +02:00 committed by GitHub
parent 2169ebaf4b
commit c69a91baf8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 42 additions and 26 deletions

View file

@ -13,11 +13,8 @@ runs:
node-version: "18" node-version: "18"
- name: Limit target directory size - name: Limit target directory size
env:
MAX_SIZE: ${{ runner.os == 'macOS' && 300 || 100 }}
shell: bash -euxo pipefail {0} shell: bash -euxo pipefail {0}
# Use the variable in the run command run: script/clear-target-dir-if-larger-than 350 200
run: script/clear-target-dir-if-larger-than ${{ env.MAX_SIZE }}
- name: Run tests - name: Run tests
shell: bash -euxo pipefail {0} shell: bash -euxo pipefail {0}

View file

@ -68,7 +68,7 @@ jobs:
- name: steps::cargo_install_nextest - name: steps::cargo_install_nextest
uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
- name: steps::clear_target_dir_if_large - 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 - name: deploy_collab::tests::run_collab_tests
run: cargo nextest run --package collab --no-fail-fast run: cargo nextest run --package collab --no-fail-fast
services: services:

View file

@ -33,7 +33,7 @@ jobs:
- name: steps::cargo_install_nextest - name: steps::cargo_install_nextest
uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
- name: steps::clear_target_dir_if_large - 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 - name: steps::setup_sccache
run: ./script/setup-sccache run: ./script/setup-sccache
env: env:
@ -83,7 +83,7 @@ jobs:
- name: steps::cargo_install_nextest - name: steps::cargo_install_nextest
uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
- name: steps::clear_target_dir_if_large - 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 - name: steps::setup_sccache
run: ./script/setup-sccache run: ./script/setup-sccache
env: env:
@ -126,7 +126,7 @@ jobs:
with: with:
node-version: '20' node-version: '20'
- name: steps::clear_target_dir_if_large - 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 shell: pwsh
- name: steps::setup_sccache - name: steps::setup_sccache
run: ./script/setup-sccache.ps1 run: ./script/setup-sccache.ps1
@ -452,7 +452,7 @@ jobs:
with: with:
token: ${{ secrets.SENTRY_AUTH_TOKEN }} token: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: steps::clear_target_dir_if_large - 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 - name: run_bundling::bundle_mac::bundle_mac
run: ./script/bundle-mac aarch64-apple-darwin run: ./script/bundle-mac aarch64-apple-darwin
- name: '@actions/upload-artifact Zed-aarch64.dmg' - name: '@actions/upload-artifact Zed-aarch64.dmg'
@ -497,7 +497,7 @@ jobs:
with: with:
token: ${{ secrets.SENTRY_AUTH_TOKEN }} token: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: steps::clear_target_dir_if_large - 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 - name: run_bundling::bundle_mac::bundle_mac
run: ./script/bundle-mac x86_64-apple-darwin run: ./script/bundle-mac x86_64-apple-darwin
- name: '@actions/upload-artifact Zed-x86_64.dmg' - name: '@actions/upload-artifact Zed-x86_64.dmg'

View file

@ -43,7 +43,7 @@ jobs:
with: with:
node-version: '20' node-version: '20'
- name: steps::clear_target_dir_if_large - 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 shell: pwsh
- name: steps::setup_sccache - name: steps::setup_sccache
run: ./script/setup-sccache.ps1 run: ./script/setup-sccache.ps1
@ -220,7 +220,7 @@ jobs:
with: with:
token: ${{ secrets.SENTRY_AUTH_TOKEN }} token: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: steps::clear_target_dir_if_large - 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 - name: run_bundling::bundle_mac::bundle_mac
run: ./script/bundle-mac aarch64-apple-darwin run: ./script/bundle-mac aarch64-apple-darwin
- name: '@actions/upload-artifact Zed-aarch64.dmg' - name: '@actions/upload-artifact Zed-aarch64.dmg'
@ -271,7 +271,7 @@ jobs:
with: with:
token: ${{ secrets.SENTRY_AUTH_TOKEN }} token: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: steps::clear_target_dir_if_large - 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 - name: run_bundling::bundle_mac::bundle_mac
run: ./script/bundle-mac x86_64-apple-darwin run: ./script/bundle-mac x86_64-apple-darwin
- name: '@actions/upload-artifact Zed-x86_64.dmg' - name: '@actions/upload-artifact Zed-x86_64.dmg'

View file

@ -116,7 +116,7 @@ jobs:
with: with:
token: ${{ secrets.SENTRY_AUTH_TOKEN }} token: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: steps::clear_target_dir_if_large - 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 - name: run_bundling::bundle_mac::bundle_mac
run: ./script/bundle-mac aarch64-apple-darwin run: ./script/bundle-mac aarch64-apple-darwin
- name: '@actions/upload-artifact Zed-aarch64.dmg' - name: '@actions/upload-artifact Zed-aarch64.dmg'
@ -160,7 +160,7 @@ jobs:
with: with:
token: ${{ secrets.SENTRY_AUTH_TOKEN }} token: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: steps::clear_target_dir_if_large - 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 - name: run_bundling::bundle_mac::bundle_mac
run: ./script/bundle-mac x86_64-apple-darwin run: ./script/bundle-mac x86_64-apple-darwin
- name: '@actions/upload-artifact Zed-x86_64.dmg' - name: '@actions/upload-artifact Zed-x86_64.dmg'

View file

@ -40,7 +40,7 @@ jobs:
- name: steps::cargo_install_nextest - name: steps::cargo_install_nextest
uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
- name: steps::clear_target_dir_if_large - 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 - name: steps::setup_sccache
run: ./script/setup-sccache run: ./script/setup-sccache
env: env:

View file

@ -324,7 +324,7 @@ jobs:
with: with:
node-version: '20' node-version: '20'
- name: steps::clear_target_dir_if_large - 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 shell: pwsh
- name: steps::setup_sccache - name: steps::setup_sccache
run: ./script/setup-sccache.ps1 run: ./script/setup-sccache.ps1
@ -379,7 +379,7 @@ jobs:
- name: steps::cargo_install_nextest - name: steps::cargo_install_nextest
uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
- name: steps::clear_target_dir_if_large - 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 - name: steps::setup_sccache
run: ./script/setup-sccache run: ./script/setup-sccache
env: env:
@ -430,7 +430,7 @@ jobs:
- name: steps::cargo_install_nextest - name: steps::cargo_install_nextest
uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
- name: steps::clear_target_dir_if_large - 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 - name: steps::setup_sccache
run: ./script/setup-sccache run: ./script/setup-sccache
env: env:

View file

@ -43,7 +43,7 @@ jobs:
- name: steps::cargo_install_nextest - name: steps::cargo_install_nextest
uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c uses: taiki-e/install-action@921e2c9f7148d7ba14cd819f417db338f63e733c
- name: steps::clear_target_dir_if_large - 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 - name: steps::setup_sccache
run: ./script/setup-sccache run: ./script/setup-sccache
env: env:

View file

@ -2,8 +2,8 @@
set -euxo pipefail set -euxo pipefail
if [[ $# -ne 1 ]]; then if [[ $# -lt 1 || $# -gt 2 ]]; then
echo "usage: $0 <MAX_SIZE_IN_GB>" echo "usage: $0 <MAX_SIZE_IN_GB> [SMALL_CLEAN_SIZE_IN_GB]"
exit 1 exit 1
fi fi
@ -13,6 +13,12 @@ if ! [[ -d target ]]; then
fi fi
max_size_gb=$1 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=$(du -s target | cut -f1)
current_size_gb=$(( ${current_size} / 1024 / 1024 )) current_size_gb=$(( ${current_size} / 1024 / 1024 ))
@ -23,4 +29,7 @@ if [[ ${current_size_gb} -gt ${max_size_gb} ]]; then
echo "clearing target directory" echo "clearing target directory"
shopt -s dotglob shopt -s dotglob
rm -rf target/* 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 fi

View file

@ -1,6 +1,8 @@
param ( param (
[Parameter(Mandatory = $true)] [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" $ErrorActionPreference = "Stop"
@ -12,6 +14,11 @@ if (-Not (Test-Path -Path "target")) {
exit 0 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 $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" 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) { if ($current_size_gb -gt $MAX_SIZE_IN_GB) {
Write-Host "clearing target directory" Write-Host "clearing target directory"
Remove-Item -Recurse -Force -Path "target\*" -ErrorAction SilentlyContinue 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
} }

View file

@ -213,9 +213,9 @@ pub fn cleanup_cargo_config(platform: Platform) -> Step<Run> {
pub fn clear_target_dir_if_large(platform: Platform) -> Step<Run> { pub fn clear_target_dir_if_large(platform: Platform) -> Step<Run> {
match platform { match platform {
Platform::Windows => named::pwsh("./script/clear-target-dir-if-larger-than.ps1 250"), 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 250"), Platform::Linux => named::bash("./script/clear-target-dir-if-larger-than 350 200"),
Platform::Mac => named::bash("./script/clear-target-dir-if-larger-than 300"), Platform::Mac => named::bash("./script/clear-target-dir-if-larger-than 350 200"),
} }
} }