Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Windows installer tests in their own container #101

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
99 changes: 14 additions & 85 deletions windows-release/stage-test-msi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
InstallAllUsers: 1

steps:
- checkout: none
- checkout: self

- task: DownloadPipelineArtifact@1
displayName: 'Download artifact: msi'
Expand All @@ -52,90 +52,19 @@ jobs:
displayName: 'Find installer executable'
workingDirectory: $(Build.BinariesDirectory)\msi

- script: >
"$(SetupExe)"
/passive
/log "$(Logs)\install\log.txt"
TargetDir="$(Build.BinariesDirectory)\Python"
Include_debug=1
Include_symbols=1
InstallAllUsers=$(InstallAllUsers)
$(IncludeFreethreadedOpt)
displayName: 'Install Python'

- powershell: |
gci "$(Build.BinariesDirectory)\python"
displayName: 'List installed files'

- powershell: |
$p = gi "$(Build.BinariesDirectory)\Python\python.exe"
Write-Host "##vso[task.prependpath]$(Split-Path -Parent $p)"
displayName: 'Add test Python to PATH'

- script: |
python -c "import sys; print(sys.version)"
displayName: 'Collect version number'
condition: and(succeeded(), not(variables['SkipTests']))

- script: |
python -m site
displayName: 'Collect site'
condition: and(succeeded(), not(variables['SkipTests']))

- ${{ if eq(parameters.DoFreethreaded, 'true') }}:
- powershell: |
$p = (gci "$(Build.BinariesDirectory)\Python\python3*t.exe" | select -First 1)
Write-Host "Found $p"
if (-not $p) {
Write-Host "Did not find python3*t.exe in:"
dir "$(Build.BinariesDirectory)\Python"
throw "Free-threaded binaries were not installed"
} else {
& $p -c "import sys; print(sys.version)"
}
displayName: 'Collect free-threaded version number'
condition: and(succeeded(), not(variables['SkipTests']))

- powershell: |
gci -r "${env:PROGRAMDATA}\Microsoft\Windows\Start Menu\Programs\Python*"
displayName: 'Capture per-machine Start Menu items'
- powershell: |
gci -r "${env:APPDATA}\Microsoft\Windows\Start Menu\Programs\Python*"
displayName: 'Capture per-user Start Menu items'

- powershell: |
gci -r "HKLM:\Software\WOW6432Node\Python"
displayName: 'Capture per-machine 32-bit registry'
- powershell: |
gci -r "HKLM:\Software\Python"
displayName: 'Capture per-machine native registry'
- powershell: |
gci -r "HKCU:\Software\Python"
displayName: 'Capture current-user registry'

- script: |
python -m pip install "azure<0.10"
python -m pip uninstall -y azure python-dateutil six
displayName: 'Test (un)install package'
condition: and(succeeded(), not(variables['SkipTests']))

- powershell: |
if (Test-Path -Type Container "$(Build.BinariesDirectory)\Python\Lib\test\test_ttk") {
# New set of tests (3.12 and later)
python -m test -uall -v test_ttk test_tkinter test_idle
} else {
# Old set of tests
python -m test -uall -v test_ttk_guionly test_tk test_idle
}
displayName: 'Test Tkinter and Idle'
condition: and(succeeded(), not(variables['SkipTests']), not(variables['SkipTkTests']))

- script: >
"$(SetupExe)"
/passive
/uninstall
/log "$(Logs)\uninstall\log.txt"
displayName: 'Uninstall Python'
- powershell: >
docker run --rm
-v ('{0}:C:\msi' -f (Split-Path -Parent "$(SetupExe)"))
-v ('{0}:C:\scripts' -f (gi windows-release))
-v ('{0}:C:\Python' -f (mkdir "$(Build.BinariesDirectory)\tmp" -Force))
-v ('{0}:C:\logs' -f (mkdir "$(Logs)" -Force))
-e InstallAllUsers
-e IncludeFreethreadedOpt
-e SkipTests
-e SkipTkTests
mcr.microsoft.com/windows/server:ltsc2022
powershell C:\scripts\test-msi.ps1 "C:\msi\$(SetupExeName)"
displayName: 'Run installer tests'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: logs'
Expand Down
100 changes: 100 additions & 0 deletions windows-release/test-msi.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
param ([string]$SetupExe)

