aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/pre-commit.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/pre-commit.yml')
-rw-r--r--.github/workflows/pre-commit.yml38
1 files changed, 38 insertions, 0 deletions
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
new file mode 100644
index 0000000..5d65b99
--- /dev/null
+++ b/.github/workflows/pre-commit.yml
@@ -0,0 +1,38 @@
+name: python + Bazel pre-commit checks
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ pre-commit:
+ runs-on: ubuntu-latest
+ env:
+ MYPY_CACHE_DIR: "${{ github.workspace }}/.cache/mypy"
+ RUFF_CACHE_DIR: "${{ github.workspace }}/.cache/ruff"
+ PRE_COMMIT_HOME: "${{ github.workspace }}/.cache/pre-commit"
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: 3.11
+ cache: pip
+ cache-dependency-path: pyproject.toml
+ - name: Install dependencies
+ run: python -m pip install ".[dev]"
+ - name: Cache pre-commit tools
+ uses: actions/cache@v3
+ with:
+ path: |
+ ${{ env.MYPY_CACHE_DIR }}
+ ${{ env.RUFF_CACHE_DIR }}
+ ${{ env.PRE_COMMIT_HOME }}
+ key: ${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}-linter-cache
+ - name: Run pre-commit checks
+ run: pre-commit run --all-files --verbose --show-diff-on-failure