Skip to content

Commit 615c91e

Browse files
Merge pull request #91 from sanafayyaz315/pre-commit-hooks-clean
chore: add ruff, markdownlint, and file-hygiene pre-commit hooks
2 parents e537e34 + 6214c46 commit 615c91e

27 files changed

Lines changed: 130 additions & 50 deletions

File tree

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,41 @@ repos:
2020
- --subject-min-length=10
2121
- --subject-max-length=72
2222
- --allow-breaking
23+
24+
# Standard file-hygiene hooks (run before linters so they see clean files)
25+
- repo: https://github.com/pre-commit/pre-commit-hooks
26+
rev: v5.0.0
27+
hooks:
28+
- id: trailing-whitespace
29+
- id: end-of-file-fixer
30+
- id: check-yaml
31+
args: [--allow-multiple-documents]
32+
exclude: ^charts/
33+
- id: check-json
34+
- id: check-toml
35+
- id: check-merge-conflict
36+
- id: check-added-large-files
37+
args: [--maxkb=1000]
38+
- id: debug-statements
39+
- id: check-case-conflict
40+
- id: mixed-line-ending
41+
- id: no-commit-to-branch
42+
args: [--branch=main]
43+
- id: detect-private-key
44+
45+
# Ruff — Python linting and formatting
46+
# Rules are defined in ruff.toml at the repo root
47+
- repo: https://github.com/astral-sh/ruff-pre-commit
48+
rev: v0.15.11
49+
hooks:
50+
- id: ruff
51+
args: [--fix, --exit-non-zero-on-fix]
52+
- id: ruff-format
53+
54+
# Markdownlint — Markdown linting
55+
# Rules are defined in .markdownlint.jsonc at the repo root
56+
- repo: https://github.com/DavidAnson/markdownlint-cli2
57+
rev: v0.22.1
58+
hooks:
59+
- id: markdownlint-cli2
60+
args: [--fix]