Write-Host "##[section]Install Python"
$SetupCmd = "$SetupExe " + `
"/passive /log ""C:\Logs\install\log.txt"" " + `
"TargetDir=C:\Python " + `
"Include_debug=1 " + `
"Include_symbols=1 " + `
"InstallAllUsers=${env:InstallAllUsers} " + `
"${env:IncludeFreethreadedOpt}"
Write-Host "##[command]$SetupCmd"
iex $SetupCmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }

Write-Host "##[command]dir C:\Python"
dir C:\Python

$env:PATH = "C:\Python:${env:PATH}"


Write-Host "##[section]Capture Start Menu items"
Write-Host "##[command]dir -r ""${env:PROGRAMDATA}\Microsoft\Windows\Start Menu\Programs\Python*"""
dir -r "${env:PROGRAMDATA}\Microsoft\Windows\Start Menu\Programs\Python*"

Write-Host "##[command]dir -r ""${env:APPDATA}\Microsoft\Windows\Start Menu\Programs\Python*"""
dir -r "${env:APPDATA}\Microsoft\Windows\Start Menu\Programs\Python*"

Write-Host "##[section]Capture registry"
Write-Host 'Capture per-machine 32-bit registry'
# PS 5.0 and later can't do this, because they normalise registry paths incorrectly
# So we'll use the good old "reg" tool
#Write-Host "##[command]dir -r ""HKLM:\Software\WOW6432Node\Python"""
#dir -r "HKLM:\Software\WOW6432Node\Python"
Write-Host "##[command]reg HKLM\Software\Python /s /reg:32"
reg HKLM\Software\Python /s /reg:32
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the containers don't seem to have reg.exe, so these steps probably need to be replaced with our own custom code for listing the registry.

Or maybe we can downgrade Powershell to a version that isn't broken by PowerShell/PowerShell#5536


Write-Host 'Capture per-machine native registry'
#Write-Host "##[command]dir -r ""HKLM:\Software\Python"""
#dir -r "HKLM:\Software\Python"
Write-Host "##[command]reg HKLM\Software\Python /s /reg:64"
reg HKLM\Software\Python /s /reg:64

Write-Host 'Capture current-user registry'
#Write-Host "##[command]dir -r ""HKCU:\Software\Python"""
#dir -r "HKCU:\Software\Python"
Write-Host "##[command]reg HKCU\Software\Python /s"
reg HKCU\Software\Python /s


if (-not $env:SkipTests) {
Write-Host "##[section]Smoke tests"
Write-Host "##[command]python -c ""import sys; print(sys.version)"""
python -c "import sys; print(sys.version)"
if (!$?) { exit $LASTEXITCODE }
Write-Host "##[command]python -m site"
python -m site
if (!$?) { exit $LASTEXITCODE }

if ($env:IncludeFreethreadedOpt) {
$p = (gci "C:\Python\python3*t.exe" | select -First 1)
if (-not $p) {
Write-Host "Did not find python3*t.exe in:"
dir "C:\Python"
throw "Free-threaded binaries were not installed"
}
Write-Host "Found free threaded executable $p"
Write-Host "##[command]$p -c ""import sys; print(sys.version)"""
& $p -c "import sys; print(sys.version)"
if (!$?) { exit $LASTEXITCODE }
}

Write-Host "##[section]Test (un)install package"
Write-Host "##[command]python -m pip install ""azure<0.10"""
python -m pip install "azure<0.10"
if (!$?) { exit $LASTEXITCODE }
Write-Host "##[command]python -m pip uninstall -y azure python-dateutil six"
python -m pip uninstall -y azure python-dateutil six
if (!$?) { exit $LASTEXITCODE }

if (-not $env:SkipTkTests) {
Write-Host "##[section]Test Tkinter and Idle"
if (Test-Path -Type Container "C:\Python\Lib\test\test_ttk") {
# New set of tests (3.12 and later)
Write-Host "##[command]python -m test -uall -v test_ttk test_tkinter test_idle"
python -m test -uall -v test_ttk test_tkinter test_idle
if (!$?) { exit $LASTEXITCODE }
} else {
# Old set of tests
Write-Host "##[command]python -m test -uall -v test_ttk_guionly test_tk test_idle"
python -m test -uall -v test_ttk_guionly test_tk test_idle
if (!$?) { exit $LASTEXITCODE }
}
}
}

Write-Host "##[section]Uninstall Python"
$UninstallCmd = "$(SetupExe) /passive /uninstall /log C:\Logs\uninstall\log.txt"
Write-Host "##[command]$UninstallCmd"
iex $UninstallCmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }