Skip to content

Commit

Permalink
🚜 Refactors nox and streamlines pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Triplett committed Sep 28, 2023
1 parent 8ad1fd8 commit 9a8b6b2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
9 changes: 6 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
just --fmt --unstable

@nox *ARGS:
nox --no-install --reuse-existing-virtualenvs {{ ARGS }}
python -m nox --no-install --reuse-existing-virtualenvs {{ ARGS }}

@pip-compile:
pip-compile --resolver=backtracking
python -m piptools compile --resolver=backtracking

@pre-commit:
git ls-files -- . | xargs pre-commit run --config=.pre-commit-config.yaml --files

@test *ARGS:
nox --reuse-existing-virtualenvs {{ ARGS }}
python -m nox --reuse-existing-virtualenvs \
--session "test_django_version" \
--session "test_python_version" \
{{ ARGS }}
25 changes: 21 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
import nox

# DJANGO_STABLE_VERSION should be set to the latest Django LTS version
# and should *not* appear in DJANGO_VERSIONS

DJANGO_STABLE_VERSION = ["4.2"]
DJANGO_STABLE_VERSION = "4.2"
DJANGO_VERSIONS = ["3.2", "4.1", "main"]

PYTHON_STABLE_VERSION = ["3.11"]
# PYTHON_STABLE_VERSION should be set to the latest stable Python version
# and should *not* appear in PYTHON_VERSIONS

PYTHON_STABLE_VERSION = "3.11"
PYTHON_VERSIONS = ["3.8", "3.9", "3.10"]


@nox.session(python=PYTHON_STABLE_VERSION, tags=["django"])
@nox.session
def lint(session):
session.install(".[lint]")
session.run("python", "-m", "pre_commit", "run", "--all-files")


@nox.session(python=[PYTHON_STABLE_VERSION], tags=["django"])
@nox.parametrize("django", DJANGO_VERSIONS)
def test_django_version(session: nox.Session, django: str) -> None:
if django == DJANGO_STABLE_VERSION:
session.skip()

session.install(".[test]")

if django == "main":
Expand All @@ -22,8 +36,11 @@ def test_django_version(session: nox.Session, django: str) -> None:


@nox.session(python=PYTHON_VERSIONS, tags=["python"])
@nox.parametrize("django", DJANGO_STABLE_VERSION)
@nox.parametrize("django", [DJANGO_STABLE_VERSION])
def test_python_version(session: nox.Session, django: str) -> None:
if session.python == PYTHON_STABLE_VERSION:
session.skip()

session.install(".[test]")
session.install(f"django~={django}")
session.run("pytest", *session.posargs)
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ zip_safe = False
tests_require = django-friendship[test]

[options.extras_require]
lint =
pre-commit
test =
black
pytest
Expand Down

0 comments on commit 9a8b6b2

Please sign in to comment.