diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dffe101..584df3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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' @@ -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] @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0cfc3d5..125b430 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/CLAUDE.md b/CLAUDE.md index e1e940d..fb992ef 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 diff --git a/Makefile b/Makefile index bd5824b..6a55ff4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.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" @@ -6,7 +6,6 @@ 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 @@ -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 @@ -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 -# ---------------------------- \ No newline at end of file diff --git a/README.md b/README.md index 101b943..2ea5382 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ make environment-create 4. Run tests to make sure everything works: ```bash -make unit-test +make test ``` ## Project Structure @@ -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 @@ -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