From 896435faececb5817ed1848589eac882a3c49f85 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 17 Jan 2025 13:57:09 -0600 Subject: [PATCH] Use `D:` drive for Windows CI (#10180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using the standard Windows runners (as opposed to the _larger_ GitHub runners), an undocumented `D:` drive is available and performant. We can save some money on by using this on a standard runner instead of a larger runner with an ReFS drive. Switching to the `D:` drive was not acceptable for `cargo test` >25m runtime. Inspired by https://github.com/pypa/pip/pull/13129 See https://github.com/actions/runner-images/issues/8755 Timings (grain of salt — GitHub is super noisy): - clippy: 2m 18s -> 2m 11s - build binary: 2m 3s -> 2m 35s - trampoline check (x86-64): 2m 32s -> 1m 50s (other architectures similar) - trampoline test (x86-64): 4m 12s -> 6m 7s - trampoline test (i686): 6m 44s -> 5m 35s --- .github/workflows/ci.yml | 6 +-- .github/workflows/setup-dev-drive.ps1 | 60 +++++++++++++++++---------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65a5bdcbb..3af157915 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: timeout-minutes: 15 needs: determine_changes if: ${{ github.repository == 'astral-sh/uv' && !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} - runs-on: github-windows-2025-x86_64-16 + runs-on: windows-latest name: "cargo clippy | windows" steps: - uses: actions/checkout@v4 @@ -324,7 +324,7 @@ jobs: timeout-minutes: 15 needs: determine_changes if: ${{ github.repository == 'astral-sh/uv' && !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} - runs-on: github-windows-2025-x86_64-16 + runs-on: windows-latest name: "check windows trampoline | ${{ matrix.target-arch }}" strategy: fail-fast: false @@ -517,7 +517,7 @@ jobs: needs: determine_changes timeout-minutes: 10 if: ${{ github.repository == 'astral-sh/uv' && !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} - runs-on: github-windows-2025-x86_64-8 + runs-on: windows-latest name: "build binary | windows" steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/setup-dev-drive.ps1 b/.github/workflows/setup-dev-drive.ps1 index bbb0db75c..53a16a018 100644 --- a/.github/workflows/setup-dev-drive.ps1 +++ b/.github/workflows/setup-dev-drive.ps1 @@ -1,32 +1,46 @@ -# This creates a 20GB dev drive, and exports all required environment -# variables so that rustup, uv and others all use the dev drive as much -# as possible. -$Volume = New-VHD -Path C:/uv_dev_drive.vhdx -SizeBytes 20GB | - Mount-VHD -Passthru | - Initialize-Disk -Passthru | - New-Partition -AssignDriveLetter -UseMaximumSize | - Format-Volume -DevDrive -Confirm:$false -Force +# Configures a drive for testing in CI. -$Drive = "$($Volume.DriveLetter):" +# When not using a GitHub Actions "larger runner", the `D:` drive is present and +# has similar or better performance characteristics than a ReFS dev drive. +# Sometimes using a larger runner is still more performant (e.g., when running +# the test suite) and we need to create a dev drive. This script automatically +# configures the appropriate drive. -# Set the drive as trusted -# See https://learn.microsoft.com/en-us/windows/dev-drive/#how-do-i-designate-a-dev-drive-as-trusted -fsutil devdrv trust $Drive +# Note we use `Get-PSDrive` is not sufficient because the drive letter is assigned. +if (Test-Path "D:\") { + Write-Output "Using existing drive at D:" + $Drive = "D:" +} else { + # The size (20 GB) is chosen empirically to be large enough for our + # workflows; larger drives can take longer to set up. + $Volume = New-VHD -Path C:/uv_dev_drive.vhdx -SizeBytes 20GB | + Mount-VHD -Passthru | + Initialize-Disk -Passthru | + New-Partition -AssignDriveLetter -UseMaximumSize | + Format-Volume -DevDrive -Confirm:$false -Force -# Disable antivirus filtering on dev drives -# See https://learn.microsoft.com/en-us/windows/dev-drive/#how-do-i-configure-additional-filters-on-dev-drive -fsutil devdrv enable /disallowAv + $Drive = "$($Volume.DriveLetter):" -# Remount so the changes take effect -Dismount-VHD -Path C:/uv_dev_drive.vhdx -Mount-VHD -Path C:/uv_dev_drive.vhdx + # Set the drive as trusted + # See https://learn.microsoft.com/en-us/windows/dev-drive/#how-do-i-designate-a-dev-drive-as-trusted + fsutil devdrv trust $Drive -# Show some debug information -Write-Output $Volume -fsutil devdrv query $Drive + # Disable antivirus filtering on dev drives + # See https://learn.microsoft.com/en-us/windows/dev-drive/#how-do-i-configure-additional-filters-on-dev-drive + fsutil devdrv enable /disallowAv -# Configure a temporary directory -$Tmp = "$($Drive)/uv-tmp" + # Remount so the changes take effect + Dismount-VHD -Path C:/uv_dev_drive.vhdx + Mount-VHD -Path C:/uv_dev_drive.vhdx + + # Show some debug information + Write-Output $Volume + fsutil devdrv query $Drive + + Write-Output "Using Dev Drive at $Volume" +} + +$Tmp = "$($Drive)\uv-tmp" # Create the directory ahead of time in an attempt to avoid race-conditions New-Item $Tmp -ItemType Directory