|
| 1 | +# Configures a drive for testing in CI. |
| 2 | +# Credits to astral-sh/uv: https://github.com/astral-sh/uv/blob/d2b9ffdc9e3f336e46b0af18a8554de560bfbefc/.github/workflows/setup-dev-drive.ps1 |
| 3 | + |
| 4 | +# When not using a GitHub Actions "larger runner", the `D:` drive is present and |
| 5 | +# has similar or better performance characteristics than a ReFS dev drive. |
| 6 | +# Sometimes using a larger runner is still more performant (e.g., when running |
| 7 | +# the test suite) and we need to create a dev drive. This script automatically |
| 8 | +# configures the appropriate drive. |
| 9 | +if (Test-Path "D:\") { |
| 10 | + Write-Output "Using existing drive at D:" |
| 11 | + $Drive = "D:" |
| 12 | +} else { |
| 13 | + # The size (20 GB) is chosen empirically to be large enough for our |
| 14 | + # workflows; larger drives can take longer to set up. |
| 15 | + $Volume = New-VHD -Path C:\pixi_dev_drive.vhdx -SizeBytes 20GB | |
| 16 | + Mount-VHD -Passthru | |
| 17 | + Initialize-Disk -Passthru | |
| 18 | + New-Partition -AssignDriveLetter -UseMaximumSize | |
| 19 | + Format-Volume -DevDrive -Confirm:$false -Force |
| 20 | + |
| 21 | + $Drive = "$($Volume.DriveLetter):" |
| 22 | + |
| 23 | + # Set the drive as trusted |
| 24 | + # See https://learn.microsoft.com/en-us/windows/dev-drive/#how-do-i-designate-a-dev-drive-as-trusted |
| 25 | + fsutil devdrv trust $Drive |
| 26 | + |
| 27 | + # Disable antivirus filtering on dev drives |
| 28 | + # See https://learn.microsoft.com/en-us/windows/dev-drive/#how-do-i-configure-additional-filters-on-dev-drive |
| 29 | + fsutil devdrv enable /disallowAv |
| 30 | + |
| 31 | + # Remount so the changes take effect |
| 32 | + Dismount-VHD -Path C:\pixi_dev_drive.vhdx |
| 33 | + Mount-VHD -Path C:\pixi_dev_drive.vhdx |
| 34 | + |
| 35 | + # Show some debug information |
| 36 | + Write-Output $Volume |
| 37 | + fsutil devdrv query $Drive |
| 38 | + |
| 39 | + Write-Output "Using Dev Drive at $Volume" |
| 40 | +} |
| 41 | + |
| 42 | +$Tmp = "$($Drive)\pixi-tmp" |
| 43 | + |
| 44 | +# Create the directory ahead of time in an attempt to avoid race-conditions |
| 45 | +New-Item $Tmp -ItemType Directory |
| 46 | + |
| 47 | +# Move Cargo to the dev drive |
| 48 | +New-Item -Path "$($Drive)\.cargo\bin" -ItemType Directory -Force |
| 49 | +if (Test-Path "C:\Users\runneradmin\.cargo") { |
| 50 | + Copy-Item -Path "C:\Users\runneradmin\.cargo\*" -Destination "$($Drive)\.cargo\" -Recurse -Force |
| 51 | +} |
| 52 | + |
| 53 | +Write-Output ` |
| 54 | + "DEV_DRIVE=$($Drive)" ` |
| 55 | + "TMP=$($Tmp)" ` |
| 56 | + "TEMP=$($Tmp)" ` |
| 57 | + "RATTLER_CACHE_DIR=$($Drive)\rattler-cache" ` |
| 58 | + "RUSTUP_HOME=$($Drive)\.rustup" ` |
| 59 | + "CARGO_HOME=$($Drive)\.cargo" ` |
| 60 | + "PIXI_HOME=$($Drive)\.pixi" ` |
| 61 | + "PIXI_WORKSPACE=$($Drive)\pixi" ` |
| 62 | + >> $env:GITHUB_ENV |
0 commit comments