forked from cjolowicz/cookiecutter-hypermodern-python
-
Notifications
You must be signed in to change notification settings - Fork 1
37 lines (36 loc) · 1.35 KB
/
pre-commit.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
name: pre-commit
on: [push, pull_request]
jobs:
pre-commit:
runs-on: ubuntu-latest
name: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
python-version: "3.11"
- run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=.github/workflows/constraints.txt pre-commit
- name: Compute cache key prefix
if: matrix.os != 'windows-latest'
id: cache_key_prefix
shell: python
run: |
import hashlib
import subprocess
import sys
python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest)
cmd = f'echo "result={result}" >> $GITHUB_OUTPUT'
subprocess.run(cmd, shell=True)
- uses: actions/cache@v3
if: matrix.os != 'windows-latest'
with:
path: ~/.cache/pre-commit
key: ${{ steps.cache_key_prefix.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.cache_key_prefix.outputs.result }}-
- run: pre-commit run --all-files --show-diff-on-failure --color=always