From 66bc9b9fc5767433eae96bb32a36e8f4e7c34b45 Mon Sep 17 00:00:00 2001 From: Andrew Vaillancourt Date: Wed, 7 May 2025 21:31:34 -0400 Subject: [PATCH] Enable pre-push unit test check via pre-commit Adds a new pre-push hook to .pre-commit-config.yaml that runs `pytest unit_tests/` before allowing any push, including `git review`. This ensures that regressions in fast-running unit tests are caught before changes are submitted for review. To activate the hook locally: pre-commit install --hook-type pre-commit pre-commit install --hook-type pre-push Change-Id: Ia2d0fe56eabf6466e27f0432ac2fb91c7b444832 Signed-off-by: Andrew Vaillancourt --- .pre-commit-config.yaml | 7 +++++++ README.rst | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d0197a8f..ae315bfb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,3 +72,10 @@ repos: language: python types: [python] args: ["--fail-under", "100", "--ignore-module", "--ignore-init-method", "--ignore-nested-functions", "--verbose"] + + - id: unit-tests + name: Run unit tests before push + entry: bash -c 'pytest unit_tests/' + language: system + pass_filenames: false + stages: [push] diff --git a/README.rst b/README.rst index c204c2a3..8fed1254 100644 --- a/README.rst +++ b/README.rst @@ -99,10 +99,13 @@ Setup and Installation 4. **Install Pre-Commit Hooks**: + Pre-commit hooks are used to enforce code formatting, linting, and unit testing before code is committed or pushed for review. + .. code-block:: bash - # Install pre-commit hooks for linting and formatting (run in the repository's root directory) - pre-commit install + # Install hooks for commit-time (linting, formatting) and push-time (unit test enforcement) + pre-commit install --hook-type pre-commit + pre-commit install --hook-type pre-push Configuration -------------