From fc5cd83ec08e9aef5e059a70a509cd79afef65ef Mon Sep 17 00:00:00 2001 From: nulano Date: Sun, 1 Jan 2023 04:33:09 +0100 Subject: [PATCH] use powershell --- .github/workflows/test-windows.yml | 12 ++---------- winbuild/test_docker.ps1 | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 winbuild/test_docker.ps1 diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 11aa465ea..df4d29975 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -238,16 +238,8 @@ jobs: - name: Test Wheel if: "github.event_name != 'pull_request' && !contains(matrix.python-version, 'pypy')" run: | - cd C:\pillow - python -m pip install pytest pytest-timeout - for %%f in (dist\*.whl) do python -m pip install %%f - reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\python.exe" /v "GlobalFlag" /t REG_SZ /d "0x02000000" /f - path C:\pillow\winbuild\build\bin\;%PATH% - set CI= - python -m pytest -vx Tests\check_wheel.py Tests - shell: cmd /c copy {0} docker.bat && docker run --rm -v %GITHUB_WORKSPACE%:C:\pillow %DOCKER_IMAGE% C:\pillow\docker.bat - env: - DOCKER_IMAGE: winamd64/python:${{ matrix.python-version }}-windowsservercore + docker run --rm -v ${env:GITHUB_WORKSPACE}:C:\pillow mcr.microsoft.com/windows/servercore:ltsc2022 powershell C:\pillow\winbuild\test_docker.ps1 ${{ matrix.python-version }}.0 ${{ matrix.architecture }} + shell: pwsh - name: Upload wheel uses: actions/upload-artifact@v3 diff --git a/winbuild/test_docker.ps1 b/winbuild/test_docker.ps1 new file mode 100644 index 000000000..1aa5c4b5b --- /dev/null +++ b/winbuild/test_docker.ps1 @@ -0,0 +1,26 @@ +param ([string]$python,[string]$arch) +$ErrorActionPreference = 'Stop' +$ProgressPreference = 'SilentlyContinue' +$suffix = if ($arch -eq "x64") {"-amd64"} else {""} +$url = 'https://www.python.org/ftp/python/{0}/python-{0}{1}.exe' -f ($python, $suffix) +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +Invoke-WebRequest -Uri $url -OutFile 'setup.exe' +Start-Process setup.exe -Wait -NoNewWindow -PassThru -ArgumentList @( + '/quiet', + 'InstallAllUsers=0', + 'TargetDir=C:\Python', + 'PrependPath=1', + 'Shortcuts=0', + 'Include_doc=0', + 'Include_pip=1', + 'Include_test=0' + ) +$env:CI = "true" +$env:path += ";C:\Python\;C:\pillow\winbuild\build\bin\" +cd C:\pillow +& python -VV +& python -m ensurepip +& python -m pip install pytest pytest-timeout +& python -m pip install "dist\$(Get-ChildItem dist\*.whl -Name)" +& python -m pytest -vx Tests\check_wheel.py Tests +if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) { exit $LASTEXITCODE }