Skip to content

Commit 3abe193

Browse files
committed
feat: combine various styling nox sessions in cicd
1 parent 78fae0d commit 3abe193

File tree

3 files changed

+14
-29
lines changed

3 files changed

+14
-29
lines changed

{{cookiecutter.project_name}}/noxfile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
DOCS: str = "docs"
4444
BUILD: str = "build"
4545
RELEASE: str = "release"
46-
CI: str = "ci"
46+
QUALITY: str = "quality"
4747
PYTHON: str = "python"
4848
RUST: str = "rust"
4949

@@ -60,7 +60,7 @@ def setup_venv(session: Session) -> None:
6060
session.run("python", SCRIPTS_FOLDER / "setup-venv.py", REPO_ROOT, "-p", PYTHON_VERSIONS[0], external=True)
6161

6262

63-
@nox.session(python=DEFAULT_PYTHON_VERSION, name="pre-commit", tags=[CI])
63+
@nox.session(python=DEFAULT_PYTHON_VERSION, name="pre-commit", tags=[QUALITY])
6464
def precommit(session: Session) -> None:
6565
"""Lint using pre-commit."""
6666
args: list[str] = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
@@ -73,7 +73,7 @@ def precommit(session: Session) -> None:
7373
activate_virtualenv_in_precommit_hooks(session)
7474

7575

76-
@nox.session(python=False, name="format-python", tags=[FORMAT, PYTHON])
76+
@nox.session(python=False, name="format-python", tags=[FORMAT, PYTHON, QUALITY])
7777
def format_python(session: Session) -> None:
7878
"""Run Python code formatter (Ruff format)."""
7979
session.log(f"Running Ruff formatter check with py{session.python}.")
@@ -91,7 +91,7 @@ def format_rust(session: Session) -> None:
9191

9292

9393
{% endif -%}
94-
@nox.session(python=False, name="lint-python", tags=[LINT, PYTHON])
94+
@nox.session(python=False, name="lint-python", tags=[LINT, PYTHON, QUALITY])
9595
def lint_python(session: Session) -> None:
9696
"""Run Python code linters (Ruff check, Pydocstyle rules)."""
9797
session.log(f"Running Ruff check with py{session.python}.")
@@ -109,7 +109,7 @@ def lint_rust(session: Session) -> None:
109109

110110

111111
{% endif -%}
112-
@nox.session(python=PYTHON_VERSIONS, name="typecheck", tags=[TYPE, PYTHON, CI])
112+
@nox.session(python=PYTHON_VERSIONS, name="typecheck", tags=[TYPE, PYTHON])
113113
def typecheck(session: Session) -> None:
114114
"""Run static type checking (Pyright) on Python code."""
115115
session.log("Installing type checking dependencies...")
@@ -119,7 +119,7 @@ def typecheck(session: Session) -> None:
119119
session.run("pyright", "--pythonversion", session.python)
120120

121121

122-
@nox.session(python=False, name="security-python", tags=[SECURITY, PYTHON, CI])
122+
@nox.session(python=False, name="security-python", tags=[SECURITY, PYTHON])
123123
def security_python(session: Session) -> None:
124124
"""Run code security checks (Bandit) on Python code."""
125125
session.log(f"Running Bandit static security analysis with py{session.python}.")
@@ -130,7 +130,7 @@ def security_python(session: Session) -> None:
130130

131131

132132
{% if cookiecutter.add_rust_extension == 'y' -%}
133-
@nox.session(python=False, name="security-rust", tags=[SECURITY, RUST, CI])
133+
@nox.session(python=False, name="security-rust", tags=[SECURITY, RUST])
134134
def security_rust(session: Session) -> None:
135135
"""Run code security checks (cargo audit)."""
136136
session.log("Installing security dependencies...")
@@ -139,7 +139,7 @@ def security_rust(session: Session) -> None:
139139

140140

141141
{% endif -%}
142-
@nox.session(python=PYTHON_VERSIONS, name="tests-python", tags=[TEST, PYTHON, CI])
142+
@nox.session(python=PYTHON_VERSIONS, name="tests-python", tags=[TEST, PYTHON])
143143
def tests_python(session: Session) -> None:
144144
"""Run the Python test suite (pytest with coverage)."""
145145
session.log("Installing test dependencies...")

{{cookiecutter.project_name}}/{% if cookiecutter.repository_provider == 'github' %}.github{% endif %}/workflows/lint-python.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,5 @@ jobs:
4545
with:
4646
python-version-file: ".github/workflows/.python-version"
4747

48-
- name: Run formatting checks
49-
run: uvx nox -s format-python
50-
51-
- name: Run linting checks
52-
run: uvx nox -s lint-python
48+
- name: Run Python quality checks
49+
run: uvx nox -t quality

{{cookiecutter.project_name}}/{% if cookiecutter.repository_provider == 'gitlab' %}.gitlab-ci.yml{% endif %}

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,19 @@ stages:
4545
after_script:
4646
- uv cache prune --ci
4747

48-
# Python Quality Checks Jobs
49-
format-python:
48+
# Python Quality Checks Job
49+
quality-python:
5050
<<: *quality-job
5151
script:
52-
- uvx nox -s format-python
53-
changes:
54-
- "src/**/*.py"
55-
- "tests/**/*.py"
56-
- "noxfile.py"
57-
- "pyproject.toml"
58-
- ".ruff.toml"
59-
- ".pydocstyle"
60-
- ".gitlab-ci.yml"
61-
62-
lint-python:
63-
<<: *quality-job
64-
script:
65-
- uvx nox -s lint-python
52+
- uvx nox -t quality
6653
changes:
6754
- "src/**/*.py"
6855
- "tests/**/*.py"
6956
- "noxfile.py"
7057
- "pyproject.toml"
7158
- ".ruff.toml"
7259
- ".pydocstyle"
60+
- "pyrightconfig.json"
7361
- ".gitlab-ci.yml"
7462

7563
typecheck-python:

0 commit comments

Comments
 (0)