Skip to content

Commit 8bef979

Browse files
authored
Merge pull request #309 from input-output-hk/cached_precommit
chore(ci): improve lint workflow with pre-commit caching
2 parents a226508 + 155bfa4 commit 8bef979

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

.github/workflows/repo_lint.yaml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,30 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v4
15-
- uses: actions/setup-python@v5
14+
- name: Check out repository
15+
uses: actions/checkout@v4
16+
- name: Set up python
17+
id: setup-python
18+
uses: actions/setup-python@v5
1619
with:
17-
python-version: '3.10'
20+
python-version: '3.11'
1821
- name: Install dependencies
1922
run: make install
20-
- name: Run lint
21-
run: make lint || { git diff; false; }
23+
- name: Load cached pre-commit env
24+
id: cached-pre-commit
25+
uses: actions/cache@v4
26+
with:
27+
path: ~/.cache/pre-commit
28+
key: pre-commit-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
29+
- name: Install pre-commit hooks
30+
run: |
31+
mkdir -p ~/.cache/pre-commit
32+
true > ~/.cache/pre-commit/pre-commit.log
33+
pre-commit install-hooks --color=always
34+
retval="$?"
35+
if [ "$retval" -ne 0 ]; then
36+
cat ~/.cache/pre-commit/pre-commit.log
37+
fi
38+
exit "$retval"
39+
- name: Run pre-commit linters
40+
run: pre-commit run -a --show-diff-on-failure --color=always

0 commit comments

Comments
 (0)