Skip to content

Commit 1ebc9e7

Browse files
authored
ci: Add pre-commit workflow (#28)
1 parent f5ef019 commit 1ebc9e7

File tree

5 files changed

+88
-43
lines changed

5 files changed

+88
-43
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/pr_pre-commit.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: pre-commit
3+
4+
on:
5+
pull_request:
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.11", "3.12"]
13+
steps:
14+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
15+
with:
16+
fetch-depth: 0
17+
- name: Setup Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Run pre-commit (Python ${{ matrix.python-version }})
22+
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
23+
with:
24+
extra_args: "--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}"

.markdownlint.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
# All defaults or options can be checked here:
3+
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
4+
5+
# Default state for all rules
6+
default: true
7+
8+
# MD013/line-length - Line length
9+
MD013:
10+
# Number of characters
11+
line_length: 9999
12+
# Number of characters for headings
13+
heading_line_length: 9999
14+
# Number of characters for code blocks
15+
code_block_line_length: 9999
16+
17+
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
18+
MD024:
19+
# Only check sibling headings
20+
siblings_only: true

.pre-commit-config.yaml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,57 @@
1-
# See https://pre-commit.com for more information
2-
# See https://pre-commit.com/hooks.html for more hooks
1+
---
2+
default_language_version:
3+
node: system
4+
35
repos:
46
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v3.2.0
7+
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # 4.6.0
68
hooks:
79
- id: trailing-whitespace
810
- id: end-of-file-fixer
9-
- id: check-yaml
10-
exclude: examples/
11+
- id: detect-aws-credentials
12+
args: ["--allow-missing-credentials"]
13+
- id: detect-private-key
1114
- id: check-added-large-files
12-
- repo: https://github.com/Yelp/detect-secrets
13-
rev: v1.4.0
15+
- id: check-symlinks
16+
17+
- repo: https://github.com/adrienverge/yamllint
18+
rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # 1.35.1
1419
hooks:
15-
- id: detect-secrets
16-
exclude: examples/
17-
- repo: https://github.com/pre-commit/mirrors-autopep8
18-
rev: v2.0.1
20+
- id: yamllint
21+
22+
- repo: https://github.com/igorshubovych/markdownlint-cli
23+
rev: f295829140d25717bc79368d3f966fc1f67a824f # 0.41.0
24+
hooks:
25+
- id: markdownlint
26+
27+
- repo: https://github.com/koalaman/shellcheck-precommit
28+
rev: 2491238703a5d3415bb2b7ff11388bf775372f29 # 0.10.0
29+
hooks:
30+
- id: shellcheck
31+
args: ["--severity=info"]
32+
33+
- repo: https://github.com/rhysd/actionlint
34+
rev: 62dc61a45fc95efe8c800af7a557ab0b9165d63b # 1.7.1
1935
hooks:
20-
- id: autopep8
21-
entry: autopep8
36+
- id: actionlint
37+
2238
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
# Ruff version.
24-
rev: v0.0.275
39+
rev: f1ebc5730d98440041cc43e4d69829ad598ae1e7 # 0.6.3
2540
hooks:
2641
- id: ruff
42+
args: [--fix]
43+
- id: ruff-format
44+
2745
- repo: https://github.com/pre-commit/mirrors-mypy
28-
rev: 'v1.4.0'
46+
rev: d4911cfb7f1010759fde68da196036feeb25b99d # 1.11.2
2947
hooks:
3048
- id: mypy
3149
args: ['--install-types', '--non-interactive']
3250
additional_dependencies:
3351
- "Jinja2>=3.1.2"
3452
- "PyYAML>=6.0"
3553
exclude: examples/
54+
3655
- repo: local
3756
hooks:
3857
- id: unittest

.yamllint.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length: disable
6+
truthy:
7+
check-keys: false
8+
comments:
9+
min-spaces-from-content: 1 # Needed due to https://github.com/adrienverge/yamllint/issues/443

0 commit comments

Comments
 (0)