From 245af37ec51e5061eb02e3524ff4154cefe93ff1 Mon Sep 17 00:00:00 2001 From: Manuel Lera-Ramirez Date: Thu, 3 Oct 2024 10:31:02 +0100 Subject: [PATCH] update CI action to enforce hooks (#277) * update CI action to enforce hooks * update action --- .../pydna_test_and_coverage_workflow.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/pydna_test_and_coverage_workflow.yml b/.github/workflows/pydna_test_and_coverage_workflow.yml index d9a6d869..6a1386d3 100644 --- a/.github/workflows/pydna_test_and_coverage_workflow.yml +++ b/.github/workflows/pydna_test_and_coverage_workflow.yml @@ -61,6 +61,28 @@ jobs: - name: 🔎 poetry run python run_test.py run: poetry run python run_test.py + # Enforce pre-commit hooks =========================== + - name: Get changed files + if: (matrix.codecov) + id: changed-files + uses: tj-actions/changed-files@v45 + + - uses: actions/cache@v4 + if: (matrix.codecov) + 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: (matrix.codecov) && (steps.cache-precommit.outputs.cache-hit != 'true') + run: poetry run pre-commit install --install-hooks + + - name: Run style checking via pre-commit + if: (matrix.codecov) + 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