Skip to content
Merged
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: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install dependencies
run: |
uv venv --python 3.12
make environment-sync
make sync

- name: Run linters
run: make lint
Expand All @@ -66,7 +66,7 @@ jobs:
- name: Install dependencies
run: |
uv venv --python 3.12
make environment-sync
make sync

- name: Run type checks
run: make type-check
Expand All @@ -91,10 +91,10 @@ jobs:
- name: Install dependencies
run: |
uv venv --python 3.12
make environment-sync
make sync

- name: Run tests
run: make unit-test
run: make test-unit

merged-test:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
Expand All @@ -119,10 +119,10 @@ jobs:
- name: Install dependencies
run: |
uv venv --python 3.12
make environment-sync
make sync

- name: Run tests
run: make unit-test
run: make test-unit

release:
needs: [lint, type-check, test]
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
- name: Install dependencies
run: |
uv venv --python 3.12
make environment-sync
make sync
uv pip install python-semantic-release

- name: Configure Git
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
pass_filenames: false
- id: unit-tests
name: Run unit tests
entry: make unit-test
entry: make test-unit
language: system
stages: [pre-commit]
verbose: true
Expand Down
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ make validate-branch # Run all checks before PR

### Testing
```bash
make unit-test # Run unit tests
make functional-test # Run functional tests
make all-test # Run all tests with coverage
make test-unit # Run unit tests
make test-functional # Run functional tests
make test # Run standard tests with coverage
make test-all # Run all tests with coverage
```

## Development Workflow
Expand Down
107 changes: 50 additions & 57 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
.PHONY: default help clean-project environment-create environment-sync environment-delete environment-list sync-env format lint type-check unit-test functional-test integration-test all-test validate-branch validate-branch-strict test-validate-branch all-test-validate-branch local-run build-engine auth-gcloud
.PHONY: default help clean-project init clean-env sync format lint type-check test test-unit test-functional test-integration test-all validate-branch

GREEN_LINE=@echo "\033[0;32m--------------------------------------------------\033[0m"

SOURCE_DIR = ai_base_template/
TEST_DIR = tests/
PROJECT_VERSION := $(shell awk '/^\[project\]/ {flag=1; next} /^\[/{flag=0} flag && /^version/ {gsub(/"/, "", $$2); print $$2}' pyproject.toml)
PYTHON_VERSION := 3.12
CLIENT_ID = leogv

default: help

Expand All @@ -17,41 +16,43 @@ help: ## Display this help message
# Environment Management
# ----------------------------

clean-project: ## Clean Python caches and tooling artifacts
@echo "Cleaning project caches..."
find . -type d \( -name '.pytest_cache' -o -name '.ruff_cache' -o -name '.mypy_cache' -o -name '__pycache__' \) -exec rm -rf {} +
$(GREEN_LINE)

environment-create: ## Set up Python version, venv, and install dependencies
@echo "Installing uv and pre-commit if missing..."
init: ## Set up Python version, venv, and install dependencies
@echo "🔧 Installing uv if missing..."
@if ! command -v uv >/dev/null 2>&1; then \
echo "📦 Installing uv..."; \
python3 -m pip install --user --upgrade uv; \
else \
echo "✅ uv is already installed"; \
fi
@echo "Setting up Python $(PYTHON_VERSION) environment..."
@echo "🐍 Setting up Python $(PYTHON_VERSION) environment..."
uv python install $(PYTHON_VERSION)
uv venv --python $(PYTHON_VERSION)
. .venv/bin/activate && uv sync --extra dev
. .venv/bin/activate && uv pip install -e '.[dev]'
. .venv/bin/activate && uv pip install pre-commit
. .venv/bin/activate && uv run pre-commit install
$(GREEN_LINE)
uv venv --python $(PYTHON_VERSION) .venv
@echo "📦 Installing project dependencies..."
uv sync --extra dev
. .venv/bin/activate && uv pip install -e .
@echo "🔗 Setting up pre-commit hooks..."
@if [ -f .pre-commit-config.yaml ]; then \
uv run pre-commit install; \
echo "✅ Pre-commit hooks installed"; \
else \
echo "⚠️ No .pre-commit-config.yaml found, skipping pre-commit setup"; \
fi
@echo "🎉 Environment setup complete!"

