From fca56d269cd3be1138a2f48ceb331038c81d6609 Mon Sep 17 00:00:00 2001 From: Jordan Kowal Date: Fri, 18 Oct 2024 16:34:03 +0200 Subject: [PATCH] feat: improved githooks --- .githooks/pre-commit | 13 +++++++++---- CONTRIBUTING.md | 12 ++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 2a93ed2..c757664 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -5,24 +5,29 @@ echo "---------- Git hook: pre-commit ----------" # Ruff (imports, lint, and format) echo "" -echo ">>> [1/4] Running Ruff" +echo ">>> [1/5] Running Ruff" ruff check --select I . ruff check . ruff format --check . # Flake8 (lint) echo "" -echo ">>> [2/4] Running Flake8" +echo ">>> [2/5] Running Flake8" flake8 . # MyPy (type checking) echo "" -echo ">>> [3/4] Running MyPy" +echo ">>> [3/5] Running MyPy" mypy . # Pyright (type checking) echo "" -echo ">>> [4/4] Running Pyright" +echo ">>> [4/5] Running Pyright" pyright . +# Run tests +echo "" +echo ">>> [5/5] Running tests" +python -m unittest discover . + echo "------------------------------------------" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dbfbd9e..2427a54 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,18 +45,18 @@ Run the following command to tell `git` to look for hooks in this folder: git config core.hooksPath .githooks ``` -### Linters +Pre-commit hooks will run `ruff`, `flake8`, `mypy`, `pyright`, and `unittest` on each commit. -In both the CI and githooks, we use both `ruff` and `flake8`. -This is mostly to ensure and test how both linters react to the pipe syntax -and better document in the [README.md](README.md)] the required setups. +### Linters -The same goes for `mypy`. +In both the CI and githooks, we use both `ruff` and `flake8`, and both `mypy` and `pyright`. +This is mostly to ensure that our implementation is compatible with the most common +linters and type checkers. ### CI/CD We use GitHub actions to verify, build, and deploy the application. We currently have: -- [code_quality](.github/workflows/code_quality.yml): runs `ruff`, `flake8`, `mypy`, and `coverage` on Python 3.12 +- [code_quality](.github/workflows/code_quality.yml): runs `ruff`, `flake8`, `mypy`, `pyright`, and `coverage` on Python 3.12 - [tests](.github/workflows/tests.yml): runs unittests on multiple Python versions (from 3.9 to 3.12) - [update_deps](.github/workflows/update_deps.yml): updates the dependencies (as `dependabot` does not support `uv` yet)