Skip to content

Commit 249ab62

Browse files
committed
Update pre-commit workflow to support both master and main branches, and upgrade action versions
1 parent b688009 commit 249ab62

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,39 @@ name: pre-commit
33
on:
44
pull_request:
55
push:
6-
branches: [master]
6+
branches: [master, main]
77

88
jobs:
99
pre-commit:
1010
runs-on: ubuntu-latest
11+
timeout-minutes: 15
1112
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-python@v2
14-
- uses: pre-commit/action@v2.0.3
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.11'
20+
21+
- name: Cache pre-commit environments
22+
uses: actions/cache@v3
23+
with:
24+
path: ~/.cache/pre-commit
25+
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
26+
restore-keys: |
27+
pre-commit-${{ runner.os }}-
28+
continue-on-error: true
29+
30+
- name: Install pre-commit (fallback)
31+
if: failure()
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install pre-commit
35+
36+
- name: Run pre-commit
37+
uses: pre-commit/action@v3.0.0
38+
continue-on-error: false
39+
env:
40+
# Reduce memory usage for pre-commit
41+
PRE_COMMIT_COLOR: never

0 commit comments

Comments
 (0)