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 <andrew.vaillancourt@windriver.com>
This commit is contained in:
Andrew Vaillancourt 2025-05-07 21:31:34 -04:00
parent fd6877b088
commit 66bc9b9fc5
2 changed files with 12 additions and 2 deletions

View File

@ -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]

View File

@ -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
-------------