diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index af3f513..1a915d9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,6 +22,7 @@ jobs: python-pyflakes reuse mypy python-pyqt6 python-tomli-w python-black python-isort + codespell - name: Checkout uses: actions/checkout@v4 - name: Add safe git directory diff --git a/src/bubblejail/bubblejail_helper.py b/src/bubblejail/bubblejail_helper.py index b0c2d38..7bbd5b6 100644 --- a/src/bubblejail/bubblejail_helper.py +++ b/src/bubblejail/bubblejail_helper.py @@ -335,7 +335,7 @@ async def client_handler(self, reader: StreamReader, writer: StreamWriter) -> No line = await reader.readline() if not line: if __debug__: - print("Reached end of reader. Returnning", flush=True) + print("Reached end of reader. Returning", flush=True) writer.close() await writer.wait_closed() return diff --git a/src/bubblejail/services.py b/src/bubblejail/services.py index e98f62c..2eb7604 100644 --- a/src/bubblejail/services.py +++ b/src/bubblejail/services.py @@ -857,7 +857,7 @@ class Settings: outbound_addr: str = field( default="", metadata=SettingFieldMetadata( - pretty_name="Outbound address or deivce", + pretty_name="Outbound address or device", description=( "Address or device to bind to. " "If not set the default address would be used." diff --git a/tools/run_linters.py b/tools/run_linters.py index 938c92f..37764ee 100644 --- a/tools/run_linters.py +++ b/tools/run_linters.py @@ -3,7 +3,7 @@ from __future__ import annotations from pathlib import Path -from subprocess import CalledProcessError, run +from subprocess import PIPE, CalledProcessError, Popen, run from sys import stderr from .base import BUILD_DIR, PROJECT_ROOT_PATH, PYTHON_SOURCES @@ -71,6 +71,61 @@ def run_isort() -> bool: return False +def run_codespell() -> bool: + print("Running: codespell", file=stderr) + try: + list_of_files = run( + args=("git", "ls-files", "-z"), + cwd=PROJECT_ROOT_PATH, + stdout=PIPE, + text=True, + check=True, + ).stdout.split("\0") + run( + args=[ + "codespell", + "--check-filenames", + "--enable-colors", + "--context", + "3", + *list_of_files, + ], + check=True, + ) + except CalledProcessError: + return True + + return False + + +def run_codespell_on_commits() -> bool: + print("Running: git log to codespell", file=stderr) + try: + git_log = Popen( + args=( + "git", + "log", + "--max-count=50", + "--no-merges", + r"--format='%H%n%n%s%n%n%b'", + ), + cwd=PROJECT_ROOT_PATH, + stdout=PIPE, + ) + + run( + args=("codespell", "--enable-colors", "--context", "3", "-"), + cwd=PROJECT_ROOT_PATH, + check=True, + stdin=git_log.stdout, + timeout=5, + ) + except CalledProcessError: + return True + + return bool(git_log.wait(3)) + + def main() -> None: BUILD_DIR.mkdir(exist_ok=True) @@ -81,6 +136,8 @@ def main() -> None: has_failed |= run_reuse() has_failed |= run_black() has_failed |= run_isort() + has_failed |= run_codespell() + has_failed |= run_codespell_on_commits() if has_failed: raise SystemExit(1)