-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
202 lines (170 loc) · 6.37 KB
/
Makefile
File metadata and controls
202 lines (170 loc) · 6.37 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Variables
PYTHON := uv run
UV := uv
PRE_COMMIT := uv run pre-commit
PROJECT_NAME := archipy
PYTHON_FILES := $(PROJECT_NAME) features/steps scripts
# Colors for terminal output
BLUE := \033[1;34m
GREEN := \033[1;32m
RED := \033[1;31m
YELLOW := \033[1;33m
NC := \033[0m # No Color
.PHONY: help
help: ## Show this help message
@echo 'Usage:'
@echo "${BLUE}make${NC} ${GREEN}<target>${NC}"
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z\-_0-9]+:.*?## / {printf " ${BLUE}%-20s${NC} %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: setup
setup: ## Setup project pre-requisites
@echo "${BLUE}Setup project pre-requisites...${NC}"
@echo "${GREEN}Installing uv (may need your sudo password)...${NC}"
sudo apt install pipx
pipx install uv
pipx ensurepath
uv generate-shell-completion bash >> ~/.bash_completion
.PHONY: install
install: ## Install project dependencies
@echo "${BLUE}Installing project dependencies...${NC}"
$(UV) sync --all-extras --group dev --upgrade
$(PRE_COMMIT) install
.PHONY: install-dev
install-dev: ## Install project dependencies with dev extras
@echo "${BLUE}Installing project dependencies with dev extras...${NC}"
$(UV) sync --all-extras --all-groups --upgrade
$(PRE_COMMIT) install
.PHONY: update
update: ## Update dependencies to their latest versions
@echo "${BLUE}Updating dependencies...${NC}"
$(UV) lock --upgrade
.PHONY: update-all
update-all: ## Aggressively update all dependencies to latest versions
@echo "${BLUE}Aggressively updating all dependencies...${NC}"
@echo "${YELLOW}Note: This updates uv.lock; to change pyproject.toml constraints, edit manually${NC}"
$(UV) self update
$(UV) python upgrade
$(UV) python update-shell
$(UV) lock --upgrade
$(UV) sync --all-extras --all-groups --upgrade
.PHONY: clean
clean: ## Remove build artifacts and cache directories
@echo "${BLUE}Cleaning project...${NC}"
rm -rf dist/
rm -rf build/
rm -rf .pytest_cache/
rm -rf .coverage
rm -rf htmlcov/
rm -rf .ty_cache/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
.PHONY: format
format: ## Format code using ruff
@echo "${BLUE}Formatting code...${NC}"
$(PYTHON) ruff format --config pyproject.toml $(PYTHON_FILES)
.PHONY: lint
lint: ## Run all linters
@echo "${BLUE}Running linters...${NC}"
$(PYTHON) ruff check --config pyproject.toml $(PYTHON_FILES)
$(PYTHON) ty check $(PYTHON_FILES)
.PHONY: security
security: ## Run security scan with Bandit
@echo "${BLUE}Running security scan...${NC}"
$(PYTHON) bandit -c pyproject.toml -r archipy/ -f json -o bandit-report.json || true
.PHONY: behave
behave: ## Run tests with behave
@echo "${BLUE}Running tests...${NC}"
$(UV) run --extra behave behave
.PHONY: test
test: behave ## Run tests (alias for behave)
.PHONY: build
build: clean ## Build project distribution
@echo "${BLUE}Building project distribution...${NC}"
$(UV) build
.PHONY: version
version: ## Display current version
@echo "${BLUE}Current version:${NC}"
@$(UV) run python -c "import tomllib; print(f\"archipy {tomllib.load(open('pyproject.toml', 'rb'))['project']['version']}\")"
@echo "${YELLOW}Current tag:${NC}"
@git describe --tags --abbrev=0 2>/dev/null || echo "No tags found"
.PHONY: bump-patch
bump-patch: ## Bump patch version
@echo "${BLUE}Bumping patch version...${NC}"
@if [ -n "$(message)" ]; then \
$(UV) run python scripts/bump_version.py patch -m "$(message)"; \
else \
$(UV) run python scripts/bump_version.py patch -m "$$(git log -1 --pretty=%s)"; \
fi
.PHONY: bump-minor
bump-minor: ## Bump minor version
@echo "${BLUE}Bumping minor version...${NC}"
@if [ -n "$(message)" ]; then \
$(UV) run python scripts/bump_version.py minor -m "$(message)"; \
else \
$(UV) run python scripts/bump_version.py minor -m "$$(git log -1 --pretty=%s)"; \
fi
.PHONY: bump-major
bump-major: ## Bump major version
@echo "${BLUE}Bumping major version...${NC}"
@if [ -n "$(message)" ]; then \
$(UV) run python scripts/bump_version.py major -m "$(message)"; \
else \
$(UV) run python scripts/bump_version.py major -m "$$(git log -1 --pretty=%s)"; \
fi
.PHONY: docker-build
docker-build: ## Build Docker image
@echo "${BLUE}Building Docker image...${NC}"
docker build -t $(PROJECT_NAME) .
.PHONY: docker-run
docker-run: ## Run Docker container
@echo "${BLUE}Running Docker container...${NC}"
docker run -it --rm $(PROJECT_NAME)
.PHONY: pre-commit
pre-commit: ## Run pre-commit hooks
@echo "${BLUE}Running pre-commit hooks...${NC}"
$(PRE_COMMIT) run --all-files
.PHONY: check
check: format lint security behave ## Run all checks (format, linting, security, and tests)
.PHONY: ci
ci: ## Run CI pipeline locally
@echo "${BLUE}Running CI pipeline...${NC}"
$(MAKE) clean
$(MAKE) install-dev
$(MAKE) lint
$(MAKE) security
$(MAKE) behave
$(MAKE) build
.PHONY: docs-serve
docs-serve: ## Serve MkDocs documentation locally (balanced mode)
@echo "${BLUE}Serving documentation...${NC}"
$(UV) run --group docs mkdocs serve -f docs/mkdocs.yml
.PHONY: docs-serve-fast
docs-serve-fast: ## Serve MkDocs documentation with fast build (for quick iterations)
@echo "${BLUE}Serving documentation (fast mode)...${NC}"
$(UV) run --group docs mkdocs serve -f docs/mkdocs-fast.yml
.PHONY: docs-serve-no-api
docs-serve-no-api: ## Serve MkDocs documentation without API auto-generation (fastest)
@echo "${BLUE}Serving documentation (no API generation)...${NC}"
ENABLE_MKDOCSTRINGS=false $(UV) run --group docs mkdocs serve -f docs/mkdocs.yml
.PHONY: docs-build
docs-build: ## Build MkDocs documentation (balanced mode)
@echo "${BLUE}Building documentation...${NC}"
$(UV) run --group docs mkdocs build -f docs/mkdocs.yml
.PHONY: docs-build-fast
docs-build-fast: ## Build MkDocs documentation with fast config
@echo "${BLUE}Building documentation (fast mode)...${NC}"
$(UV) run --group docs mkdocs build -f docs/mkdocs-fast.yml
.PHONY: docs-build-full
docs-build-full: ## Build MkDocs documentation with full features (for production)
@echo "${BLUE}Building documentation (full mode)...${NC}"
$(UV) run --group docs mkdocs build -f docs/mkdocs-full.yml --clean
.PHONY: docs-time
docs-time: ## Time the documentation build
@echo "${BLUE}Timing documentation build...${NC}"
time $(UV) run --group docs mkdocs build -f docs/mkdocs.yml
.PHONY: docs-deploy
docs-deploy: ## Deploy MkDocs to GitHub Pages
@echo "${BLUE}Deploying documentation...${NC}"
$(UV) run --group docs mkdocs gh-deploy --force -f docs/mkdocs-full.yml
.DEFAULT_GOAL := help