-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (110 loc) · 3.5 KB
/
Makefile
File metadata and controls
123 lines (110 loc) · 3.5 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
.PHONY: test test-only install clean lint format format-check help venv setup check-all
VENV_DIR = venv
PYTHON = $(VENV_DIR)/bin/python
PIP = $(VENV_DIR)/bin/pip
# Default target
help:
@echo "Available targets:"
@echo " setup - Create virtual environment and install dependencies"
@echo " venv - Create virtual environment only"
@echo " install - Install package in development mode (requires venv)"
@echo " test - Format, lint, and run unit tests"
@echo " test-only - Run unit tests only (no formatting/linting)"
@echo " check-all - Run all quality checks (format-check, lint, typecheck, test)"
@echo " clean - Remove build artifacts and virtual environment"
@echo " lint - Run code linting"
@echo " format - Format code with black and isort"
@echo " format-check - Check if code is properly formatted"
@echo " help - Show this help message"
# Create virtual environment
venv:
@if [ ! -d "$(VENV_DIR)" ]; then \
echo "Creating virtual environment..."; \
python3 -m venv $(VENV_DIR); \
echo "Virtual environment created in $(VENV_DIR)/"; \
else \
echo "Virtual environment already exists"; \
fi
# Setup: create venv and install dependencies
setup: venv
@echo "Installing dependencies..."
$(PIP) install --upgrade pip
$(PIP) install -e .
$(PIP) install -r requirements-dev.txt
@echo "Setup complete! Activate with: source $(VENV_DIR)/bin/activate"
# Run tests with formatting and linting
test: setup format lint
@if [ -f "$(PYTHON)" ]; then \
$(PYTHON) -m unittest test_git.py -v; \
else \
echo "Virtual environment not found. Run 'make setup' first."; \
exit 1; \
fi
# Run tests only (no formatting/linting)
test-only:
@if [ -f "$(PYTHON)" ]; then \
$(PYTHON) -m unittest test_git.py -v; \
else \
echo "Virtual environment not found. Run 'make setup' first."; \
exit 1; \
fi
# Run all quality checks
check-all: format-check lint typecheck test-only
@echo "All quality checks passed! ✅"
# Install in development mode
install:
@if [ -f "$(PIP)" ]; then \
$(PIP) install -e .; \
else \
echo "Virtual environment not found. Run 'make setup' first."; \
exit 1; \
fi
# Clean build artifacts and virtual environment
clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf $(VENV_DIR)/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
@echo "Cleaned build artifacts and virtual environment"
# Run linting
lint:
@if [ -f "$(PYTHON)" ]; then \
$(PYTHON) -m flake8 git.py test_git.py --max-line-length=120; \
else \
echo "Virtual environment not found. Run 'make setup' first."; \
exit 1; \
fi
# Format code
format:
@if [ -f "$(PYTHON)" ]; then \
echo "Sorting imports..."; \
$(PYTHON) -m isort git.py test_git.py; \
echo "Formatting code..."; \
$(PYTHON) -m black git.py test_git.py; \
echo "Code formatted successfully!"; \
else \
echo "Virtual environment not found. Run 'make setup' first."; \
exit 1; \
fi
# Check if code is properly formatted
format-check:
@if [ -f "$(PYTHON)" ]; then \
echo "Checking import sorting..."; \
$(PYTHON) -m isort --check-only git.py test_git.py; \
echo "Checking code formatting..."; \
$(PYTHON) -m black --check git.py test_git.py; \
echo "Code formatting is correct!"; \
else \
echo "Virtual environment not found. Run 'make setup' first."; \
exit 1; \
fi
# Type checking
typecheck:
@if [ -f "$(PYTHON)" ]; then \
$(PYTHON) -m mypy git.py --ignore-missing-imports; \
else \
echo "Virtual environment not found. Run 'make setup' first."; \
exit 1; \
fi