Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install system dependencies
run: |
sudo apt-get install ngspice iverilog ngspice-dev libngspice0-dev
- name: Install Python packages
- name: Install nox
run: |
pip install -e ".[dev]"
- name: Test
pip install nox
- name: Run tests
run: |
pytest
nox -s test
45 changes: 42 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,59 @@

"""Setup file for nox (https://nox.thea.codes/en/stable/tutorial.html)."""

from functools import cache

import nox

import tomllib # Python 3.11+; use `tomli` for earlier versions
# Python 3.11+ has tomllib built-in, use tomli for earlier versions
try:
import tomllib
except ImportError:
import tomli as tomllib


@cache
def get_doc_dependencies():
with open("pyproject.toml", "rb") as f:
pyproject = tomllib.load(f)
return pyproject["project"]["optional-dependencies"]["docs"]


def get_dev_dependencies():
with open("pyproject.toml", "rb") as f:
pyproject = tomllib.load(f)
return pyproject["project"]["optional-dependencies"]["dev"]


@nox.session
def test(session: nox.Session) -> None:
"""Run the test suite with pytest."""
dev_deps = get_dev_dependencies()
session.install(".", *dev_deps)
session.run("pytest", *session.posargs)


@nox.session
def test_sdist(session: nox.Session) -> None:
"""Test that the package works after creating and installing from sdist."""
# Install build tool
session.install("build")

# Create source distribution
session.run("python", "-m", "build", "--sdist", "--outdir", session.cache_dir)

# Find the created sdist file
import glob
sdist_files = glob.glob(str(session.cache_dir / "*.tar.gz"))
if not sdist_files:
session.error("No sdist file found")

# Install from sdist along with dev dependencies
dev_deps = get_dev_dependencies()
session.install(sdist_files[0], *dev_deps)

# Run tests to ensure everything works
session.run("pytest", *session.posargs)


@nox.session
def docs(session: nox.Session) -> None:
"""Invoke sphinx-build to build the HTML docs."""
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dev = [
"numpy",
"matplotlib",
"cocotbext-spi",
"tomli",
]

docs = [
Expand Down