forked from pre-commit/action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
32 lines (32 loc) · 1003 Bytes
/
action.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
name: pre-commit
description: run pre-commit
inputs:
extra_args:
description: options to pass to pre-commit run
required: false
default: '--all-files'
runs:
using: composite
steps:
- run: python -m pip install pre-commit
shell: bash
- run: python -m pip freeze --local
shell: bash
- run: |
tf=$(mktemp)
echo "arch=$(uname -p)" >> "$tf"
for program in python ruby go cargo ; do
if command -v $program >/dev/null 2>&1 ; then
echo "$program=$(which $program)" >> "$tf"
fi
done
hash="$(sha256sum < "$tf" | awk '{print $1}')"
echo "dependencyHash=${hash}" >> $GITHUB_OUTPUT
shell: bash
id: computeDependencies
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ steps.computeDependencies.outputs.dependencyHash }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
shell: bash