Skip to content

Commit

Permalink
Fix macOS CI tests (#15)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
yanovs authored Apr 29, 2024
1 parent c80cdc7 commit 7a722db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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

Expand All @@ -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() }}
Expand All @@ -80,15 +82,15 @@ 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 }}
# Grab entire history for setuptools_scm
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 }}

Expand Down
11 changes: 10 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
See https://nox.thea.codes/en/stable/index.html for more.
"""

from __future__ import annotations

import pathlib
Expand Down Expand Up @@ -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")


Expand Down Expand Up @@ -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")

Expand All @@ -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")

Expand All @@ -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():
Expand Down Expand Up @@ -170,13 +174,18 @@ 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",
"leda.tests.integration.run_test",
bundle_name,
"--log",
"INFO",
*args,
)


Expand Down

0 comments on commit 7a722db

Please sign in to comment.