diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 4a2b79cfd23..07f6ca443e3 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -7,26 +7,56 @@ jobs: runs-on: windows-2016 strategy: + fail-fast: false matrix: - python-version: - - "3.5.4" - - "3.6.8" - - "3.7.4" - platform: - - name: "x86" - vars: "x86" - msbuild: "Win32" - - name: "x64" - vars: "x86_amd64" - msbuild: "x64" + python-version: ["3.5", "3.6", "3.7", "pypy3.6"] + architecture: ["x86", "x64"] + include: + - architecture: "x86" + platform-vcvars: "x86" + platform-msbuild: "Win32" + - architecture: "x64" + platform-vcvars: "x86_amd64" + platform-msbuild: "x64" + - python-version: "pypy3.6" + pypy-version: "pypy-c-jit-97588-7392d01b93d0-win32" + pypy-url: "http://buildbot.pypy.org/nightly/py3.6/pypy-c-jit-97588-7392d01b93d0-win32.zip" + # pypy-url: "https://bitbucket.org/pypy/pypy/downloads/${{ matrix.pypy-version }}.zip" + exclude: + - python-version: "pypy3.6" + architecture: "x64" - name: Python ${{ matrix.python-version }} ${{ matrix.platform.name }} + name: Python ${{ matrix.python-version }} ${{ matrix.architecture }} steps: - uses: actions/checkout@v1 + + - name: Install PyPy + if: "contains(matrix.python-version, 'pypy')" + run: | + curl -fsSL -o pypy3.zip "${{ matrix.pypy-url }}" + 7z x pypy3.zip "-o$env:RUNNER_WORKSPACE\" + mv "$env:RUNNER_WORKSPACE\${{ matrix.pypy-version }}" "$env:RUNNER_WORKSPACE\${{ matrix.python-version }}" + $env:PYTHON="$env:RUNNER_WORKSPACE\${{ matrix.python-version }}" + # set env: pythonLocation + Write-Host "`#`#[set-env name=pythonLocation;]$env:PYTHON" # old syntax https://github.com/actions/toolkit/issues/61 + Write-Host "::set-env name=pythonLocation::$env:PYTHON" # new syntax https://github.com/actions/toolkit/blob/5bb77ec03fea98332e41f9347c8fbb1ce1e48f4a/docs/commands.md + New-Item -ItemType SymbolicLink -Path "$env:PYTHON\python.exe" -Target "$env:PYTHON\pypy3.exe" + curl -fsSL -o get-pip.py https://bootstrap.pypa.io/get-pip.py + & $env:PYTHON\python.exe get-pip.py + shell: pwsh + + # sets env: pythonLocation + - name: Set up Python + if: "!contains(matrix.python-version, 'pypy')" + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.architecture }} - name: Fetch dependencies run: | + $env:PYTHON=$env:pythonLocation curl -fsSL -o pillow-depends.zip https://github.com/python-pillow/pillow-depends/archive/master.zip 7z x pillow-depends.zip -oc:\ mv c:\pillow-depends-master c:\pillow-depends @@ -37,7 +67,6 @@ jobs: python.exe $env:GITHUB_WORKSPACE\winbuild\build_dep.py # .\build_deps.cmd env: - PYTHON: C:\hostedtoolcache\windows\Python\${{ matrix.python-version }}\${{ matrix.platform.name }} EXECUTABLE: bin\python.exe shell: pwsh @@ -47,7 +76,7 @@ jobs: set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 set BUILD=%GITHUB_WORKSPACE%\winbuild\build cd /D %BUILD%\jpeg-9c - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform.vars }} 8.1 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 echo on nmake -nologo -f makefile.vc setup-vc6 nmake -nologo -f makefile.vc clean @@ -61,7 +90,7 @@ jobs: set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 set BUILD=%GITHUB_WORKSPACE%\winbuild\build cd /D %BUILD%\zlib-1.2.11 - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform.vars }} 8.1 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 echo on nmake -nologo -f win32\Makefile.msc clean nmake -nologo -f win32\Makefile.msc zlib.lib @@ -75,7 +104,7 @@ jobs: set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 set BUILD=%GITHUB_WORKSPACE%\winbuild\build cd /D %BUILD%\tiff-4.0.10 - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform.vars }} 8.1 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 echo on copy %GITHUB_WORKSPACE%\winbuild\nmake.opt nmake.opt nmake -nologo -f makefile.vc clean @@ -90,13 +119,13 @@ jobs: set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 set BUILD=%GITHUB_WORKSPACE%\winbuild\build cd /D %BUILD%\libwebp-1.0.3 - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform.vars }} 8.1 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 echo on rmdir /S /Q output\release-static - nmake -nologo -f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output ARCH=${{ matrix.platform.name }} all + nmake -nologo -f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output ARCH=${{ matrix.architecture }} all mkdir %INCLIB%\webp copy /Y /B src\webp\*.h %INCLIB%\webp - copy /Y /B output\release-static\${{ matrix.platform.name }}\lib\* %INCLIB% + copy /Y /B output\release-static\${{ matrix.architecture }}\lib\* %INCLIB% - name: Build dependencies / freetype run: | @@ -106,16 +135,16 @@ jobs: set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 set BUILD=%GITHUB_WORKSPACE%\winbuild\build cd /D %BUILD%\freetype-2.10.1 - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform.vars }} 8.1 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 echo on rmdir /S /Q objs set DefaultPlatformToolset=v140 set VCTargetsPath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets set MSBUILD="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" - %MSBUILD% builds\windows\vc2010\freetype.sln /t:Build /p:Configuration="Release" /p:Platform=${{ matrix.platform.msbuild }} /m + %MSBUILD% builds\windows\vc2010\freetype.sln /t:Build /p:Configuration="Release" /p:Platform=${{ matrix.platform-msbuild }} /m xcopy /Y /E /Q include %INCLIB% - copy /Y /B objs\${{ matrix.platform.msbuild }}\Release\freetype.dll %INCLIB% - copy /Y /B objs\${{ matrix.platform.msbuild }}\Release\freetype.lib %INCLIB% + copy /Y /B objs\${{ matrix.platform-msbuild }}\Release\freetype.dll %INCLIB% + copy /Y /B objs\${{ matrix.platform-msbuild }}\Release\freetype.lib %INCLIB% - name: Build dependencies / lcms2 if: false @@ -142,7 +171,7 @@ jobs: set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 set BUILD=%GITHUB_WORKSPACE%\winbuild\build cd /D %BUILD%\openjpeg-2.3.1msvcr10-x32 - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform.vars }} 8.1 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 echo on cmake.exe -DBUILD_THIRDPARTY:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" . nmake -nologo -f Makefile clean @@ -157,17 +186,18 @@ jobs: set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 set BUILD=%GITHUB_WORKSPACE%\winbuild\build cd /D %BUILD%\ghostscript-9.27 - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform.vars }} 8.1 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 echo on set MSVC_VERSION=14 set RCOMP="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\RC.Exe" - if "${{ matrix.platform.name }}"=="x64" set WIN64="" + if "${{ matrix.architecture }}"=="x64" set WIN64="" nmake -nologo -f psi\msvc.mak rem Add bin to PATH variable: Copy to INCLIB, then add INCLIB to PATH in Test step. copy /Y /B bin\* %INCLIB% - name: Build Pillow run: | + set PYTHON=%pythonLocation% set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\V7.1A\Include set MPLSRC=%GITHUB_WORKSPACE% set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 @@ -175,37 +205,30 @@ jobs: set DISTUTILS_USE_SDK=1 set LIB=%INCLIB%;%PYTHON%\tcl set INCLUDE=%INCLIB%;%GITHUB_WORKSPACE%\depends\tcl86\include;%INCLUDE% - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform.vars }} 8.1 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ${{ matrix.platform-vcvars }} 8.1 set BLDOPT=install %PYTHON%\%EXECUTABLE% setup.py build_ext --add-imaging-libs=msvcrt install %PYTHON%\%EXECUTABLE% -c "from PIL import _webp;import os, shutil;shutil.copy(r'%INCLIB%\freetype.dll', os.path.dirname(_webp.__file__));" %PYTHON%\%EXECUTABLE% selftest.py --installed env: - PYTHON: C:\hostedtoolcache\windows\Python\${{ matrix.python-version }}\${{ matrix.platform.name }} EXECUTABLE: python.exe - name: pip install pytest pytest-cov codecov - run: '%PYTHON%\%PIP% install pytest pytest-cov codecov' - env: - PYTHON: C:\hostedtoolcache\windows\Python\${{ matrix.python-version }}\${{ matrix.platform.name }} - PIP: Scripts\pip.exe + run: | + "%pythonLocation%\python.exe" -m pip install pytest pytest-cov + pip install codecov - name: Test Pillow run: | + set PYTHON=%pythonLocation% set INCLIB=%GITHUB_WORKSPACE%\winbuild\depends\msvcr10-x32 rem Add GhostScript executables (copied to INCLIB) to PATH. path %INCLIB%;%PATH% cd /D %GITHUB_WORKSPACE% - %PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov-report term --cov-report xml Tests - env: - PYTHON: C:\hostedtoolcache\windows\Python\${{ matrix.python-version }}\${{ matrix.platform.name }} - EXECUTABLE: python.exe + %PYTHON%\python.exe -m pytest -vx --cov PIL --cov-report term --cov-report xml Tests - name: Upload coverage - run: | - cd /D %GITHUB_WORKSPACE% - %PYTHON%\%CODECOV% --file coverage.xml --name %PYTHON% + run: 'codecov --file "%GITHUB_WORKSPACE%\coverage.xml" --name "%pythonLocation%"' env: - PYTHON: C:\hostedtoolcache\windows\Python\${{ matrix.python-version }}\${{ matrix.platform.name }} CODECOV: Scripts\codecov.exe diff --git a/Tests/helper.py b/Tests/helper.py index 78a2f520f92..c352f54b940 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -355,10 +355,17 @@ def on_appveyor(): return "APPVEYOR" in os.environ +def on_github_actions(): + return "GITHUB_ACTIONS" in os.environ + + def on_ci(): # Travis and AppVeyor have "CI" # Azure Pipelines has "TF_BUILD" - return "CI" in os.environ or "TF_BUILD" in os.environ + # GitHub Actions has "GITHUB_ACTIONS" + return ( + "CI" in os.environ or "TF_BUILD" in os.environ or "GITHUB_ACTIONS" in os.environ + ) if sys.platform == "win32": diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index b06814cb944..b69c2040f4c 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -3,7 +3,7 @@ from PIL import Image -from .helper import PillowTestCase, hopper, on_appveyor, unittest +from .helper import PillowTestCase, hopper, on_ci, unittest # CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2 # https://github.com/eliben/pycparser/pull/198#issuecomment-317001670 @@ -333,8 +333,8 @@ def test_p_putpixel_rgb_rgba(self): class TestEmbeddable(unittest.TestCase): @unittest.skipIf( - not sys.platform.startswith("win32") or on_appveyor(), - "Failing on AppVeyor when run from subprocess, not from shell", + not sys.platform.startswith("win32") or on_ci(), + "Failing on AppVeyor / GitHub Actions when run from subprocess, not from shell", ) def test_embeddable(self): import subprocess diff --git a/Tests/test_imageshow.py b/Tests/test_imageshow.py index 2f2620b7408..bad0329af44 100644 --- a/Tests/test_imageshow.py +++ b/Tests/test_imageshow.py @@ -1,6 +1,8 @@ +import sys + from PIL import Image, ImageShow -from .helper import PillowTestCase, hopper, on_ci, unittest +from .helper import PillowTestCase, hopper, on_ci, on_github_actions, unittest class TestImageShow(PillowTestCase): @@ -34,7 +36,10 @@ def show_image(self, image, **options): # Restore original state ImageShow._viewers.pop(0) - @unittest.skipUnless(on_ci(), "Only run on CIs") + @unittest.skipUnless( + on_ci() and not (sys.platform == "win32" and on_github_actions()), + "Only run on CIs; hangs on Windows on Github Actions", + ) def test_show(self): for mode in ("1", "I;16", "LA", "RGB", "RGBA"): im = hopper(mode)