-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
75 lines (61 loc) · 1.8 KB
/
Makefile
File metadata and controls
75 lines (61 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Load environment variables from .env file
ifneq (,$(wildcard ./.env))
include .env
export $(shell sed 's/=.*//' .env)
else
$(warning .env file not found. Environment variables not loaded.)
endif
# Variables
PYTHON ?= python3
PIP ?= pip3
DEP_MNGR ?= poetry
DOCS_DIR ?= docs
# Directories and files to clean
CACHE_DIRS = .mypy_cache .pytest_cache .ruff_cache
COVERAGE = .coverage htmlcov coverage.xml
DIST_DIRS = dist junit
TMP_DIRS = site
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show help for all targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Setup & Installation
.PHONY: setup
setup: ## Install system dependencies and dependency manager (e.g., Poetry)
sudo apt-get update
sudo apt-get install -y python3-pip
$(PIP) install --upgrade pip
$(PIP) install $(DEP_MNGR)
.PHONY: install
install: ## Install Python dependencies
$(DEP_MNGR) install --all-extras --no-interaction --no-root
# Quality & Testing
.PHONY: test
test: ## Run tests
$(DEP_MNGR) run pytest
.PHONY: lint
lint: ## Run linter checks
$(DEP_MNGR) run ruff check --fix
.PHONY: format
format: ## Format code
$(DEP_MNGR) run ruff format
.PHONY: typecheck
typecheck: ## Typecheck code
$(DEP_MNGR) run mypy .
.PHONY: precommit
precommit: ## Run pre-commit hooks
$(DEP_MNGR) run pre-commit run --all-files
.PHONY: precommit-install
precommit-install: ## Install pre-commit hooks
$(DEP_MNGR) run pre-commit install
# Documentation
.PHONY: docs
docs: ## Build documentation
$(DEP_MNGR) run mkdocs build
# Maintenance
.PHONY: clean
clean: ## Remove caches and build artifacts
find . -type f -name '*.pyc' -delete
find . -type d -name '__pycache__' -exec rm -rf {} +
rm -rf $(CACHE_DIRS) $(COVERAGE) $(DIST_DIRS) $(TMP_DIRS)