-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (45 loc) · 1.32 KB
/
Makefile
File metadata and controls
52 lines (45 loc) · 1.32 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
# Variables
PYTHON = python3
UV = uv
PYTEST = coverage run -m pytest
TEST_REPORT = coverage report -m
MYPY = mypy
RUFF = ruff
CHECKFILES = pyttings/ tests/
UV_INSTALLED := $(shell command -v $(UV) 2> /dev/null)
# Default target
all: test
# Install uv if not found
install-uv:
ifndef UV_INSTALLED
@echo "uv is not installed. Would you like to install it? (y/n)"
@read -p "Choice: " choice; \
if [ "$$choice" = "y" ]; then \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
echo "uv installed successfully."; \
else \
echo "uv is required. Exiting."; \
exit 1; \
fi
endif
# Set up the environment and install dependencies
setup: install-uv
$(UV) sync --all-extras --dev
# Run tests (pytest and mypy)
test: setup
$(UV) run $(PYTEST) $(CHECKFILES) -s
$(UV) run $(TEST_REPORT)
$(UV) run $(MYPY) $(CHECKFILES)
$(UV) run $(RUFF) format --diff $(CHECKFILES)
$(UV) run $(RUFF) check --select I $(CHECKFILES)
# Format and lint code (ruff)
style: setup
$(UV) run $(RUFF) format $(CHECKFILES)
$(UV) run $(RUFF) check --select I --fix $(CHECKFILES)
# Help message
help:
@echo "Available targets:"
@echo " setup - Set up the environment and install dependencies using uv"
@echo " test - Run tests with pytest and mypy"
@echo " style - Format and lint code with ruff"
@echo " help - Show this help message"