8000 Run installer tests in their own container · python/release-tools@5871cde · GitHub
[go: up one dir, main page]

Skip to content

Commit 5871cde

Browse files
committed
Run installer tests in their own container
1 parent 58a7c91 commit 5871cde

File tree

2 files changed

+105
-85
lines changed

2 files changed

+105
-85
lines changed

windows-release/stage-test-msi.yml

Lines changed: 14 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
InstallAllUsers: 1
3838

3939
steps:
40-
- checkout: none
40+
- checkout: self
4141

4242
- task: DownloadPipelineArtifact@1
4343
displayName: 'Download artifact: msi'
@@ -52,90 +52,19 @@ jobs:
5252
displayName: 'Find installer executable'
5353
workingDirectory: $(Build.BinariesDirectory)\msi
5454
55-
- script: >
56-
"$(SetupExe)"
57-
/passive
58-
/log "$(Logs)\install\log.txt"
59-
TargetDir="$(Build.BinariesDirectory)\Python"
60-
Include_debug=1
61-
Include_symbols=1
62-
InstallAllUsers=$(InstallAllUsers)
63-
$(IncludeFreethreadedOpt)
64-
displayName: 'Install Python'
65-
66-
- powershell: |
67-
gci "$(Build.BinariesDirectory)\python"
68-
displayName: 'List installed files'
69-
70-
- powershell: |
71-
$p = gi "$(Build.BinariesDirectory)\Python\python.exe"
72-
Write-Host "##vso[task.prependpath]$(Split-Path -Parent $p)"
73-
displayName: 'Add test Python to PATH'
74-
75-
- script: |
76-
python -c "import sys; print(sys.version)"
77-
displayName: 'Collect version number'
78-
condition: and(succeeded(), not(variables['SkipTests']))
79-
80-
- script: |
81-
python -m site
82-
displayName: 'Collect site'
83-
condition: and(succeeded(), not(variables['SkipTests']))
84-
85-
- ${{ if eq(parameters.DoFreethreaded, 'true') }}:
86-
- powershell: |
87-
$p = (gci "$(Build.BinariesDirectory)\Python\python3*t.exe" | select -First 1)
88-
Write-Host "Found $p"
89-
if (-not $p) {
90-
Write-Host "Did not find python3*t.exe in:"
91-
dir "$(Build.BinariesDirectory)\Python"
92-
throw "Free-threaded binaries were not installed"
93-
} else {
94-
& $p -c "import sys; print(sys.version)"
95-
}
96-
displayName: 'Collect free-threaded version number'
97-
condition: and(succeeded(), not(variables['SkipTests']))
98-
99-
- powershell: |
100-
gci -r "${env:PROGRAMDATA}\Microsoft\Windows\Start Menu\Programs\Python*"
101-
displayName: 'Capture per-machine Start Menu items'
102-
- powershell: |
103-
gci -r "${env:APPDATA}\Microsoft\Windows\Start Menu\Programs\Python*"
104-
displayName: 'Capture per-user Start Menu items'
105-
106-
- powershell: |
107-
gci -r "HKLM:\Software\WOW6432Node\Python"
108-
displayName: 'Capture per-machine 32-bit registry'
109-
- powershell: |
110-
gci -r "HKLM:\Software\Python"
111-
displayName: 'Capture per-machine native registry'
112-
- powershell: |
113-
gci -r "HKCU:\Software\Python"
114-
displayName: 'Capture current-user registry'
115-
116-
- script: |
117-
python -m pip install "azure<0.10"
118-
python -m pip uninstall -y azure python-dateutil six
119-
displayName: 'Test (un)install package'
120-
condition: and(succeeded(), not(variables['SkipTests']))
121-
122-
- powershell: |
123-
if (Test-Path -Type Container "$(Build.BinariesDirectory)\Python\Lib\test\test_ttk") {
124-
# New set of tests (3.12 and later)
125-
python -m test -uall -v test_ttk test_tkinter test_idle
126-
} else {
127-
# Old set of tests
128-
python -m test -uall -v test_ttk_guionly test_tk test_idle
129-
}
130-
displayName: 'Test Tkinter and Idle'
131-
condition: and(succeeded(), not(variables['SkipTests']), not(variables['SkipTkTests']))
132-
133-
- script: >
134-
"$(SetupExe)"
135-
/passive
136-
/uninstall
137-
/log "$(Logs)\uninstall\log.txt"
138-
displayName: 'Uninstall Python'
55+
- powershell: >
56+
docker run --rm
57+
-v "$(Build.BinariesDirectory)\msi:C:\msi"
58+
-v "$(Build.SourcesDirectory)\windows-release:C:\scripts"
59+
-v "$(Build.BinariesDirectory)\tmp:C:\Python"
60+
-v ('{}:C:\logs' -f (mkdir "$(Build.ArtifactStagingDirectory)\logs"))
61+
-e InstallAllUsers
62+
-e IncludeFreethreadedOpt
63+
-e SkipTests
64+
-e SkipTkTests
65+
mcr.microsoft.com/windows/servercore:ltsc2022
66+
powershell C:\scripts\test-msi.ps1 "C:\msi\$(SetupExeName)"
67+
displayName: 'Run installer tests'
13968
14069
- task: PublishBuildArtifacts@1
14170
displayName: 'Publish Artifact: logs'