CONTRIBUTING.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,51 @@ uv tool install pre-commit
2323
pre-commit install --install-hooks
2424
```
2525

26-
After this, every `git commit` will automatically validate your commit message format (see below).
26+
After this, every `git commit` will automatically run the checks listed in [Pre-commit hooks](#pre-commit-hooks) on your staged files. Commits that fail any check will be blocked.
27+
28+
If you haven't run `pre-commit install --install-hooks`, hooks will **not** run automatically. In that case, you can run all checks manually before committing:
29+
30+
```bash
31+
pre-commit run --all-files
32+
```
33+
34+
## Pre-commit hooks
35+
36+
The following hooks run automatically on every commit. They are defined in [`.pre-commit-config.yaml`](.pre-commit-config.yaml).
37+
38+
### Conventional commits
39+
40+
Enforces the [Conventional Commits](https://www.conventionalcommits.org/) format on commit messages (see [Commit message conventions](#commit-message-conventions) below). Runs at the `commit-msg` stage.
41+
42+
### Python linting and formatting (ruff)
43+
44+
Two hooks from [ruff](https://docs.astral.sh/ruff/):
45+
46+
- **ruff** — lints Python files and auto-fixes issues. Rules are defined in [`ruff.toml`](ruff.toml).
47+
- **ruff-format** — enforces consistent formatting (quotes, indentation, line length).
48+
49+
### Markdown linting (markdownlint)
50+
51+
Lints `.md` files and auto-fixes what it can (e.g., list indentation, code block languages). Rules are defined in [`.markdownlint.jsonc`](.markdownlint.jsonc); ignored paths in [`.markdownlint-cli2.yaml`](.markdownlint-cli2.yaml).
52+
53+
### File-hygiene hooks
54+
55+
General-purpose checks from [pre-commit/pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks):
56+
57+
| Hook | What it does |
58+
| ---- | ------------ |
59+
| `trailing-whitespace` | Removes trailing whitespace from all files |
60+
| `end-of-file-fixer` | Ensures every file ends with a newline |
61+
| `check-yaml` | Validates YAML syntax (excludes `charts/` — Helm templates use Go syntax) |
62+
| `check-json` | Validates JSON syntax |
63+
| `check-toml` | Validates TOML syntax |
64+
| `check-merge-conflict` | Detects leftover merge conflict markers |
65+
| `check-added-large-files` | Blocks files larger than 1 MB |
66+
| `debug-statements` | Catches leftover `breakpoint()` / `pdb` calls in Python |
67+
| `check-case-conflict` | Detects filenames that differ only in case |
68+
| `mixed-line-ending` | Ensures consistent line endings (no mixed LF/CRLF) |
69+
| `no-commit-to-branch` | Blocks direct commits to `main` |
70+
| `detect-private-key` | Catches accidentally committed private keys |
2771

2872
## Linting and formatting
2973

agents/a2a/langgraph_crewai_agent/src/a2a_langgraph_crewai/images/rh_logo.svg

Lines changed: 9 additions & 9 deletions
Loading

agents/autogen/mcp_agent/images/rh_logo.svg

Lines changed: 9 additions & 9 deletions
Loading

agents/autogen/mcp_agent/mcp_automl_template/AUTOML_DEPLOYMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ See: [Model Deployment](https://github.com/red-hat-data-services/red-hat-ai-exam
127127

128128
- Open the **deployment details**. Under **Inference endpoint**, copy the **external** URL (only if you enabled the external route).
129129
- **Deployment URL** for the MCP server is the **predict** endpoint, for example:
130-
- `<EXTERNAL_BASE_URL>/v1/models/<MODEL_NAME>:predict`
130+
- `<EXTERNAL_BASE_URL>/v1/models/<MODEL_NAME>:predict`
131131
where `<MODEL_NAME>` is the deployment’s **Resource name** (lowercase, no spaces). Example: `https://my-model-myproject.apps.example.com/v1/models/my-churn-model:predict`
132132
- **Token** (if you enabled token auth): **Projects***your project***Deployments** → expand the deployment → use the **Token secret** value as `DEPLOYMENT_TOKEN`.
133133

agents/autogen/mcp_agent/mcp_automl_template/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies = [
2323

2424
[project.optional-dependencies]
2525
dev = [
26-
"pytest>=9.0.2,<10.0.0",
26+
"pytest>=9.0.2,<10.0.0",
2727
]
2828

2929
[tool.setuptools]

agents/crewai/websearch_agent/.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ MODEL_ID=ollama/llama3.1:8b
1717
# MLFLOW_WORKSPACE=default
1818
# LLM_PROVIDER=litellm
1919
# MLFLOW_TRACKING_AUTH= # Use Kubernetes service account for authentication (if running inside the cluster)
20-

agents/crewai/websearch_agent/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ requires-python = ">=3.12,<3.14"
88
dependencies = [
99
"fastapi>=0.135.1",
1010
"uvicorn[standard]>=0.41.0",
11-
"crewai[litellm]>=1.11.0",
11+
"crewai[litellm]>=1.11.0",
1212
"litellm!=1.82.7,!=1.82.8", # Block compromised PyPI releases
1313
"python-dotenv>=1.1.1,<1.2.0", # CrewAI pins ~=1.1.1
1414
"setuptools>=80.9.0,<82.0.0",

agents/google/adk/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ API_KEY=not-needed-for-local-development
1010
#PORT=
1111

1212
## Deployment Configuration (for OpenShift/Kubernetes)
13-
#CONTAINER_IMAGE=
13+
#CONTAINER_IMAGE=

agents/langflow/simple_tool_calling_agent/flows/outdoor-activity-agent.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2283,4 +2283,4 @@
22832283
"action_name": null,
22842284
"action_description": null,
22852285
"access_type": "PRIVATE"
2286-
}
2286+
}

0 commit comments

Comments
 (0)