Skip to content

Commit 6794b13

Browse files
authored
Fancy Makefile
1 parent bf337b3 commit 6794b13

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

Makefile

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
1+
# Colors for pretty output
2+
BLUE := \033[36m
3+
BOLD := \033[1m
4+
RESET := \033[0m
5+
16
.DEFAULT_GOAL := help
27

8+
.PHONY: help verify install fmt test marimo clean
9+
10+
##@ Development Setup
11+
312
venv:
13+
@printf "$(BLUE)Creating virtual environment...$(RESET)\n"
414
@curl -LsSf https://astral.sh/uv/install.sh | sh
5-
@uv venv --python='3.12'
15+
@uv venv --python 3.12
616

17+
install: venv ## Install all dependencies using uv
18+
@printf "$(BLUE)Installing dependencies...$(RESET)\n"
19+
@uv sync --dev --frozen
720

8-
.PHONY: install
9-
install: venv ## Install a virtual environment
10-
@uv pip install --upgrade pip
11-
@uv sync --all-extras --dev --frozen
21+
##@ Code Quality
1222

13-
14-
.PHONY: fmt
15-
fmt: venv ## Run autoformatting and linting
23+
fmt: venv ## Run code formatting and linting
24+
@printf "$(BLUE)Running formatters and linters...$(RESET)\n"
1625
@uv pip install pre-commit
1726
@uv run pre-commit install
1827
@uv run pre-commit run --all-files
1928

29+
##@ Testing
2030

21-
.PHONY: clean
22-
clean: ## Clean up caches and build artifacts
23-
@git clean -X -d -f
31+
test: install ## Run all tests
32+
@printf "$(BLUE)Running tests...$(RESET)\n"
33+
@uv pip install pytest
34+
@uv run pytest src/tests
2435

36+
##@ Cleanup
2537

26-
.PHONY: help
27-
help: ## Display this help screen
28-
@echo -e "\033[1mAvailable commands:\033[0m"
29-
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' | sort
38+
clean: ## Clean generated files and directories
39+
@printf "$(BLUE)Cleaning project...$(RESET)\n"
40+
@git clean -d -X -f
3041

42+
##@ Marimo & Jupyter
3143

32-
.PHONY: marimo
33-
marimo: install ## Install Marimo
44+
marimo: install ## Start a Marimo server
45+
@printf "$(BLUE)Start Marimo server...$(RESET)\n"
3446
@uv pip install marimo
3547
@uv run marimo edit book/marimo
3648

49+
##@ Help
50+
51+
help: ## Display this help message
52+
@printf "$(BOLD)Usage:$(RESET)\n"
53+
@printf " make $(BLUE)<target>$(RESET)\n\n"
54+
@printf "$(BOLD)Targets:$(RESET)\n"
55+
@awk 'BEGIN {FS = ":.*##"; printf ""} /^[a-zA-Z_-]+:.*?##/ { printf " $(BLUE)%-15s$(RESET) %s\n", $$1, $$2 } /^##@/ { printf "\n$(BOLD)%s$(RESET)\n", substr($$0, 5) }' $(MAKEFILE_LIST)
3756

38-
.PHONY: test
39-
test: install ## Run pytests
40-
@uv pip install pytest
41-
@uv run pytest src/tests

0 commit comments

Comments
 (0)