From 44c16a772440651adc197e373ec6d6401bfb2dea Mon Sep 17 00:00:00 2001 From: Manuel Lera-Ramirez Date: Thu, 3 Oct 2024 10:22:08 +0100 Subject: [PATCH] update CI action to enforce hooks --- .../pydna_test_and_coverage_workflow.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/pydna_test_and_coverage_workflow.yml b/.github/workflows/pydna_test_and_coverage_workflow.yml index d9a6d869..9d53d367 100644 --- a/.github/workflows/pydna_test_and_coverage_workflow.yml +++ b/.github/workflows/pydna_test_and_coverage_workflow.yml @@ -61,6 +61,25 @@ jobs: - name: 🔎 poetry run python run_test.py run: poetry run python run_test.py + # Enforce pre-commit hooks =========================== + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v45 + + - uses: actions/cache@v4 + id: cache-precommit + with: + path: ~/.cache/pre-commit + key: ${{ runner.os }}-precommit-hooks-v2-${{ hashFiles('**/.pre-commit-config.yaml') }} + + - name: Installing pre-commit hooks (cached) + if: steps.cache-precommit.outputs.cache-hit != 'true' + run: poetry run pre-commit install --install-hooks + + - name: Run style checking via pre-commit + run: poetry run pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }} + # ====================================================== + - name: 🔼 Upload coverage to Codecov if: (matrix.codecov) uses: codecov/codecov-action@v1.0.13