windows-release/test-msi.ps1

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
param ([string]$SetupExe)
2+
3+
Write-Host "##[section]Install Python"
4+
$SetupCmd = "$SetupExe /passive /log ""C:\Logs\install\log.txt"" "`
5+
"TargetDir=C:\Python " `
6+
"Include_debug=1 " `
7+
"Include_symbols=1 " `
8+
"InstallAllUsers=${env:InstallAllUsers} " `
9+
"${env:IncludeFreethreadedOpt}"
10+
Write-Host "##[command]$SetupCmd"
11+
& $SetupCmd
12+
if (!$?) { exit $LASTEXITCODE }
13+
14+
Write-Host "##[command]dir C:\Python"
15+
dir C:\Python
16+
17+
$env:PATH = "C:\Python:${env:PATH}"
18+
19+
20+
Write-Host "##[section]Capture Start Menu items& F438 quot;
21+
Write-Host "##[command]dir -r ""${env:PROGRAMDATA}\Microsoft\Windows\Start Menu\Programs\Python*"""
22+
dir -r "${env:PROGRAMDATA}\Microsoft\Windows\Start Menu\Programs\Python*"
23+
24+
Write-Host "##[command]dir -r ""${env:APPDATA}\Microsoft\Windows\Start Menu\Programs\Python*"""
25+
dir -r "${env:APPDATA}\Microsoft\Windows\Start Menu\Programs\Python*"
26+
27+
Write-Host "##[section]Capture registry"
28+
Write-Host 'Capture per-machine 32-bit registry'
29+
Write-Host "##[command]dir -r ""HKLM:\Software\WOW6432Node\Python"""
30+
dir -r "HKLM:\Software\WOW6432Node\Python"
31+
32+
Write-Host 'Capture per-machine native registry'
33+
Write-Host "##[command]dir -r ""HKLM:\Software\Python"""
34+
dir -r "HKLM:\Software\Python"
35+
36+
Write-Host 'Capture current-user registry'
37+
Write-Host "##[command]dir -r ""HKCU:\Software\Python"""
38+
dir -r "HKCU:\Software\Python"
39+
40+
41+
if (-not $env:SkipTests) {
42+
Write-Host "##[section]Smoke tests"
43+
Write-Host "##[command]python -c ""import sys; print(sys.version)"""
44+
python -c "import sys; print(sys.version)"
45+
if (!$?) { exit $LASTEXITCODE }
46+
Write-Host "##[command]python -m site"
47+
python -m site
48+
if (!$?) { exit $LASTEXITCODE }
49+
50+
if ($env:IncludeFreethreadedOpt) {
51+
$p = (gci "C:\Python\python3*t.exe" | select -First 1)
52+
if (-not $p) {
53+
Write-Host "Did not find python3*t.exe in:"
54+
dir "C:\Python"
55+
throw "Free-threaded binaries were not installed"
56+
}
57+
Write-Host "Found free threaded executable $p"
58+
Write-Host "##[command]$p -c ""import sys; print(sys.version)"""
59+
& $p -c "import sys; print(sys.version)"
60+
if (!$?) { exit $LASTEXITCODE }
61+
}
62+
63+
Write-Host "##[section]Test (un)install package"
64+
Write-Host "##[command]python -m pip install ""azure<0.10"""
65+
python -m pip install "azure<0.10"
66+
if (!$?) { exit $LASTEXITCODE }
67+
Write-Host "##[command]python -m pip uninstall -y azure python-dateutil six"
68+
python -m pip uninstall -y azure python-dateutil six
69+
if (!$?) { exit $LASTEXITCODE }
70+
71+
if (-not $env:SkipTkTests) {
72+
Write-Host "##[section]Test Tkinter and Idle"
73+
if (Test-Path -Type Container "C:\Python\Lib\test\test_ttk") {
74+
# New set of tests (3.12 and later)
75+
Write-Host "##[command]python -m test -uall -v test_ttk test_tkinter test_idle"
76+
python -m test -uall -v test_ttk test_tkinter test_idle
77+
if (!$?) { exit $LASTEXITCODE }
78+
} else {
79+
# Old set of tests
80+
Write-Host "##[command]python -m test -uall -v test_ttk_guionly test_tk test_idle"
81+
python -m test -uall -v test_ttk_guionly test_tk test_idle
82+
if (!$?) { exit $LASTEXITCODE }
83+
}
84+
}
85+
}
86+
87+
Write-Host "##[section]Uninstall Python"
88+
$UninstallCmd = "$(SetupExe) /passive /uninstall /log C:\Logs\uninstall\log.txt"
89+
Write-Host "##[command]$UninstallCmd"
90+
& $UninstallCmd
91+
if (!$?) { exit $LASTEXITCODE }

0 commit comments

Comments
 (0)
0