Skip to content

Commit 4343ca6

Browse files
committed
Implement pre-commit and linting GitHub action
1 parent 3667658 commit 4343ca6

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'github-actions'
4+
directory: '/'
5+
schedule:
6+
interval: 'weekly'
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: 'pip'
10+
directory: '/'
11+
schedule:
12+
interval: 'weekly'
13+
open-pull-requests-limit: 10

.github/workflows/linters.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Linters
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
linters:
12+
name: Run Linters
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v5
17+
18+
- name: Debug GitHub Variables
19+
run: |
20+
echo "github.event_name: ${{ github.event_name }}"
21+
echo "github.ref_name: ${{ github.ref_name }}"
22+
echo "github.event.repository.default_branch: ${{ github.event.repository.default_branch }}"
23+
24+
- name: Setup Python 3 (with caching)
25+
uses: actions/setup-python@v6
26+
id: setup-python
27+
with:
28+
python-version: 3.12
29+
cache: 'pip'
30+
cache-dependency-path: |
31+
pyproject.toml
32+
33+
- name: Install Linting Requirements
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install --group dev -e .
37+
38+
- name: Cache pre-commit
39+
uses: actions/cache@v4
40+
with:
41+
path: |
42+
~/.cache/pre-commit
43+
key: ${{ runner.os }}-lint-py${{ steps.setup-python.outputs.python-version || '3.x' }}-${{ hashFiles('**/.pre-commit-config.yaml', '**/pyproject.toml') }}
44+
restore-keys: |
45+
${{ runner.os }}-lint-
46+
47+
- name: Run pre-commit
48+
uses: pre-commit/action@v3.0.1
49+
50+
- uses: pre-commit-ci/lite-action@v1.1.0
51+
if: always()

.pre-commit-config.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
exclude: '.*\.md$'
9+
- id: end-of-file-fixer
10+
exclude: '.*\.md$'
11+
- id: check-yaml
12+
- id: check-toml
13+
- id: check-added-large-files
14+
- id: check-ast
15+
- id: check-merge-conflict
16+
17+
- repo: https://github.com/rhysd/actionlint
18+
rev: v1.7.9
19+
hooks:
20+
- id: actionlint
21+
22+
# Note: shellcheck cannot directly parse YAML; actionlint extracts workflow
23+
# shell blocks and calls shellcheck when available.
24+
- repo: https://github.com/shellcheck-py/shellcheck-py
25+
rev: v0.11.0.1
26+
hooks:
27+
- id: shellcheck
28+
# Match by detected shell file type (extensions or shebang)
29+
types: [shell]
30+
args: ['-x']
31+
32+
- repo: https://github.com/codespell-project/codespell
33+
rev: v2.4.1
34+
hooks:
35+
- id: codespell
36+
additional_dependencies:
37+
- tomli
38+
39+
- repo: https://github.com/astral-sh/ruff-pre-commit
40+
rev: v0.14.6
41+
hooks:
42+
# Run the linter.
43+
- id: ruff-check
44+
args: [--fix]
45+
# Run the formatter.
46+
- id: ruff-format
47+
48+
ci:
49+
autofix_prs: true
50+
autoupdate_schedule: weekly
51+
skip: []
52+
submodules: false

0 commit comments

Comments
 (0)