Skip to content

Commit 6e465c0

Browse files
committed
[REF] Add pre-commit workflow
1 parent e8e749d commit 6e465c0

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

.github/workflows/pre-commit.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "*"
7+
push:
8+
branches:
9+
- "master"
10+
11+
jobs:
12+
pre-commit:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-python@v2
17+
with:
18+
python-version: "3.8"
19+
- name: Get python version
20+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
21+
- uses: actions/cache@v1
22+
with:
23+
path: ~/.cache/pre-commit
24+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
25+
- name: Install pre-commit
26+
run: pip install pre-commit
27+
- name: Run pre-commit
28+
run: pre-commit run --all-files --show-diff-on-failure --color=always
29+
- name: Check that all files generated by pre-commit are in git
30+
run: |
31+
newfiles="$(git ls-files --others --exclude-from=.gitignore)"
32+
if [ "$newfiles" != "" ] ; then
33+
echo "Please check-in the following files:"
34+
echo "$newfiles"
35+
exit 1
36+
fi

0 commit comments

Comments
 (0)