-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (58 loc) · 2.19 KB
/
pre_commit_checks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Pre-commit Checks
on:
push:
branches:
- main
pull_request:
branches:
- "**"
jobs:
pre_commit:
runs-on: ubuntu-latest
env:
# Set the Python version that `uv` will use for its virtual environment.
UV_PYTHON: 3.13
steps:
- uses: actions/checkout@v4
- name: Set up base Python
uses: actions/setup-python@v5
with:
# Note that this is just the version of Python that we use to run `uv` with.
# `uv` manages its own version of Python.
# For speed, we use the same version for both, but in principle these could differ.
python-version: ${{ env.UV_PYTHON }}
- name: Set up cache directories
run: |
echo "UV_CACHE_DIR=${{ runner.temp }}/.uv-cache" >> $GITHUB_ENV
echo "PRE_COMMIT_HOME=${{ runner.temp }}/.pre-commit" >> $GITHUB_ENV
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}-${{ env.UV_PYTHON }}-dev
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}-${{ env.UV_PYTHON }}
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Restore pre-commit cache
uses: actions/cache@v4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: pre_commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre_commit-${{ runner.os }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Install uv
run: pip install uv
- name: Install latest dependencies
run: uv sync --dev --locked
- name: Debug - uv pip freeze
run: uv pip freeze
- name: Remove fail_fast from Pre-commit config
run: sed -e "/fail_fast/d" .pre-commit-config.yaml > /tmp/.pre-commit-config-ci.yaml
- name: Run Pre-commit checks
run: SKIP=no-commit-to-branch uv run pre-commit run --all-files --show-diff-on-failure --config /tmp/.pre-commit-config-ci.yaml
- name: Minimize UV cache
run: uv cache prune --ci
if: always()