Skip to content

Commit 6873b3f

Browse files
authored
Run pre-commit in GitHub Actions (#72)
* make pre-commit pass * Bump pre-commit repos * Rename deprecated hook * Add no-commit-to-branch hook * Run pre-commit in GitHub Actions * Lint is not test, extract in a different workflow
1 parent 59e2665 commit 6873b3f

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

.github/workflows/lint.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
workflow_call:
8+
9+
permissions:
10+
contents: read
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
FORCE_COLOR: "1"
15+
PYTHONUNBUFFERED: "1"
16+
UV_VERSION: "0.4.x"
17+
18+
jobs:
19+
pre-commit:
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
enable-cache: true
28+
version: ${{ env.UV_VERSION }}
29+
30+
- uses: actions/cache@v4
31+
with:
32+
path: ~/.cache/pre-commit/
33+
key: pre-commit-1|${{ hashFiles('.pre-commit-config.yaml') }}
34+
35+
- name: pre-commit
36+
run: |
37+
SKIP=no-commit-to-branch \
38+
uv run --with pre-commit-uv pre-commit run \
39+
--all-files \
40+
--show-diff-on-failure \
41+
--color always

.pre-commit-config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
5-
- id: check-byte-order-marker
5+
- id: fix-byte-order-marker
66
- id: check-case-conflict
77
- id: check-merge-conflict
88
- id: check-symlinks
99
- id: check-toml
1010
- id: check-yaml
11+
args: ["--unsafe"] # breaks on .mkdocs.yml otherwise
1112
- id: end-of-file-fixer
1213
- id: mixed-line-ending
1314
- id: trailing-whitespace
15+
- id: no-commit-to-branch
16+
args: ["--branch", "main"]
1417
- repo: https://github.com/backplane/pre-commit-rust-hooks
1518
rev: v1.1.0
1619
hooks:

0 commit comments

Comments
 (0)