Skip to content
Closed
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
14 changes: 0 additions & 14 deletions .githooks/post-commit

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: Prek Checks

on:
pull_request:
Expand All @@ -10,9 +10,11 @@ on:
- '.github/workflows/**'

jobs:
lint:
prek:
if: github.event_name == 'pull_request' || github.event.pull_request == null
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
submodules: 'recursive'
- uses: j178/prek-action@v1
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
25 changes: 20 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@ check_jq:
jq --version; \
fi

check_prek:
@echo "$(YELLOW)🔍Checking prek version...$(RESET)"
@if ! command -v prek > /dev/null 2>&1; then \
echo "$(RED)prek is not installed. Please install prek before proceeding.$(RESET)"; \
echo "$(RED)curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.3/prek-installer.sh | sh$(RESET)"; \
exit 1; \
else \
prek --version; \
fi

########################################################
# Setup githooks for linting
########################################################
setup_githooks:
@echo "$(YELLOW)🔨Setting up githooks on post-commit...$(RESET)"
chmod +x .githooks/post-commit
git config core.hooksPath .githooks
install_hooks: check_prek
@echo "$(YELLOW)🔨Installing pre-commit hooks with prek...$(RESET)"
@git config --unset core.hooksPath || true
@prek install


########################################################
Expand All @@ -75,7 +85,7 @@ view_python_venv_size_by_libraries:
# Run Main Application
########################################################

all: update_python_dep setup_githooks
all: update_python_dep install_hooks
@echo "$(GREEN)🏁Running main application...$(RESET)"
@$(PYTHON) main.py
@echo "$(GREEN)✅ Main application run completed.$(RESET)"
Expand All @@ -102,6 +112,11 @@ test: check_rye
IGNORE_LINT_DIRS = .venv|venv
LINE_LENGTH = 88

lint: check_prek
@echo "$(YELLOW)🔍Running pre-commit hooks...$(RESET)"
@prek run --all-files
@echo "$(GREEN)✅Pre-commit hooks passed.$(RESET)"

fmt: check_rye check_jq
@echo "$(YELLOW)✨Formatting project with Black...$(RESET)"
@rye run black --exclude '/($(IGNORE_LINT_DIRS))/' . --line-length $(LINE_LENGTH)
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@
```
curl -sSf https://rye.astral.sh/get | bash
```
- [prek](https://github.com/j178/prek)
```
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.3/prek-installer.sh | sh
```

## Quick Start

- `make all` - runs `main.py`
- `make fmt` - runs `black` linter, an opinionated linter
- `make lint` - runs `prek` hooks (linting, formatting, checks)
- `make banner` - create a new banner that makes the README nice 😊
- `make test` - runs all tests defined by `TEST_TARGETS = tests/folder1 tests/folder2`

Expand All @@ -83,6 +88,7 @@
This software uses the following tools:
- [Cursor: The AI Code Editor](cursor.com)
- [Rye: a Hassle-Free Python Experience](https://rye.astral.sh/)
- [prek: Better pre-commit, re-engineered in Rust](https://github.com/j178/prek)
- [DSPY: Pytorch for LLM Inference](https://dspy.ai/)
- [LangFuse: LLM Observability Tool](https://langfuse.com/)

Expand Down
Loading