264 lines
8.0 KiB
Makefile
264 lines
8.0 KiB
Makefile
.PHONY: help install install-dev install-all update update-dev clean clean-all
|
|
.PHONY: test test-unit test-integration test-ui test-coverage test-fast
|
|
.PHONY: lint lint-flake8 lint-mypy lint-bandit lint-all
|
|
.PHONY: format format-check format-diff
|
|
.PHONY: build build-check build-dist upload-test upload-prod
|
|
.PHONY: docs docs-serve docs-build docs-clean
|
|
.PHONY: check security coverage-report
|
|
|
|
# Default target
|
|
.DEFAULT_GOAL := help
|
|
|
|
# Python executable
|
|
PYTHON := python3
|
|
PIP := pip3
|
|
PYTEST := pytest
|
|
BLACK := black
|
|
FLAKE8 := flake8
|
|
MYPY := mypy
|
|
ISORT := isort
|
|
BANDIT := bandit
|
|
SAFETY := safety
|
|
TWINE := twine
|
|
|
|
# Directories
|
|
SRC_DIRS := core plugins
|
|
TEST_DIR := tests
|
|
DOCS_DIR := docs
|
|
BUILD_DIR := build
|
|
DIST_DIR := dist
|
|
|
|
# =============================================================================
|
|
# HELP
|
|
# =============================================================================
|
|
|
|
help: ## Show this help message
|
|
@echo "EU-Utility Development Commands"
|
|
@echo "================================"
|
|
@echo ""
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
|
|
# =============================================================================
|
|
# INSTALLATION
|
|
# =============================================================================
|
|
|
|
install: ## Install production dependencies
|
|
$(PIP) install -e .
|
|
|
|
install-dev: ## Install development dependencies
|
|
$(PIP) install -e ".[dev]"
|
|
|
|
install-all: ## Install all dependencies including optional features
|
|
$(PIP) install -e ".[all,dev]"
|
|
|
|
install-spotify: ## Install with Spotify support
|
|
$(PIP) install -e ".[spotify]"
|
|
|
|
install-discord: ## Install with Discord Rich Presence support
|
|
$(PIP) install -e ".[discord]"
|
|
|
|
update: ## Update production dependencies
|
|
$(PIP) install --upgrade -e .
|
|
|
|
update-dev: ## Update development dependencies
|
|
$(PIP) install --upgrade -e ".[dev]"
|
|
|
|
update-all: ## Update all dependencies
|
|
$(PIP) install --upgrade -e ".[all,dev]"
|
|
|
|
# =============================================================================
|
|
# TESTING
|
|
# =============================================================================
|
|
|
|
test: ## Run all tests
|
|
$(PYTEST) $(TEST_DIR) -v
|
|
|
|
test-unit: ## Run unit tests only
|
|
$(PYTEST) $(TEST_DIR) -v -m unit
|
|
|
|
test-integration: ## Run integration tests only
|
|
$(PYTEST) $(TEST_DIR) -v -m integration
|
|
|
|
test-ui: ## Run UI tests only
|
|
$(PYTEST) $(TEST_DIR) -v -m ui
|
|
|
|
test-performance: ## Run performance benchmarks
|
|
$(PYTEST) $(TEST_DIR) -v -m performance --benchmark-only
|
|
|
|
test-coverage: ## Run tests with coverage report
|
|
$(PYTEST) $(TEST_DIR) -v --cov=$(SRC_DIRS) --cov-report=term-missing --cov-report=html
|
|
|
|
test-coverage-xml: ## Run tests with XML coverage report
|
|
$(PYTEST) $(TEST_DIR) -v --cov=$(SRC_DIRS) --cov-report=xml
|
|
|
|
test-fast: ## Run fast tests only (excludes slow and UI tests)
|
|
$(PYTEST) $(TEST_DIR) -v -m "not slow and not ui"
|
|
|
|
test-parallel: ## Run tests in parallel (requires pytest-xdist)
|
|
$(PYTEST) $(TEST_DIR) -v -n auto
|
|
|
|
# =============================================================================
|
|
# CODE QUALITY
|
|
# =============================================================================
|
|
|
|
lint: lint-flake8 lint-mypy ## Run all linters
|
|
|
|
lint-flake8: ## Run flake8 linter
|
|
$(FLAKE8) $(SRC_DIRS) $(TEST_DIR)
|
|
|
|
lint-mypy: ## Run mypy type checker
|
|
$(MYPY) $(SRC_DIRS)
|
|
|
|
lint-bandit: ## Run bandit security linter
|
|
$(BANDIT) -r $(SRC_DIRS) -f txt
|
|
|
|
lint-pydocstyle: ## Run pydocstyle docstring checker
|
|
pydocstyle $(SRC_DIRS)
|
|
|
|
lint-all: lint-flake8 lint-mypy lint-bandit lint-pydocstyle ## Run all linters
|
|
|
|
format: ## Format code with black and isort
|
|
$(BLACK) $(SRC_DIRS) $(TEST_DIR)
|
|
$(ISORT) $(SRC_DIRS) $(TEST_DIR)
|
|
|
|
format-check: ## Check code formatting without modifying files
|
|
$(BLACK) --check $(SRC_DIRS) $(TEST_DIR)
|
|
$(ISORT) --check-only $(SRC_DIRS) $(TEST_DIR)
|
|
|
|
format-diff: ## Show formatting changes without applying them
|
|
$(BLACK) --diff $(SRC_DIRS) $(TEST_DIR)
|
|
|
|
# =============================================================================
|
|
# SECURITY
|
|
# =============================================================================
|
|
|
|
security: security-bandit security-safety ## Run all security checks
|
|
|
|
security-bandit: ## Run bandit security analysis
|
|
$(BANDIT) -r $(SRC_DIRS) -f json -o bandit-report.json || true
|
|
$(BANDIT) -r $(SRC_DIRS) -f txt
|
|
|
|
security-safety: ## Run safety check for known vulnerabilities
|
|
$(SAFETY) check
|
|
|
|
security-pip-audit: ## Run pip-audit for dependency vulnerabilities
|
|
pip-audit --desc
|
|
|
|
# =============================================================================
|
|
# BUILD & DISTRIBUTION
|
|
# =============================================================================
|
|
|
|
build: clean-build ## Build source and wheel distributions
|
|
$(PYTHON) -m build
|
|
|
|
build-check: ## Check the built distributions
|
|
$(TWINE) check $(DIST_DIR)/*
|
|
|
|
build-dist: build build-check ## Build and check distributions
|
|
|
|
upload-test: build-dist ## Upload to TestPyPI
|
|
$(TWINE) upload --repository testpypi $(DIST_DIR)/*
|
|
|
|
upload-prod: build-dist ## Upload to PyPI (requires credentials)
|
|
$(TWINE) upload $(DIST_DIR)/*
|
|
|
|
# =============================================================================
|
|
# DOCUMENTATION
|
|
# =============================================================================
|
|
|
|
docs: docs-build ## Build documentation
|
|
|
|
docs-build: ## Build Sphinx documentation
|
|
cd $(DOCS_DIR) && $(MAKE) html
|
|
|
|
docs-serve: docs-build ## Serve documentation locally
|
|
cd $(DOCS_DIR)/_build/html && $(PYTHON) -m http.server 8000
|
|
|
|
docs-clean: ## Clean documentation build files
|
|
cd $(DOCS_DIR) && $(MAKE) clean
|
|
|
|
docs-live: ## Serve documentation with auto-reload (requires sphinx-autobuild)
|
|
sphinx-autobuild $(DOCS_DIR) $(DOCS_DIR)/_build/html --watch $(SRC_DIRS)
|
|
|
|
# =============================================================================
|
|
# CLEANUP
|
|
# =============================================================================
|
|
|
|
clean: ## Remove build artifacts and cache files
|
|
rm -rf $(BUILD_DIR)
|
|
rm -rf $(DIST_DIR)
|
|
rm -rf *.egg-info
|
|
rm -rf .eggs
|
|
rm -rf .pytest_cache
|
|
rm -rf .mypy_cache
|
|
rm -rf .coverage
|
|
rm -rf htmlcov
|
|
rm -rf coverage.xml
|
|
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
find . -type f -name "*.pyc" -delete
|
|
find . -type f -name "*.pyo" -delete
|
|
find . -type f -name "*.so" -delete
|
|
|
|
clean-all: clean ## Remove all generated files including virtual environments
|
|
rm -rf .venv
|
|
rm -rf venv
|
|
rm -rf env
|
|
rm -rf .tox
|
|
rm -rf bandit-report.json
|
|
|
|
# =============================================================================
|
|
# UTILITY
|
|
# =============================================================================
|
|
|
|
check: format-check lint test-fast ## Run all checks (format, lint, fast tests)
|
|
|
|
ci: clean install-dev format-check lint test-coverage security ## Full CI pipeline
|
|
|
|
coverage-report: ## Open coverage report in browser
|
|
$(PYTHON) -m webbrowser htmlcov/index.html
|
|
|
|
requirements: ## Generate requirements.txt from pyproject.toml
|
|
$(PIP) freeze > requirements.txt
|
|
|
|
dependency-tree: ## Show dependency tree
|
|
pipdeptree
|
|
|
|
pre-commit: ## Install and run pre-commit hooks
|
|
pre-commit install
|
|
pre-commit run --all-files
|
|
|
|
# =============================================================================
|
|
# DEVELOPMENT
|
|
# =============================================================================
|
|
|
|
run: ## Run EU-Utility
|
|
$(PYTHON) -m core.main
|
|
|
|
run-secure: ## Run EU-Utility (secure/optimized version)
|
|
$(PYTHON) -m core.main_optimized
|
|
|
|
run-tests: ## Run the test suite runner
|
|
$(PYTHON) run_tests.py
|
|
|
|
demo: ## Run the core functionality demo
|
|
$(PYTHON) core_functionality_demo.py
|
|
|
|
profile: ## Run with profiling
|
|
$(PYTHON) -m cProfile -o profile.stats -m core.main
|
|
|
|
# =============================================================================
|
|
# VERSION MANAGEMENT
|
|
# =============================================================================
|
|
|
|
version: ## Show current version
|
|
$(PYTHON) -c "from core import __version__; print(__version__)"
|
|
|
|
bump-patch: ## Bump patch version
|
|
bump2version patch
|
|
|
|
bump-minor: ## Bump minor version
|
|
bump2version minor
|
|
|
|
bump-major: ## Bump major version
|
|
bump2version major
|