From e2b8170dc88a09dff55cf068c196e72d0079edd3 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sun, 10 Jul 2022 21:06:45 +0100 Subject: [PATCH] add mingw CI --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++ noxfile.py | 42 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a791047..1d6552f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -350,3 +350,42 @@ jobs: CIBW_BUILD_VERBOSITY: 1 with: package-dir: examples/namespace_package + + test-mingw: + runs-on: windows-latest + name: ${{ matrix.python-version }} mingw-${{ matrix.arch }} + strategy: + fail-fast: false + matrix: + include: [ + { msystem: MINGW64, arch: x86_64, path: mingw64, rust_target: x86_64-pc-windows-gnu }, + { msystem: MINGW32, arch: i686, path: mingw32, rust_target: i686-pc-windows-gnu } + ] + steps: + - uses: actions/checkout@v2 + - name: Install MSys2 and dependencies + uses: msys2/setup-msys2@v2 + with: + update: true + msystem: ${{ matrix.msystem }} + install: >- + git + mingw-w64-${{ matrix.arch }}-python + mingw-w64-${{ matrix.arch }}-python-pip + mingw-w64-${{ matrix.arch }}-openssl + mingw-w64-${{ matrix.arch }}-toolchain + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: ${{ matrix.rust-target }} + + - name: Install test dependencies + shell: msys2 {0} + run: python -m pip install --upgrade nox pip wheel + + - name: Test examples + shell: msys2 {0} + run: | + PATH="$PATH:/c/Users/runneradmin/.cargo/bin" nox -s test-mingw diff --git a/noxfile.py b/noxfile.py index 1eab20ca..6640d659 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,6 +2,7 @@ import tarfile from glob import glob from pathlib import Path +from unittest.mock import patch import nox @@ -35,3 +36,44 @@ def mypy(session: nox.Session): def test(session: nox.Session): session.install("pytest", ".") session.run("pytest", "setuptools_rust", "tests", *session.posargs) + + +@nox.session(name="test-mingw") +def test_mingw(session: nox.Session): + # manually re-implemented test-examples to workaround + # https://github.com/wntrblm/nox/issues/630 + + oldrun = nox.command.run + + def newrun(*args, **kwargs): + # suppress "external" error on install + kwargs["external"] = True + oldrun(*args, **kwargs) + + def chdir(path: Path): + print(path) + os.chdir(path) + + examples = Path(os.path.dirname(__file__)).absolute() / "examples" + + with patch.object(nox.command, "run", newrun): + session.install(".") + + chdir(examples / "hello-world") + session.install("--no-build-isolation", ".") + session.run("hello-world") + + chdir(examples / "html-py-ever") + session.install("pytest", "pytest-benchmark", "beautifulsoup4") + session.install("--no-build-isolation", ".") + session.run("pytest") + + chdir(examples / "namespace_package") + session.install("pytest") + session.install("--no-build-isolation", ".") + session.run("pytest") + + chdir(examples / "rust_with_cffi") + session.install("pytest", "cffi") + session.install("--no-build-isolation", ".") + session.run("pytest")