Skip to content

Commit 0ece9ab

Browse files
authored
Automatically start Windows ARM64 VM (#345)
1 parent 9737ad3 commit 0ece9ab

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

windows-release/azure-pipelines.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ parameters:
6363
type: boolean
6464
default: true
6565
- name: DoPGOARM64
66-
displayName: "Run ARM64 PGO (requires custom VM)"
66+
displayName: "Run ARM64 PGO"
6767
type: boolean
6868
default: true
6969
- name: DoLayout
@@ -163,6 +163,10 @@ stages:
163163
pool:
164164
vmImage: ${{ parameters.vmImage }}
165165
jobs:
166+
- template: start-arm64vm.yml
167+
parameters:
168+
DoARM64: ${{ parameters.DoARM64 }}
169+
DoPGOARM64: ${{ parameters.DoPGOARM64 }}
166170
- template: stage-build.yml
167171
parameters:
168172
DoFreethreaded: ${{ parameters.DoFreethreaded }}

windows-release/stage-build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ parameters:
1010
jobs:
1111
- job: Build_Docs
1212
displayName: Docs build
13+
dependsOn: []
1314

1415
workspace:
1516
clean: all
@@ -37,6 +38,7 @@ jobs:
3738

3839
- job: Build_Python
3940
displayName: Python build
41+
dependsOn: []
4042

4143
workspace:
4244
clean: all
@@ -170,6 +172,7 @@ jobs:
170172
- ${{ if eq(parameters.DoPGO, 'true') }}:
171173
- job: Build_Python_PGO_Native
172174
displayName: Python PGO build
175+
dependsOn: []
173176

174177
workspace:
175178
clean: all
@@ -210,6 +213,7 @@ jobs:
210213
- ${{ if eq(parameters.DoPGOARM64, 'true') }}:
211214
- job: Build_Python_PGO_1
212215
displayName: Python PGO build
216+
dependsOn: []
213217

214218
workspace:
215219
clean: all
@@ -324,6 +328,7 @@ jobs:
324328

325329
- job: TclTk_Lib
326330
displayName: Publish Tcl/Tk Library
331+
dependsOn: []
327332

328333
variables:
329334
IncludeLLVM: false

windows-release/start-arm64vm.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
parameters:
2+
DoARM64: false
3+
DoPGOARM64: false
4+
5+
jobs:
6+
# Only include the job if we need the VM, which means ARM64 PGO.
7+
- ${{ if eq(parameters.DoPGOARM64, 'true') }}:
8+
- job: Start_ARM64VM
9+
displayName: 'Ensure ARM64 VM is running'
10+
dependsOn: []
11+
12+
steps:
13+
- checkout: none
14+
15+
- task: AzureCLI@2
16+
displayName: 'Start pythonarm64 and set auto-shutdown to (UTC now - 1h)'
17+
inputs:
18+
azureSubscription: "Steve's VM" # WIF service connection name
19+
scriptType: pscore
20+
scriptLocation: inlineScript
21+
inlineScript: |
22+
$ErrorActionPreference = 'Stop'
23+
24+
$rg = 'cpythonbuild'
25+
$vm = 'pythonarm64'
26+
27+
# Compute UTC time minus 12 hours, format HHmm (e.g. 1830)
28+
$shutdownTime = (Get-Date).ToUniversalTime().AddHours(-12).ToString('HHmm')
29+
Write-Host "Setting auto-shutdown time to: $shutdownTime UTC"
30+
31+
# Configure daily auto-shutdown in 12 hours
32+
az vm auto-shutdown -g $rg -n $vm --time $shutdownTime | Out-Null
33+
if ($?) {
34+
Write-Host "Successfully configured auto-shutdown for ARM64 VM in 12 hours."
35+
} else {
36+
Write-Host "##[warning]Failed to configure ARM64 VM auto-shutdown."
37+
}
38+
39+
# Start VM, but don't fail if it's already running
40+
az vm start -g $rg -n $vm | Out-Null
41+
$u = "https://dev.azure.com/Python/cpython/_settings/agentqueues?queueId=24&view=agents"
42+
if ($?) {
43+
Write-Host "Successfully started ARM64 VM. Check $u for running status."
44+
} else {
45+
Write-Host "##[warning]Failed to start ARM64 VM. Check $u in case it is already active, or ping Steve."
46+
}

0 commit comments

Comments
 (0)