-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
168 lines (142 loc) · 5.78 KB
/
Copy pathMakefile
File metadata and controls
168 lines (142 loc) · 5.78 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
.PHONY: help install dev-install test test-fast test-all lint type-check format format-check docker-up docker-down docker-build run run-local clean build publish publish-test bump-patch bump-minor bump-major start stop
PYTHON := python3
PIP := pip
DOCKER_COMPOSE := docker-compose
help:
@echo "Dostępne komendy:"
@echo " install - Instalacja zależności produkcyjnych"
@echo " dev-install - Instalacja zależności deweloperskich"
@echo " test - Uruchomienie testów pytest (bez slow)"
@echo " test-fast - Szybkie testy (bez slow/integration/e2e)"
@echo " test-all - Wszystkie testy włącznie z slow"
@echo " lint - Sprawdzenie lintingu ruff"
@echo " type-check - Sprawdzenie typów mypy"
@echo " format - Formatowanie kodu ruff"
@echo " format-check - Sprawdzenie formatowania kodu"
@echo " start - Zabija porty i uruchamia usługi Docker"
@echo " stop - Zabija porty i zatrzymuje usługi Docker"
@echo " docker-up - Uruchomienie usług Docker"
@echo " docker-down - Zatrzymanie usług Docker"
@echo " docker-build - Budowanie obrazów Docker"
@echo " run - Uruchomienie aplikacji w Docker"
@echo " run-local - Uruchomienie aplikacji lokalnie"
@echo " clean - Czyszczenie plików tymczasowych"
@echo ""
@echo "📦 Building & Release:"
@echo " build - Build distribution packages"
@echo " publish - Publish to PyPI (requires credentials)"
@echo " publish-test - Publish to TestPyPI"
@echo " bump-patch - Bump patch version"
@echo " bump-minor - Bump minor version"
@echo " bump-major - Bump major version"
install:
$(PIP) install -r requirements.txt
dev-install:
$(PIP) install -r requirements.txt
$(PIP) install -e ".[dev]"
test:
$(PYTHON) -m pytest tests/ -v -m "not slow"
test-fast:
$(PYTHON) -m pytest tests/ -q -m "not slow and not integration and not e2e"
test-all:
$(PYTHON) -m pytest tests/ -v
lint:
$(PYTHON) -m ruff check redsl/ tests/
type-check:
$(PYTHON) -m mypy redsl/
format:
$(PYTHON) -m ruff format redsl/ tests/
$(PYTHON) -m ruff check --fix redsl/ tests/
format-check:
$(PYTHON) -m ruff format --check redsl/ tests/
docker-up:
$(DOCKER_COMPOSE) up -d
docker-down:
$(DOCKER_COMPOSE) down
# Kill processes on specific ports
kill-ports:
@echo "Killing processes on ports 8000, 8001, 9999..."
@for port in 8000 8001 9999; do \
pid=$$(lsof -ti :$$port 2>/dev/null); \
if [ -n "$$pid" ]; then \
echo "Killing process $$pid on port $$port"; \
kill -9 $$pid 2>/dev/null || true; \
fi; \
done
@echo "✓ Ports cleared"
start: kill-ports docker-up
@echo "✓ Services started"
stop: kill-ports docker-down
@echo "✓ Services stopped"
docker-build:
$(DOCKER_COMPOSE) build
run: docker-up
run-local:
$(PYTHON) -m uvicorn redsl.api:app --reload --host 0.0.0.0 --port 8000
clean:
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
rm -rf refactor_output/ build/ dist/ *.egg-info 2>/dev/null || true
build:
rm -rf build/ dist/ *.egg-info
$(PYTHON) -m build
@echo "✓ Build complete - check dist/"
bump-patch:
@current=$$(cat VERSION); \
major=$$(echo $$current | cut -d. -f1); \
minor=$$(echo $$current | cut -d. -f2); \
patch=$$(echo $$current | cut -d. -f3); \
new_patch=$$((patch + 1)); \
new_version="$${major}.$${minor}.$${new_patch}"; \
echo "$$new_version" > VERSION; \
sed -i "s/version = \"$$current\"/version = \"$$new_version\"/" pyproject.toml; \
echo "🔢 Bumped version: $$current → $$new_version"
bump-minor:
@current=$$(cat VERSION); \
major=$$(echo $$current | cut -d. -f1); \
minor=$$(echo $$current | cut -d. -f2); \
new_minor=$$((minor + 1)); \
new_version="$${major}.$${new_minor}.0"; \
echo "$$new_version" > VERSION; \
sed -i "s/version = \"$$current\"/version = \"$$new_version\"/" pyproject.toml; \
echo "🔢 Bumped version: $$current → $$new_version"
bump-major:
@current=$$(cat VERSION); \
major=$$(echo $$current | cut -d. -f1); \
new_major=$$((major + 1)); \
new_version="$${new_major}.0.0"; \
echo "$$new_version" > VERSION; \
sed -i "s/version = \"$$current\"/version = \"$$new_version\"/" pyproject.toml; \
echo "🔢 Bumped version: $$current → $$new_version"
publish-test: build
@echo "🚀 Publishing to TestPyPI..."
@bash -c 'if [ -z "$${TWINE_USERNAME}" ] && [ -z "$${TWINE_PASSWORD}" ] && [ -z "$${PYPI_API_TOKEN}" ] && [ ! -f "$${HOME}/.pypirc" ]; then \
echo "⚠️ No PyPI credentials found. Set TWINE_USERNAME and TWINE_PASSWORD, PYPI_API_TOKEN, or configure ~/.pypirc"; \
echo " Example: TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-xxx make publish-test"; \
echo " Skipping publish-test."; \
exit 0; \
else \
$(PYTHON) -m venv publish-test-env && \
publish-test-env/bin/pip install twine && \
publish-test-env/bin/python -m twine upload --repository testpypi dist/* && \
echo "✓ Published to TestPyPI" || \
echo "✗ Publish failed"; \
rm -rf publish-test-env; \
fi'
publish: build
@echo "🚀 Publishing to PyPI..."
@bash -c 'if [ -z "$${TWINE_USERNAME}" ] && [ -z "$${TWINE_PASSWORD}" ] && [ -z "$${PYPI_API_TOKEN}" ] && [ ! -f "$${HOME}/.pypirc" ]; then \
echo "⚠️ No PyPI credentials found. Set TWINE_USERNAME and TWINE_PASSWORD, PYPI_API_TOKEN, or configure ~/.pypirc"; \
echo " Example: TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-xxx make publish"; \
echo " Skipping publish."; \
exit 0; \
else \
$(PYTHON) -m venv publish-env; \
publish-env/bin/pip install twine; \
publish-env/bin/python -m twine upload dist/* && \
echo "✓ Published to PyPI" || \
echo "✗ Publish failed"; \
rm -rf publish-env; \
fi'