Skip to content

Commit 7dd9df5

Browse files
committed
Add dev drive as well
1 parent 8d6f22a commit 7dd9df5

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ jobs:
193193

194194
- run: winget install -e --id TortoiseSVN.TortoiseSVN --accept-package-agreements --accept-source-agreements
195195

196-
# We use C:\Temp (which is already available on the worker)
197-
# as a temporary directory for all of the tests because the
198-
# default value (under the user dir) is more deeply nested
199-
# and causes tests to fail with "path too long" errors.
196+
- name: Create a Dev Drive
197+
run: |
198+
./tools/ci/devdrive.ps1 -Drive R -Size 5GB
199+
mkdir R:\Temp
200+
echo "TEMP=R:\\Temp" >> $env:GITHUB_ENV
201+
200202
- run: pip install nox
201-
env:
202-
TEMP: "C:\\Temp"
203203

204204
# Main check
205205
- name: Run unit tests
@@ -208,26 +208,20 @@ jobs:
208208
nox -s test-${{ matrix.python }} --
209209
-m unit
210210
--verbose --numprocesses auto --showlocals
211-
env:
212-
TEMP: "C:\\Temp"
213211
214212
- name: Run integration tests (group 1)
215213
if: matrix.group == 1
216214
run: >-
217215
nox -s test-${{ matrix.python }} --
218216
-m integration -k "not test_install"
219217
--verbose --numprocesses auto --showlocals
220-
env:
221-
TEMP: "C:\\Temp"
222218
223219
- name: Run integration tests (group 2)
224220
if: matrix.group == 2
225221
run: >-
226222
nox -s test-${{ matrix.python }} --
227223
-m integration -k "test_install"
228224
--verbose --numprocesses auto --showlocals
229-
env:
230-
TEMP: "C:\\Temp"
231225
232226
tests-zipapp:
233227
name: tests / zipapp

tools/ci/devdrive.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# A Powershell script to create a Dev Drive which tends to have significantly better
2+
# performance in developer workloads. The goal is improve pip's Windows CI times.
3+
#
4+
# The implementation was borrowed from the uv project which also use a Dev Drive for
5+
# better CI performance: https://github.com/astral-sh/uv/pull/3522
6+
#
7+
# Windows docs:
8+
# https://learn.microsoft.com/en-us/windows/dev-drive/
9+
# Related GHA reports:
10+
# https://github.com/actions/runner-images/issues/7320 (Windows slowness report)
11+
# https://github.com/actions/runner-images/issues/8698 (feature request for
12+
# preprovisioned Dev Drives)
13+
14+
[CmdletBinding()]
15+
param(
16+
[Parameter(Mandatory=$true,
17+
HelpMessage="Drive letter to use for the Dev Drive")]
18+
[String]$drive,
19+
[Parameter(Mandatory=$true,
20+
HelpMessage="Size to allocate to the Dev Drive")]
21+
[UInt64]$size
22+
)
23+
$ErrorActionPreference = "Stop"
24+
25+
$OSVersion = [Environment]::OSVersion.Version
26+
$Partition = New-VHD -Path C:/pip_dev_drive.vhdx -SizeBytes $size |
27+
Mount-VHD -Passthru |
28+
Initialize-Disk -Passthru |
29+
New-Partition -DriveLetter $drive -UseMaximumSize
30+
# Dev Drives aren't supported on all GHA Windows runners, in which case fallback to
31+
# a ReFS disk which still offer performance gains.
32+
if ($OSVersion -ge (New-Object 'Version' 10.0.22621)) {
33+
Write-Output "Dev Drives are supported, one will be created at ${drive}:"
34+
$Volume = ($Partition | Format-Volume -DevDrive -Confirm:$false -Force)
35+
} else {
36+
Write-Output "Dev Drives are unsupported, only creating a ReFS disk at ${drive}:"
37+
$Volume = ($Partition | Format-Volume -FileSystem ReFS -Confirm:$false -Force)
38+
}
39+
Write-Output $Volume

0 commit comments

Comments
 (0)