Skip to main content
Glama
quality.mkโ€ข9.47 kB
# ============================================================================ # quality.mk - Code Quality Targets # ============================================================================ # Provides: linting, formatting, type-checking, pre-publish gates # Include in main Makefile with: -include .makefiles/quality.mk # # Extracted from: claude-mpm production Makefile (97 targets) # Dependencies: common.mk (for colors, ENV system) # Last updated: 2025-11-21 # ============================================================================ # ============================================================================ # Quality Target Declarations # ============================================================================ .PHONY: lint-ruff lint-fix lint-mypy quality quality-ci pre-publish .PHONY: clean-system-files clean-test-artifacts clean-deprecated clean-pre-publish # ============================================================================ # Individual Linting Targets # ============================================================================ lint-ruff: ## Run Ruff linter and formatter check @echo "$(YELLOW)๐Ÿ” Running Ruff linter...$(NC)" @if command -v ruff &> /dev/null; then \ ruff check $(SRC_DIR)/ $(TESTS_DIR)/ $(RUFF_ARGS) || exit 1; \ echo "$(GREEN)โœ“ Ruff linting passed$(NC)"; \ echo "$(YELLOW)๐Ÿ” Checking code formatting...$(NC)"; \ ruff format --check $(SRC_DIR)/ $(TESTS_DIR)/ || exit 1; \ echo "$(GREEN)โœ“ Ruff format check passed$(NC)"; \ else \ echo "$(RED)โœ— ruff not found. Install with: pip install ruff$(NC)"; \ exit 1; \ fi lint-mypy: ## Run mypy type checker @echo "$(YELLOW)๐Ÿ” Running mypy type checker...$(NC)" @if command -v mypy &> /dev/null; then \ mypy $(SRC_DIR)/ --ignore-missing-imports --no-error-summary || true; \ echo "$(YELLOW)โ„น MyPy check complete (informational)$(NC)"; \ else \ echo "$(YELLOW)โš  mypy not found. Install with: pip install mypy$(NC)"; \ fi # ============================================================================ # Auto-Fix Target # ============================================================================ lint-fix: ## Auto-fix linting issues (ruff format + ruff check --fix) @echo "$(YELLOW)๐Ÿ”ง Auto-fixing code issues with Ruff...$(NC)" @if command -v ruff &> /dev/null; then \ echo "$(YELLOW)Fixing linting issues...$(NC)"; \ ruff check $(SRC_DIR)/ $(TESTS_DIR)/ --fix || true; \ echo "$(GREEN)โœ“ Ruff linting fixes applied$(NC)"; \ echo "$(YELLOW)Formatting code...$(NC)"; \ ruff format $(SRC_DIR)/ $(TESTS_DIR)/ || true; \ echo "$(GREEN)โœ“ Code formatted$(NC)"; \ else \ echo "$(RED)โœ— ruff not found. Install with: pip install ruff$(NC)"; \ exit 1; \ fi @echo "" @echo "$(GREEN)โœ… Auto-fix complete. Run 'make quality' to verify.$(NC)" # ============================================================================ # Combined Quality Checks # ============================================================================ quality: ## Run all quality checks (ruff + mypy) @echo "$(BLUE)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @echo "$(BLUE)Running all quality checks...$(NC)" @echo "$(BLUE)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @$(MAKE) lint-ruff @$(MAKE) lint-mypy @echo "" @echo "$(GREEN)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @echo "$(GREEN)โœ… All quality checks passed!$(NC)" @echo "$(GREEN)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" quality-ci: ## Quality checks for CI/CD (strict, fail fast) @echo "$(BLUE)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @echo "$(BLUE)Running CI quality checks (strict mode)...$(NC)" @echo "$(BLUE)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @set -e; \ echo "$(YELLOW)๐Ÿ” Ruff check (no fixes)...$(NC)"; \ ruff check $(SRC_DIR)/ $(TESTS_DIR)/ --no-fix; \ echo "$(YELLOW)๐Ÿ” Type checking...$(NC)"; \ mypy $(SRC_DIR)/ --ignore-missing-imports; \ echo "$(YELLOW)๐Ÿงช Running tests (parallel)...$(NC)"; \ $(PYTHON) -m pytest $(TESTS_DIR)/ $(PYTEST_ARGS) --tb=short @echo "" @echo "$(GREEN)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @echo "$(GREEN)โœ… CI quality checks passed!$(NC)" @echo "$(GREEN)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" # ============================================================================ # Pre-Publish Cleanup Targets # ============================================================================ clean-system-files: ## Remove system files (.DS_Store, __pycache__, *.pyc) @echo "$(YELLOW)๐Ÿงน Cleaning system files...$(NC)" @find . -name ".DS_Store" -not -path "*/venv/*" -not -path "*/.venv/*" -delete 2>/dev/null || true @find . -type d -name "__pycache__" -not -path "*/venv/*" -not -path "*/.venv/*" -exec rm -rf {} + 2>/dev/null || true @find . -type f \( -name "*.pyc" -o -name "*.pyo" \) -not -path "*/venv/*" -not -path "*/.venv/*" -delete 2>/dev/null || true @echo "$(GREEN)โœ“ System files cleaned$(NC)" clean-test-artifacts: ## Remove test artifacts (HTML, JSON reports in root) @echo "$(YELLOW)๐Ÿงน Cleaning test artifacts from root...$(NC)" @rm -f dashboard_test.html report_qa_test.html coverage.json 2>/dev/null || true @rm -rf htmlcov/ .coverage .pytest_cache/ 2>/dev/null || true @echo "$(GREEN)โœ“ Test artifacts cleaned$(NC)" clean-deprecated: ## Remove explicitly deprecated files @echo "$(YELLOW)๐Ÿงน Removing deprecated files...$(NC)" @# Add project-specific deprecated file patterns here @echo "$(GREEN)โœ“ Deprecated files removed$(NC)" clean-pre-publish: clean-system-files clean-test-artifacts clean-deprecated ## Complete pre-publish cleanup @echo "" @echo "$(GREEN)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @echo "$(GREEN)โœ… Pre-publish cleanup complete!$(NC)" @echo "$(GREEN)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" # ============================================================================ # Pre-Publish Quality Gate # ============================================================================ pre-publish: clean-pre-publish ## Comprehensive pre-release quality gate @echo "$(BLUE)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @echo "$(BLUE)๐Ÿš€ Pre-Publish Quality Gate$(NC)" @echo "$(BLUE)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @echo "" @echo "$(YELLOW)Step 1/4: Checking working directory...$(NC)" @if [ -n "$$(git status --porcelain)" ]; then \ echo "$(RED)โœ— Working directory is not clean$(NC)"; \ echo "$(YELLOW)Please commit or stash your changes first$(NC)"; \ git status --short; \ exit 1; \ fi @echo "$(GREEN)โœ“ Working directory is clean$(NC)" @echo "" @echo "$(YELLOW)Step 2/4: Running all linters...$(NC)" @$(MAKE) quality @echo "" @echo "$(YELLOW)Step 3/4: Running tests...$(NC)" @if command -v pytest >/dev/null 2>&1; then \ $(PYTHON) -m pytest $(TESTS_DIR)/ $(PYTEST_ARGS) || exit 1; \ else \ echo "$(YELLOW)โš  pytest not found, skipping tests$(NC)"; \ fi @echo "$(GREEN)โœ“ Tests passed$(NC)" @echo "" @echo "$(YELLOW)Step 4/4: Checking for common issues...$(NC)" @echo "Checking for debug prints..." @! grep -r "print(" $(SRC_DIR)/ --include="*.py" | grep -v "#" | grep -v "logger" || \ echo "$(YELLOW)โš  Found print statements (non-blocking for CLI tools)$(NC)" @echo "Checking for TODO/FIXME..." @! grep -r "TODO\|FIXME" $(SRC_DIR)/ --include="*.py" | head -5 || \ echo "$(YELLOW)โš  Found TODO/FIXME comments (non-blocking)$(NC)" @echo "$(GREEN)โœ“ Common issues check complete$(NC)" @echo "" @echo "$(GREEN)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" @echo "$(GREEN)โœ… Pre-publish checks PASSED!$(NC)" @echo "$(GREEN)Ready for release.$(NC)" @echo "$(GREEN)โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•$(NC)" # ============================================================================ # Usage Examples # ============================================================================ # Quick development workflow: # make lint-fix # Auto-fix all issues # make quality # Verify all checks pass # # Before committing: # make quality # Run all quality checks # # Before releasing: # make pre-publish # Comprehensive quality gate # # CI/CD integration: # make quality-ci # Strict, fail-fast checks # # Cleanup: # make clean-pre-publish # Remove artifacts and temp files # ============================================================================

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bobmatnyc/mcp-skills'

If you have feedback or need assistance with the MCP directory API, please join our Discord server