From 7a722db12c0388b29629efa64cc4ce7a0e1b7c7c Mon Sep 17 00:00:00 2001 From: yanovs <42386943+yanovs@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:05:07 -0400 Subject: [PATCH] Fix macOS CI tests (#15) - Fix since macos-latest now points to macOS 14 on M1 chip (see here and here) - Upgrade GitHub actions - Disable pip version check - Tweak noxfile to include arg to gen HTML diffs --- .github/workflows/test.yml | 24 +++++++++++++----------- noxfile.py | 11 ++++++++++- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5037e91..1a11452 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,27 +14,29 @@ permissions: jobs: # Run tests, linters, and checkers via nox test: - runs-on: ${{ matrix.platform }} + runs-on: ${{ matrix.os }} env: LEDA_TEST_OUTPUT_DIR: ~/leda_outputs/ + PIP_DISABLE_PIP_VERSION_CHECK: '1' strategy: fail-fast: false matrix: # See https://help.github.com/articles/virtual-environments-for-github-actions - platform: + os: - ubuntu-latest - - macos-latest + # TODO: Switch back to `macos-latest` when we fix small issues with macOS 14 ARM + - macos-13 - windows-latest python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8'] steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -45,7 +47,7 @@ jobs: - name: Test with nox run: nox - if: ${{ ! (matrix.platform == 'windows-latest' && matrix.python-version == 'pypy-3.8') }} + if: ${{ ! (matrix.os == 'windows-latest' && matrix.python-version == 'pypy-3.8') }} # TODO: Run tests on windows/pypy-3.8 @@ -55,12 +57,12 @@ jobs: # there are no pre-built Windows/py3.8/numpy1.6.6 wheels. # Skip py3.9 because none of the bundles are for it. # TODO: Investigate issues on Windows and pypy. - if: ${{ (matrix.python-version != '3.9') && ! (matrix.platform == 'windows-latest' && matrix.python-version == '3.8') && ! startsWith(matrix.python-version, 'pypy-') }} + if: ${{ (matrix.python-version != '3.9') && ! (matrix.os == 'windows-latest' && matrix.python-version == '3.8') && ! startsWith(matrix.python-version, 'pypy-') }} - name: Upload failed outputs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: leda-outputs-${{ matrix.platform }}-${{ matrix.python-version }} + name: leda-outputs-${{ matrix.os }}-${{ matrix.python-version }} path: ~/leda_outputs/ retention-days: 1 if: ${{ failure() }} @@ -80,7 +82,7 @@ jobs: python-version: ['3.8'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # See https://github.com/actions/checkout/issues/261 ref: ${{ github.event.pull_request.head.sha }} @@ -88,7 +90,7 @@ jobs: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/noxfile.py b/noxfile.py index 878fd63..d9bb985 100644 --- a/noxfile.py +++ b/noxfile.py @@ -30,6 +30,7 @@ See https://nox.thea.codes/en/stable/index.html for more. """ + from __future__ import annotations import pathlib @@ -69,6 +70,7 @@ def is_isolated_venv(session: nox.Session) -> bool: def mypy(session: nox.Session) -> None: if is_isolated_venv(session): session.install("-e", ".[test]") + session.run("mypy", "leda") @@ -96,6 +98,7 @@ def pytest(session: nox.Session) -> None: def ruff(session: nox.Session) -> None: if is_isolated_venv(session): session.install("-e", ".[test]") + session.run("ruff", "format", "leda", "--check") session.run("ruff", "check", "leda") @@ -104,6 +107,7 @@ def ruff(session: nox.Session) -> None: def fix_ruff(session: nox.Session) -> None: if is_isolated_venv(session): session.install("-e", ".[test]") + session.run("ruff", "format", "leda") session.run("ruff", "check", "leda", "--fix") @@ -124,7 +128,7 @@ def develop(session: nox.Session) -> None: def _get_requirements_versions( - requirements_path: pathlib.Path + requirements_path: pathlib.Path, ) -> dict[str, str]: versions = {} for line in pathlib.Path(requirements_path).read_text().splitlines(): @@ -170,6 +174,10 @@ def _run_integration_test(session: nox.Session, bundle_name: str) -> None: session.install("-r", requirements_filename, "-c", requirements_filename) session.install("-e", ".[demos,test]") + args = [] + if "--gen-html-diffs" in session.posargs: + args.append("--gen-html-diffs") + session.run( "python", "-m", @@ -177,6 +185,7 @@ def _run_integration_test(session: nox.Session, bundle_name: str) -> None: bundle_name, "--log", "INFO", + *args, )