-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
222 lines (200 loc) · 7.91 KB
/
Copy pathMakefile
File metadata and controls
222 lines (200 loc) · 7.91 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# ScriptMate Makefile
.PHONY: help install dev test test-cov lint format build clean publish publish-test \
version-patch version-minor version-major check-version status setup-dev \
check-deps security-check docs serve-docs
# Default target
help:
@echo "🚀 ScriptMate Development Tools"
@echo ""
@echo "📦 Project Management:"
@echo " install Install project dependencies"
@echo " dev Install development dependencies"
@echo " setup-dev Complete development environment setup"
@echo " status Show project status"
@echo ""
@echo "🧪 Testing and Quality:"
@echo " test Run tests"
@echo " test-cov Run tests with coverage report"
@echo " lint Code linting"
@echo " format Code formatting"
@echo " security-check Security check"
@echo ""
@echo "🔧 Build and Publish:"
@echo " build Build package"
@echo " clean Clean build files"
@echo " publish Publish to PyPI"
@echo " publish-test Publish to test PyPI"
@echo ""
@echo "📝 Version Management:"
@echo " check-version Check current version"
@echo " version-patch Bump patch version and publish"
@echo " version-minor Bump minor version and publish"
@echo " version-major Bump major version and publish"
@echo ""
@echo "📚 Documentation:"
@echo " docs Generate documentation"
@echo " serve-docs Start documentation server"
# Project Management
install:
@echo "📦 Installing project dependencies..."
uv sync
dev:
@echo "🔧 Installing development dependencies..."
uv sync --dev
@if command -v pre-commit >/dev/null 2>&1 || uv run pre-commit --version >/dev/null 2>&1; then \
uv run pre-commit install; \
echo "✅ pre-commit hooks installed"; \
else \
echo "⚠️ pre-commit not found, skipping hooks installation"; \
fi
setup-dev: dev
@echo "🚀 Setting up complete development environment..."
@echo "✅ Development environment setup complete"
status:
@echo "📊 Project Status:"
@echo "Current version: $$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')"
@echo "Python version: $$(uv run python --version)"
@echo "UV version: $$(uv --version)"
@if [ -d ".git" ]; then \
echo "Git branch: $$(git branch --show-current 2>/dev/null || echo 'unknown')"; \
echo "Git status: $$(git status --porcelain | wc -l | tr -d ' ') uncommitted changes"; \
fi
check-deps:
@echo "🔍 Checking dependencies..."
uv tree
# Testing and Quality
test:
@echo "🧪 Running tests..."
uv run pytest -v
test-cov:
@echo "🧪 Running tests with coverage report..."
uv run pytest --cov=src --cov-report=html --cov-report=term-missing
lint:
@echo "🔍 Code linting..."
@echo "Checking code format..."
uv run black --check src/ tests/ || (echo "❌ Black format check failed" && exit 1)
@echo "Checking import sorting..."
uv run isort --check-only src/ tests/ || (echo "❌ isort check failed" && exit 1)
@if command -v flake8 >/dev/null 2>&1 || uv run flake8 --version >/dev/null 2>&1; then \
echo "Checking code style..."; \
uv run flake8 src/ tests/ || (echo "❌ flake8 check failed" && exit 1); \
fi
@if command -v mypy >/dev/null 2>&1 || uv run mypy --version >/dev/null 2>&1; then \
echo "Type checking..."; \
uv run mypy src/ || (echo "❌ mypy check failed" && exit 1); \
fi
@echo "✅ All checks passed"
format:
@echo "🎨 Code formatting..."
uv run black src/ tests/
uv run isort src/ tests/
@echo "✅ Code formatting complete"
security-check:
@echo "🔒 Security check..."
@if command -v bandit >/dev/null 2>&1 || uv run bandit --version >/dev/null 2>&1; then \
uv run bandit -r src/; \
else \
echo "⚠️ bandit not installed, skipping security check"; \
fi
# Build and Clean
build: clean
@echo "🔨 Building package..."
uv build
@echo "✅ Build complete"
clean:
@echo "🧹 Cleaning build files..."
rm -rf build/ dist/ src/*.egg-info/ .pytest_cache/ htmlcov/ .coverage
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
find . -type f -name "*.pyo" -delete 2>/dev/null || true
@echo "✅ Clean complete"
# Publishing
publish: lint test build
@echo "🚀 Publishing to PyPI..."
@if [ ! -f ~/.pypirc ] && [ -z "$$TWINE_PASSWORD" ]; then \
echo "❌ Error: PyPI authentication required"; \
echo "Please set environment variables:"; \
echo " export TWINE_USERNAME=__token__"; \
echo " export TWINE_PASSWORD=your-api-token"; \
echo "or create ~/.pypirc configuration file"; \
exit 1; \
fi
@echo "📦 Uploading package to PyPI..."
uv run twine upload dist/*
@echo "✅ Published successfully!"
publish-test: lint test build
@echo "🧪 Publishing to test PyPI..."
@if [ ! -f ~/.pypirc ] && [ -z "$$TWINE_PASSWORD" ]; then \
echo "❌ Error: PyPI authentication required"; \
echo "Please set environment variables:"; \
echo " export TWINE_USERNAME=__token__"; \
echo " export TWINE_PASSWORD=your-test-api-token"; \
echo "or create ~/.pypirc configuration file"; \
exit 1; \
fi
@echo "📦 Uploading package to test PyPI..."
uv run twine upload --repository testpypi dist/*
@echo "✅ Test publish successful!"
# Version Management
check-version:
@echo "📋 Current version information:"
@current_version=$$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
echo "Current version: $$current_version"
version-patch:
@echo "🔖 Bumping patch version..."
@current_version=$$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
new_version=$$(uv run python -c "import sys; v=sys.argv[1].split('.'); v[2]=str(int(v[2])+1); print('.'.join(v))" $$current_version); \
if [ "$$(uname)" = "Darwin" ]; then \
sed -i '' "s/^version = .*/version = \"$$new_version\"/" pyproject.toml; \
else \
sed -i "s/^version = .*/version = \"$$new_version\"/" pyproject.toml; \
fi; \
echo "✅ Version updated to: $$new_version"; \
git add pyproject.toml && git commit -m "bump version to $$new_version" || true; \
$(MAKE) publish
version-minor:
@echo "🔖 Bumping minor version..."
@current_version=$$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
new_version=$$(uv run python -c "import sys; v=sys.argv[1].split('.'); v[1]=str(int(v[1])+1); v[2]='0'; print('.'.join(v))" $$current_version); \
if [ "$$(uname)" = "Darwin" ]; then \
sed -i '' "s/^version = .*/version = \"$$new_version\"/" pyproject.toml; \
else \
sed -i "s/^version = .*/version = \"$$new_version\"/" pyproject.toml; \
fi; \
echo "✅ Version updated to: $$new_version"; \
git add pyproject.toml && git commit -m "bump version to $$new_version" || true; \
$(MAKE) publish
version-major:
@echo "🔖 Bumping major version..."
@current_version=$$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
new_version=$$(uv run python -c "import sys; v=sys.argv[1].split('.'); v[0]=str(int(v[0])+1); v[1]='0'; v[2]='0'; print('.'.join(v))" $$current_version); \
if [ "$$(uname)" = "Darwin" ]; then \
sed -i '' "s/^version = .*/version = \"$$new_version\"/" pyproject.toml; \
else \
sed -i "s/^version = .*/version = \"$$new_version\"/" pyproject.toml; \
fi; \
echo "✅ Version updated to: $$new_version"; \
git add pyproject.toml && git commit -m "bump version to $$new_version" || true; \
$(MAKE) publish
# Documentation
docs:
@echo "📚 Generating documentation..."
@if [ -f "docs/conf.py" ] || [ -f "mkdocs.yml" ]; then \
if [ -f "mkdocs.yml" ]; then \
uv run mkdocs build; \
elif [ -f "docs/conf.py" ]; then \
cd docs && uv run sphinx-build -b html . _build/html; \
fi; \
echo "✅ Documentation generation complete"; \
else \
echo "⚠️ Documentation configuration file not found"; \
fi
serve-docs:
@echo "🌐 Starting documentation server..."
@if [ -f "mkdocs.yml" ]; then \
uv run mkdocs serve; \
elif [ -f "docs/conf.py" ]; then \
cd docs && uv run sphinx-autobuild . _build/html; \
else \
echo "⚠️ Documentation configuration file not found"; \
fi