environment-sync: ## Re-sync project dependencies using uv
@echo "Syncing up environment..."
. .venv/bin/activate && uv sync --extra dev
. .venv/bin/activate && uv pip install -e '.[dev]'
clean-project: ## Clean Python caches and tooling artifacts
@echo "Cleaning project caches..."
find . -type d \( -name '.pytest_cache' -o -name '.ruff_cache' -o -name '.mypy_cache' -o -name '__pycache__' \) -exec rm -rf {} +
$(GREEN_LINE)

sync-env: environment-sync ## Alias for environment-sync

environment-delete: ## Remove the virtual environment folder
clean-env: ## Remove the virtual environment folder
@echo "Deleting virtual environment..."
rm -rf .venv
$(GREEN_LINE)

environment-list: ## List installed packages
@echo "Listing packages in environment..."
. .venv/bin/activate && uv pip list
sync: ## Sync project dependencies
@echo "Syncing project dependencies..."
uv sync --extra dev
$(GREEN_LINE)

# ----------------------------
# Code Quality
Expand All @@ -76,56 +77,48 @@ type-check: ## Perform static type checks using mypy
# Tests
# ----------------------------

unit-test: ## Run unit tests with pytest
test-unit: ## Run unit tests with pytest
@echo "Running UNIT tests with pytest..."
uv run python -m pytest -vv --verbose -s $(TEST_DIR)
$(GREEN_LINE)

functional-test: ## Run functional tests with pytest
test-functional: ## Run functional tests with pytest
@echo "Running FUNCTIONAL tests with pytest..."
uv run python -m pytest -m functional -vv --verbose -s $(TEST_DIR)
$(GREEN_LINE)

integration-test: ## Run integration tests with pytest
test-integration: ## Run integration tests with pytest
@echo "Running INTEGRATION tests with pytest..."
uv run python -m pytest -m integration -vv --verbose -s $(TEST_DIR)
$(GREEN_LINE)

all-test: ## Run all tests with coverage report
@echo "Running ALL tests with pytest..."
test: ## Run standard tests with coverage report (excludes integration)
@echo "Running tests with pytest..."
uv run python -m pytest -m "not integration" -vv -s $(TEST_DIR) \
--cov=ai_base_template \
--cov-config=pyproject.toml \
--cov-fail-under=80 \
--cov-report=term-missing
$(GREEN_LINE)

test-all: ## Run all tests including integration tests
@echo "Running ALL tests with pytest..."
uv run python -m pytest -vv -s $(TEST_DIR) \
--cov=ai_base_template \
--cov-config=pyproject.toml \
--cov-fail-under=80 \
--cov-report=term-missing
$(GREEN_LINE)

# ----------------------------
# Branch Validation
# ----------------------------

validate-branch: ## Run formatting, linting, and tests (equivalent to old behavior)
@echo "🔍 Running validation checks..."
@echo "📝 Running linting..."
uv run ruff check .
@echo "✅ Linting passed!"
@echo "🧪 Running tests..."
uv run python -m pytest
@echo "✅ All tests passed!"
@echo "🎉 Branch validation successful - ready for PR!"

validate-branch-strict: ## Run formatting, linting, type checks, and tests
$(MAKE) sync-env
$(MAKE) format
validate-branch: ## Run linting, type checks, and tests
@echo "🔍 Running branch validation..."
$(MAKE) lint
$(MAKE) type-check
$(MAKE) test
@echo "🎉 Branch validation successful - ready for PR!"
$(GREEN_LINE)

test-validate-branch: ## Validate branch and run unit tests
$(MAKE) validate-branch
$(MAKE) unit-test
$(MAKE) clean-project

all-test-validate-branch: ## Validate branch and run all tests
$(MAKE) validate-branch
$(MAKE) all-test
$(MAKE) clean-project

# ----------------------------
# Local Development
# ----------------------------
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ make environment-create

4. Run tests to make sure everything works:
```bash
make unit-test
make test
```

## Project Structure
Expand Down Expand Up @@ -86,9 +86,9 @@ make type-check # Check types
make validate-branch # Run all checks (before committing)

# Testing
make unit-test # Run unit tests
make functional-test # Run functional tests
make all-test # Run all tests with coverage
make test # Run unit tests
make test-functional # Run functional tests
make test # Run all tests with coverage
```

### Adding Code
Expand Down Expand Up @@ -148,9 +148,9 @@ The template includes three test levels:

Run specific test types:
```bash
make unit-test
make functional-test
make integration-test
make test
make test-functional
make test-integration
```

## Starting Your Project
Expand Down
Loading