Skip to content

Commit 42c49da

Browse files
committed
chore: add pre-commit
1 parent 49ea03a commit 42c49da

File tree

3 files changed

+56
-32
lines changed

3 files changed

+56
-32
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,54 @@
11
name: CI
2-
32
on:
43
push:
5-
branches: [ master, main ]
4+
branches: [master, main]
65
pull_request:
7-
86
env:
97
CARGO_TERM_COLOR: always
10-
118
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.13"
16+
- uses: pre-commit/[email protected]
1217
style:
1318
runs-on: ubuntu-latest
1419
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v5
17-
- uses: dtolnay/rust-toolchain@stable
18-
with:
19-
components: rustfmt,clippy
20-
toolchain: 1.91.1
21-
- uses: Swatinem/rust-cache@v2
22-
- name: cargo fmt
23-
run: cargo fmt --all -- --check
24-
- name: cargo clippy
25-
run: cargo clippy -- -D warnings
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
- uses: dtolnay/rust-toolchain@stable
23+
with:
24+
components: rustfmt,clippy
25+
toolchain: 1.91.1
26+
- uses: Swatinem/rust-cache@v2
27+
- name: cargo fmt
28+
run: cargo fmt --all -- --check
29+
- name: cargo clippy
30+
run: cargo clippy -- -D warnings
2631
test:
2732
runs-on: ubuntu-latest
2833
strategy:
2934
matrix:
3035
rust: ["1.85.0", stable, beta]
3136
steps:
32-
- uses: actions/checkout@v5
33-
- uses: dtolnay/rust-toolchain@stable
34-
with:
35-
toolchain: ${{ matrix.rust }}
36-
- uses: Swatinem/rust-cache@v2
37-
- name: Test
38-
run: cargo test --all-features
37+
- uses: actions/checkout@v5
38+
- uses: dtolnay/rust-toolchain@stable
39+
with:
40+
toolchain: ${{ matrix.rust }}
41+
- uses: Swatinem/rust-cache@v2
42+
- name: Test
43+
run: cargo test --all-features
3944
audit:
4045
runs-on: ubuntu-latest
4146
steps:
42-
- uses: actions/checkout@v5
43-
- uses: dtolnay/rust-toolchain@stable
44-
with:
45-
toolchain: stable
46-
- uses: taiki-e/install-action@v2
47-
with:
48-
tool: cargo-audit
49-
- run: cargo audit
50-
47+
- uses: actions/checkout@v5
48+
- uses: dtolnay/rust-toolchain@stable
49+
with:
50+
toolchain: stable
51+
- uses: taiki-e/install-action@v2
52+
with:
53+
tool: cargo-audit
54+
- run: cargo audit

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- id: check-case-conflict
8+
- id: check-illegal-windows-names
9+
- id: check-merge-conflict
10+
- id: check-symlinks
11+
- id: check-toml
12+
- id: check-yaml
13+
- id: check-json
14+
- repo: https://github.com/google/yamlfmt
15+
rev: v0.17.2
16+
hooks:
17+
- id: yamlfmt
18+
- repo: https://github.com/rhysd/actionlint
19+
rev: v1.7.8
20+
hooks:
21+
- id: actionlint

LICENSE.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ Copyright 2016-2019 James Brown
33
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
44

55
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6-

0 commit comments

Comments
 (0)