Skip to content

Commit 357eca1

Browse files
Add pre-commit configuration and CI workflow
- Add .pre-commit-config.yaml with hooks for ruff, black, codespell, and whitelist validation - Add GitHub Actions workflow for pre-commit CI on pull requests - Add pre-commit to dev dependencies in pyproject.toml - Fix ruff configuration by removing invalid 'concise' output format - Update codespell ignore list to handle existing spelling issues in icon data The pre-commit configuration reuses existing tool configurations: - Ruff settings from pyproject.toml - Codespell settings from .codespellrc - Black version matches project dependencies - Whitelist validation uses same logic as existing CI Co-Authored-By: Alek <[email protected]>
1 parent a604517 commit 357eca1

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[codespell]
22
skip = *.csv, *.json
3-
ignore-words-list = selectin
3+
ignore-words-list = selectin,contruction,knowledgable,savety,unsecure

.github/workflows/pre-commit.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
pre-commit:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install the latest version of uv
17+
uses: astral-sh/setup-uv@v6
18+
with:
19+
python-version: "3.11"
20+
activate-environment: true
21+
22+
- name: Install the project
23+
run: uv sync --locked --all-extras --dev
24+
25+
- name: Run pre-commit
26+
run: uv run pre-commit run --all-files

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.1.6
12+
hooks:
13+
- id: ruff
14+
args: [--fix, --exit-non-zero-on-fix]
15+
- id: ruff-format
16+
17+
- repo: https://github.com/psf/black
18+
rev: 23.10.0
19+
hooks:
20+
- id: black
21+
22+
- repo: https://github.com/codespell-project/codespell
23+
rev: v2.2.6
24+
hooks:
25+
- id: codespell
26+
args: [--config=.codespellrc]
27+
28+
- repo: local
29+
hooks:
30+
- id: whitelist-check
31+
name: Check whitelist is empty
32+
entry: python3
33+
language: system
34+
args: [-c, "exec(open('pcweb/whitelist.py').read()); assert not WHITELISTED_PAGES, f'WHITELISTED_PAGES includes {WHITELISTED_PAGES}'"]
35+
files: ^pcweb/whitelist\.py$

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ dependencies = [
2727
]
2828

2929
[dependency-groups]
30-
dev = ["pytest", "playwright", "pytest-playwright", "uvicorn"]
30+
dev = ["pytest", "playwright", "pytest-playwright", "uvicorn", "pre-commit"]
3131

3232
[tool.setuptools.packages.find]
3333
where = ["pcweb"]
3434

3535
[tool.ruff]
3636
target-version = "py311"
37-
output-format = "concise"
3837
lint.isort.split-on-trailing-comma = false
3938
lint.select = [
4039
"ANN001",

0 commit comments

Comments
 (0)