From 1cbfb84652810a76549d557148a7101fe7da9d19 Mon Sep 17 00:00:00 2001 From: nulano Date: Sun, 1 Jan 2023 03:18:30 +0100 Subject: [PATCH] GHA: test windows wheels in Docker --- .github/workflows/test-windows.yml | 14 ++++++++++++++ Tests/check_wheel.py | 24 ++++++++++++++++++++++++ Tests/test_imagegrab.py | 2 ++ 3 files changed, 40 insertions(+) create mode 100644 Tests/check_wheel.py diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 3d7ec8e67..11aa465ea 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -235,6 +235,20 @@ 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' && !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 + - 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 000000000..646ec9497 --- /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 f8059eca4..0f2cf845d 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)