Skip to content

Commit

Permalink
Merge pull request #7 from 12rambau/nox
Browse files Browse the repository at this point in the history
build: add nox automatic tests
  • Loading branch information
santiagobasulto committed Apr 27, 2023
2 parents 309170e + 58271aa commit eab7ed3
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,26 @@ jobs:
with:
python-version: "3.10"
- uses: pre-commit/action@v3.0.0

test:
needs: [lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
include:
- os: macos-latest # macos test
python-version: "3.10"
- os: windows-latest # windows test
python-version: "3.10"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install chore deps
run: python -m pip install nox poetry
- name: run the tests
run: nox -s test
43 changes: 43 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""All the process that can be run using nox.
The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder.
"""
import tempfile
from pathlib import Path

import nox


def install_poetry_groups(session: nox.Session, *groups: str) -> None:
"""Install dependencies from poetry groups.
Related to https://github.com/cjolowicz/nox-poetry/issues/663
"""
with tempfile.NamedTemporaryFile() as requirements:
session.run(
"poetry",
"export",
*[f"--only={group}" for group in groups],
"--format=requirements.txt",
"--without-hashes",
f"--output={requirements.name}",
external=True,
)
print(Path(requirements.name).read_text())
session.install("-r", requirements.name)


@nox.session(reuse_venv=True)
def lint(session):
"""Apply the pre-commits."""
session.install("pre-commit")
session.run("pre-commit", "run", "--a", *session.posargs)


@nox.session(reuse_venv=True)
def test(session):
"""Run all the test using the environment varialbe of the running machine."""
session.install(".")
install_poetry_groups(session, "test")
test_files = session.posargs or ["tests"]
session.run("pytest", "--color=yes", *test_files)
57 changes: 56 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ ipython = "^8.12.0"
[tool.poetry.group.dev.dependencies]
pre-commit = "^3.2.2"
pytest = "^7.3.1"
nox = "^2022.11.21"


[tool.poetry.group.test.dependencies]
pytest = "^7.3.1"
pytest-mock = "^3.10.0"

[build-system]
Expand Down

0 comments on commit eab7ed3

Please sign in to comment.