diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 3d7ec8e6720..e7f98fa03b3 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -235,6 +235,12 @@ jobs: %pythonLocation%\python.exe -m pip wheel -v -C raqm=vendor -C fribidi=vendor -C imagequant=disable . shell: cmd + - name: Test Wheel + if: "github.event_name != 'pull_request'" + run: | + 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 }} + shell: pwsh + - name: Upload wheel uses: actions/upload-artifact@v3 if: "github.event_name != 'pull_request'" diff --git a/Tests/check_wheel.py b/Tests/check_wheel.py new file mode 100644 index 00000000000..646ec949797 --- /dev/null +++ b/Tests/check_wheel.py @@ -0,0 +1,24 @@ +import sys + +import pytest + +from PIL import features + + +@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows") +def test_windows_wheel_features(): + expected_modules = ["pil", "tkinter", "freetype2", "littlecms2", "webp"] + expected_codecs = ["jpg", "jpg_2000", "zlib", "libtiff"] + expected_features = [ + "webp_anim", + "webp_mux", + "transp_webp", + "raqm", + "fribidi", + "harfbuzz", + "libjpeg_turbo", + ] + + assert features.get_supported_modules() == expected_modules + assert features.get_supported_codecs() == expected_codecs + assert features.get_supported_features() == expected_features diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index f8059eca443..d230b9d81a6 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -15,6 +15,8 @@ class TestImageGrab: sys.platform not in ("win32", "darwin"), reason="requires Windows or macOS" ) def test_grab(self): + if os.environ.get("USERNAME") == "ContainerAdministrator": + pytest.skip("can't grab screen when running in Docker") ImageGrab.grab() ImageGrab.grab(include_layered_windows=True) ImageGrab.grab(all_screens=True) diff --git a/winbuild/test_docker.ps1 b/winbuild/test_docker.ps1 new file mode 100644 index 00000000000..e3bf55e94aa --- /dev/null +++ b/winbuild/test_docker.ps1 @@ -0,0 +1,38 @@ +param ([string]$python) +$ErrorActionPreference = 'Stop' +$ProgressPreference = 'SilentlyContinue' +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +if ($python -like "pypy*") { + echo "Downloading https://aka.ms/vs/15/release/vc_redist.x64.exe" + Invoke-WebRequest -Uri 'https://aka.ms/vs/15/release/vc_redist.x64.exe' -OutFile 'vc_redist.x64.exe' + C:\vc_redist.x64.exe /install /quiet /norestart | Out-Null + $url = 'https://downloads.python.org/pypy/{0}-v7.3.13-win64.zip' -f $python + echo "Downloading $url" + Invoke-WebRequest -Uri $url -OutFile 'pypy.zip' + tar -xf 'pypy.zip' + mv pypy*-win64 C:\Python +} else { + $url = 'https://www.python.org/ftp/python/{0}.0/python-{0}.0-amd64.exe' -f $python + echo "Downloading $url" + 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 -U pip +& python -m pip install pytest pytest-timeout +& python -m pip install "$(Get-ChildItem *.whl -Name)" +& python -m pytest -vx Tests\check_wheel.py Tests +if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) { exit $LASTEXITCODE }