discord_bot/Makefile
Oleksandr Kozachuk fbec05dfe9 Fix hanging test and establish comprehensive development environment
- Fix infinite retry loop in ai_responder.py that caused test_fix1 to hang
- Add missing picture_edit parameter to all AIResponse constructor calls
- Set up complete development toolchain with Black, isort, Bandit, and MyPy
- Create comprehensive Makefile for development workflows
- Add pre-commit hooks with formatting, linting, security, and type checking
- Update test mocking to provide contextual responses for different scenarios
- Configure all tools for 140 character line length and strict type checking
- Add DEVELOPMENT.md with setup instructions and workflow documentation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 19:07:14 +02:00

100 lines
3.2 KiB
Makefile

# Fjerkroa Bot Development Makefile
.PHONY: help install install-dev clean test test-cov lint format type-check security-check all-checks pre-commit run build
# Default target
help: ## Show this help message
@echo "Fjerkroa Bot Development Commands:"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Installation targets
install: ## Install production dependencies
pip3.11 install -r requirements.txt
install-dev: install ## Install development dependencies and pre-commit hooks
pip3.11 install -e .
pre-commit install
# Cleaning targets
clean: ## Clean up temporary files and caches
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -delete
find . -type d -name "*.egg-info" -exec rm -rf {} +
find . -type d -name ".pytest_cache" -exec rm -rf {} +
find . -type d -name ".mypy_cache" -exec rm -rf {} +
find . -name ".coverage" -delete
rm -rf build dist htmlcov
# Testing targets
test: ## Run tests
python3.11 -m pytest -v
test-cov: ## Run tests with coverage report
python3.11 -m pytest --cov=fjerkroa_bot --cov-report=html --cov-report=term-missing
test-fast: ## Run tests without slow tests
python3.11 -m pytest -v -m "not slow"
# Code quality targets
lint: ## Run linter (flake8)
python3.11 -m flake8 fjerkroa_bot tests
format: ## Format code with black and isort
python3.11 -m black fjerkroa_bot tests
python3.11 -m isort fjerkroa_bot tests
format-check: ## Check if code is properly formatted
python3.11 -m black --check fjerkroa_bot tests
python3.11 -m isort --check-only fjerkroa_bot tests
type-check: ## Run type checker (mypy)
python3.11 -m mypy fjerkroa_bot tests
security-check: ## Run security scanner (bandit)
python3.11 -m bandit -r fjerkroa_bot --configfile pyproject.toml
# Combined targets
all-checks: lint format-check type-check security-check test ## Run all code quality checks and tests
pre-commit: format lint type-check security-check test ## Run all pre-commit checks (format, then check)
# Development targets
run: ## Run the bot (requires config.toml)
python3.11 -m fjerkroa_bot
run-dev: ## Run the bot in development mode with auto-reload
python3.11 -m watchdog.watchmedo auto-restart --patterns="*.py" --recursive -- python3.11 -m fjerkroa_bot
# Build targets
build: clean ## Build distribution packages
python3.11 setup.py sdist bdist_wheel
# CI targets
ci: install-dev all-checks ## Full CI pipeline (install deps and run all checks)
# Docker targets (if needed in future)
docker-build: ## Build Docker image
docker build -t fjerkroa-bot .
docker-run: ## Run bot in Docker container
docker run -d --name fjerkroa-bot fjerkroa-bot
# Utility targets
deps-update: ## Update dependencies (requires pip-tools)
python3.11 -m piptools compile requirements.in --upgrade
requirements-lock: ## Generate locked requirements
pip3.11 freeze > requirements-lock.txt
check-deps: ## Check for outdated dependencies
pip3.11 list --outdated
# Documentation targets (if needed)
docs: ## Generate documentation (placeholder)
@echo "Documentation generation not implemented yet"
# Database/migration targets (if needed)
migrate: ## Run database migrations (placeholder)
@echo "No migrations needed for this project"