Skip to content

Commit

Permalink
Add GitHub action for linting. Resolves #13 (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbowen777 authored Dec 31, 2024
1 parent 62e8b96 commit d517e67
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 146 deletions.
13 changes: 0 additions & 13 deletions .coveragerc

This file was deleted.

13 changes: 0 additions & 13 deletions .flake8

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/nox-lint_multi-arch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: nox-lint_multi-arch
on: push
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
name: Python ${{ matrix.python-version }} xfce-repocapp
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
architecture: x64
- run: pip install nox==2024.10.09
- run: pip install poetry==1.8.5
- run: |
nox -s lint-${{ matrix.python-version }}
53 changes: 9 additions & 44 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import nox

nox.options.sessions = "lint", "safety", "tests"
PYTHON_VERSIONS = ["3.10", "3.11", "3.12", "3.13"]
nox.options.sessions = "lint", "tests"
locations = (
"src",
"./noxfile.py",
Expand Down Expand Up @@ -41,64 +42,28 @@ def install_with_constraints(session, *args, **kwargs):
session.install(f"--requirement={requirements.name}", *args, **kwargs)


@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
def black(session):
"""Run black code formatter."""
args = session.posargs or locations
install_with_constraints(session, "black")
session.run("black", *args)


@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
@nox.session(python=PYTHON_VERSIONS)
def docs(session):
"""Build the documentation."""
install_with_constraints(session, "sphinx")
session.run("sphinx-build", "docs", "docs/_build")


@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
@nox.session(python=PYTHON_VERSIONS)
def lint(session):
"""Lint using flake8."""
"""Lint using ruff."""
args = session.posargs or locations
install_with_constraints(
session,
"flake8",
"flake8-bandit",
"flake8-black",
"flake8-bugbear",
# "flake8-docstrings",
"flake8-import-order",
"ruff",
)
session.run("flake8", *args)


@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
def safety(session):
"""Scan dependencies for insecure packages."""
with tempfile.NamedTemporaryFile() as requirements:
session.run(
"poetry",
"export",
"--with",
"dev",
"--format=requirements.txt",
"--without-hashes",
f"--output={requirements.name}",
external=True,
)
install_with_constraints(session, "safety")
session.run(
"safety",
"check",
f"--file={requirements.name}",
"--full-report",
)
session.run("ruff", "check", ".", *args)


@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8"])
@nox.session(python=PYTHON_VERSIONS)
def tests(session):
"""Run the test suite."""
args = session.posargs or ["--cov"]
args = session.posargs
with tempfile.NamedTemporaryFile() as requirements:
session.run(
"poetry",
Expand Down
37 changes: 35 additions & 2 deletions poetry.lock

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

55 changes: 24 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,14 @@ ruff = ">=0.8, <1.0"
nox = "2024.10.09"
pytest = ">=8.0, <8.4"
pytest-cov = ">=6.0.0, <7.0"
pytest-sugar = "1.0.0"
coverage = { version = ">=7.0.0, <8.0.0", extras = ["toml"] }
pylint = "^3.0"
sphinx = ">= 8.0, <9.0"

[tool.black]
line-length = 79
# include =
exclude = '''
/(
\.git
| __pycache__
| .pytest_cache
| .idea
| logs
| .venv
| build
| dist
)/
'''

[tool.coverage.paths]
source = ["src"]

[tool.coverage.run]
branch = true
dynamic_context = "test_function"
source = ["src"]
omit = [
"*/__init__.py",
Expand All @@ -61,13 +44,6 @@ precision = 2
show_contexts = true
title = "xfce-repocapp coverage report"

[tool.isort]
profile = "black"
multi_line_output = 3
skip = ["*.gitignore"]
extend_skip = ["*.md", "*.json"]
line_length = 79

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
Expand All @@ -82,10 +58,10 @@ respect-gitignore = true
unsafe-fixes = false

# Same as Black.
line-length = 79
line-length = 88

# Assume Python 3.10.
target-version = "py312"
# Assume Python 3.13.x
target-version = "py313"

# Exclude a variety of commonly ignored directories.
exclude = [
Expand All @@ -97,12 +73,29 @@ exclude = [
"_build",
"build",
"dist",
"htmlcov",
]

[tool.ruff.lint]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = []
select = [
"B", # flake8-bugbear
"C90", # mccabe
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"S", # flake8-bandit
"W", # pycodestyle warnings
"RUF", # ruff checks
]
ignore = [
"E501", # line too long ({width} > {limit} characters)
# "E203", # slice notation whitespace (not currently supported)
"E402", # module level import not at top of file
"E722", # do not use bare except
# "W503", # (not currently supported)
"ERA", # do not autoremove commented out code
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
Expand Down
12 changes: 9 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ exceptiongroup==1.2.2 ; python_full_version >= "3.10.0" and python_version < "3.
filelock==3.16.1 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
--hash=sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0 \
--hash=sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435
identify==2.6.3 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
--hash=sha256:62f5dae9b5fef52c84cc188514e9ea4f3f636b1d8799ab5ebc475471f9e47a02 \
--hash=sha256:9edba65473324c2ea9684b1f944fe3191db3345e50b6d04571d10ed164f8d7bd
identify==2.6.4 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
--hash=sha256:285a7d27e397652e8cafe537a6cc97dd470a970f48fb2e9d979aa38eae5513ac \
--hash=sha256:993b0f01b97e0568c179bb9196391ff391bfb88a99099dbf5ce392b68f42d0af
idna==3.10 ; python_version >= "3.10" and python_full_version < "3.14.0" \
--hash=sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9 \
--hash=sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3
Expand Down Expand Up @@ -306,6 +306,9 @@ pytest==8.3.4 ; python_full_version >= "3.10.0" and python_full_version < "3.14.
pytest-cov==6.0.0 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
--hash=sha256:eee6f1b9e61008bd34975a4d5bab25801eb31898b032dd55addc93e96fcaaa35 \
--hash=sha256:fde0b595ca248bb8e2d76f020b465f3b107c9632e6a1d1705f17834c89dcadc0
pytest-sugar==1.0.0 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
--hash=sha256:6422e83258f5b0c04ce7c632176c7732cab5fdb909cb39cca5c9139f81276c0a \
--hash=sha256:70ebcd8fc5795dc457ff8b69d266a4e2e8a74ae0c3edc749381c64b5246c8dfd
pyyaml==6.0.2 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
--hash=sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff \
--hash=sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48 \
Expand Down Expand Up @@ -406,6 +409,9 @@ sphinxcontrib-qthelp==2.0.0 ; python_version >= "3.10" and python_full_version <
sphinxcontrib-serializinghtml==2.0.0 ; python_version >= "3.10" and python_full_version < "3.14.0" \
--hash=sha256:6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331 \
--hash=sha256:e9d912827f872c029017a53f0ef2180b327c3f7fd23c87229f7a8e8b70031d4d
termcolor==2.5.0 ; python_full_version >= "3.10.0" and python_full_version < "3.14.0" \
--hash=sha256:37b17b5fc1e604945c2642c872a3764b5d547a48009871aea3edd3afa180afb8 \
--hash=sha256:998d8d27da6d48442e8e1f016119076b690d962507531df4890fcd2db2ef8a6f
tomli==2.2.1 ; python_version >= "3.10" and python_full_version <= "3.11.0a6" \
--hash=sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6 \
--hash=sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd \
Expand Down
Loading

0 comments on commit d517e67

Please sign in to comment.