Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Pre-commit Checks

on:
# Allow manual trigger
workflow_dispatch:

# Run on push to main branch
push:
branches:
- main

# Run on pull requests to main branch
pull_request:
branches:
- main

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Install prek
run: |
uv tool install prek

- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-

- name: Run pre-commit with prek
run: |
uv tool run prek run --all-files

- name: Upload pre-commit results
if: always()
uses: actions/upload-artifact@v4
with:
name: pre-commit-results
path: |
.pre-commit.log
if-no-files-found: ignore
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- locust-compare
- config-utils
- wt-worktree
# Just test for 3.12
# Just test for 3.12
# uncomment if you want to test for all versions
# python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.12"]
Expand All @@ -34,4 +34,3 @@ jobs:
python -m pip install --upgrade pip
pip install -e .[dev]
python -m pytest -v

8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ cython_debug/
# Ruff stuff:
.ruff_cache/

# Pre-commit cache
.pre-commit-cache/

# Interrogate badge
interrogate_badge.svg

# PyPI configuration file
.pypirc

Expand All @@ -220,4 +226,4 @@ __marimo__/
.DS_Store

# Locust
test_runs/
test_runs/
74 changes: 74 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Pre-commit hooks configuration using prek
# See https://github.com/pre-commit/pre-commit-hooks for more hooks

repos:
# Ruff - Fast Python linter and formatter (replaces flake8, isort, black, etc.)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
# Run the linter
- id: ruff
args: [--fix]
# Run the formatter
- id: ruff-format

# Pyright - Astral's type checker
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.390
hooks:
- id: pyright

# Pre-commit hooks for general file cleanup
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# Prevent giant files from being committed
- id: check-added-large-files
args: ['--maxkb=1000']
# Check for files that would conflict in case-insensitive filesystems
- id: check-case-conflict
# Check for merge conflicts
- id: check-merge-conflict
# Check for debugger imports and py37+ breakpoint()
- id: debug-statements
# Ensure files end in a newline
- id: end-of-file-fixer
# Trim trailing whitespace
- id: trailing-whitespace
# Check YAML files for parseable syntax
- id: check-yaml
# Check TOML files for parseable syntax
- id: check-toml
# Check JSON files for parseable syntax
- id: check-json
# Ensure JSON files are properly formatted
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys', '--indent=2']
# Fix mixed line endings
- id: mixed-line-ending
args: ['--fix=lf']
# Check for private keys
- id: detect-private-key

# Check for common security issues
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
hooks:
- id: bandit
args: ['-c', 'pyproject.toml']
additional_dependencies: ['bandit[toml]']

# Markdown linting
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.43.0
hooks:
- id: markdownlint
args: ['--fix']

# Python docstring coverage
- repo: https://github.com/econchick/interrogate
rev: 1.7.0
hooks:
- id: interrogate
args: [--fail-under=0, --verbose]
pass_filenames: false
7 changes: 4 additions & 3 deletions Agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ If you need to create more tasks do it in inside PRD.md and under a story where

Add appropirate test for your work. try not to use mocks unless necessary

Mark a task done in PRD after the task is completed and tests are passing
Mark a task done in PRD after the task is completed and tests are passing

Build/update README.md at the end if the story is finished

Your final commit should include just that folder and selected items from its contents:

- The notes.md, PRD.md and README.md files
- Any code you wrote along the way
- If you checked out and modified an existing repo, the output of "git diff" against that modified repo saved as a file - but not a copy of the full repo
Expand All @@ -26,12 +27,14 @@ After everything is done update the root README.md with the tool's information
## Running Tests

**First time setup:**

```bash
cd tools/<tool-name>
uv pip install -e ".[dev]" # Install with dev dependencies
```

**Run tests:**

```bash
uv run pytest tests/ -v # Verbose output
uv run pytest tests/ -v --cov=<pkg> # With coverage (if configured in pyproject.toml)
Expand All @@ -49,5 +52,3 @@ uv run pytest tests/test_foo.py::test_bar -v # Run specific test
5. **Document learnings**: Add to notes.md as you discover gotchas or solutions
6. **Test as you go**: Run tests after each significant change, not just at the end
7. **Git config in tests**: Disable GPG signing in test fixtures: `git config commit.gpgsign false`


2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Option 1: uv tool install
Each tool can be installed independently using `uvx` directly from GitHub:

For example:

```bash
# Install locust-compare
uv tool install 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools/locust-compare'
Expand All @@ -29,6 +30,7 @@ uv tool install 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=
```

After installation, you can run from anywhere:

```bash
locust-compare <base_dir> <current_dir>
config-utils capture-env
Expand Down
Loading
Loading