-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
276 lines (230 loc) · 11 KB
/
Copy pathMakefile
File metadata and controls
276 lines (230 loc) · 11 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
SHELL := /usr/bin/env bash
PYTHON ?= python3
VENV ?= .venv
PY := $(VENV)/bin/python
PIP := $(VENV)/bin/pip
IMGL_ROOT ?= $(HOME)/github/semcod/imgl
IMGL_IMAGE ?= /tmp/koru-imgl-screen.png
IMGL_WINDOW ?= region-bottom
PYTEST_WORKERS ?= auto
PYTEST_DIST ?= loadfile
PYTEST_ARGS ?=
KORU_PYTEST_ENV := KORU_PYTEST_WORKERS="$(PYTEST_WORKERS)" KORU_PYTEST_DIST="$(PYTEST_DIST)"
.PHONY: help test test-fast test-parallel test-parallel-fast test-python-parallel test-api-parallel
.PHONY: install-imgl-bridge test-imgl imgl-capture imgl-capture-interactive imgl-key imgl-type imgl-chat imgl-execute imgl-execute-dry imgl-doctor imgl-shot imgl-serve-rest
help:
@echo "koru — Makefile"
@echo ""
@echo "Testy:"
@echo " make test pełny pytest"
@echo " make test-fast krytyczne / szybkie"
@echo " make test-imgl integracja imgl"
@echo ""
@echo "imgl bridge (vision UI):"
@echo " make install-imgl-bridge koru/.venv + imgl + dsl2coru"
@echo " make imgl-capture zrzut → $(IMGL_IMAGE) (bez dialogu)"
@echo " make imgl-capture-interactive portal GNOME — wybierz obszar"
@echo " make imgl-key UI_KEY ctrl+Return (dry-run)"
@echo " make imgl-type wpisz test w Chat input (dry-run)"
@echo " make imgl-chat TYPE + KEY (dry-run)"
@echo " make imgl-shot PROMPT='wpisz hello' capture-interactive + execute (szybko)"
@echo " make imgl-execute PROMPT='wpisz hello' wpisuje na pulpit (zrzut <60s)"
@echo " make imgl-execute-dry PROMPT='wpisz hello' tylko plan (dry-run)"
@echo " make imgl-doctor autodiagnostyka zrzutu (img2nl)"
@echo " make imgl-serve-rest rest2imgl :8219 (w IMGL_ROOT)"
@echo ""
@echo "Release: make build | publish | packages-build"
test:
$(KORU_PYTEST_ENV) scripts/koru-pytest.sh --verbose $(PYTEST_ARGS)
test-fast:
$(KORU_PYTEST_ENV) scripts/koru-pytest.sh --critical --quick $(PYTEST_ARGS)
test-parallel:
$(KORU_PYTEST_ENV) scripts/koru-pytest.sh --critical --fast --maxfail=1 $(PYTEST_ARGS)
test-parallel-fast:
$(KORU_PYTEST_ENV) scripts/koru-pytest.sh --changed --critical --quick $(PYTEST_ARGS)
test-python-parallel: test-parallel
test-api-parallel:
$(KORU_PYTEST_ENV) scripts/koru-pytest.sh --fast --maxfail=1 \
tests/test_koruapi.py \
tests/test_koruapi_transports.py \
tests/test_dashboard_projects_by_ide.py \
tests/test_dashboard_topology_post.py \
tests/test_mcp_server.py \
$(PYTEST_ARGS)
install-imgl-bridge: $(VENV)/.imgl-bridge-installed
$(VENV)/.imgl-bridge-installed:
@test -x "$(VENV)/bin/python" || (echo "Brak $(VENV) — uruchom make install-dev lub python -m venv .venv" && exit 1)
IMGL_ROOT="$(IMGL_ROOT)" bash scripts/install-imgl-bridge.sh
@touch "$(VENV)/.imgl-bridge-installed"
test-imgl:
$(PY) -m pytest tests/test_imgl_integration.py packages/dsl2coru/tests/test_dsl2coru_ui.py -q
imgl-capture:
@test -x "$(IMGL_ROOT)/.venv/bin/imgl" || (echo "Brak $(IMGL_ROOT)/.venv — cd $(IMGL_ROOT) && make install-dev" && exit 1)
@$(IMGL_ROOT)/.venv/bin/imgl capture --smart -o "$(IMGL_IMAGE)"
@echo "export KORU_IMGL_IMAGE=$(IMGL_IMAGE)"
imgl-capture-interactive:
@test -x "$(IMGL_ROOT)/.venv/bin/imgl" || (echo "Brak $(IMGL_ROOT)/.venv — cd $(IMGL_ROOT) && make install-dev" && exit 1)
@rm -f "$(IMGL_IMAGE:.png=.vql.imgl.json)" "$(IMGL_IMAGE:.png=.vql.json)" "$(IMGL_IMAGE:.png=.captured_at)" "$(IMGL_IMAGE)"
@$(IMGL_ROOT)/.venv/bin/imgl capture -o "$(IMGL_IMAGE)" --verify
@rm -f "$(IMGL_IMAGE:.png=.vql.imgl.json)" "$(IMGL_IMAGE:.png=.vql.json)"
@echo "export KORU_IMGL_IMAGE=$(IMGL_IMAGE)"
imgl-key: install-imgl-bridge
IMGL_ROOT="$(IMGL_ROOT)" KORU_IMGL_IMAGE=$(IMGL_IMAGE) $(VENV)/bin/dsl2coru exec 'UI_KEY ctrl+Return'
imgl-type: install-imgl-bridge imgl-capture
IMGL_ROOT="$(IMGL_ROOT)" KORU_IMGL_IMAGE=$(IMGL_IMAGE) $(VENV)/bin/dsl2coru exec 'UI_TYPE "test" IN "Chat input" WINDOW $(IMGL_WINDOW)'
imgl-chat: install-imgl-bridge imgl-capture
IMGL_ROOT="$(IMGL_ROOT)" KORU_IMGL_IMAGE=$(IMGL_IMAGE) $(VENV)/bin/dsl2coru exec 'UI_TYPE "demo" IN "Chat input" WINDOW $(IMGL_WINDOW)'
IMGL_ROOT="$(IMGL_ROOT)" KORU_IMGL_IMAGE=$(IMGL_IMAGE) $(VENV)/bin/dsl2coru exec 'UI_KEY ctrl+Return'
imgl-execute: $(VENV)/.imgl-bridge-installed
@test -f "$(IMGL_IMAGE)" || (echo "Brak zrzutu — najpierw: make imgl-capture-interactive" && exit 1)
@test -n "$(PROMPT)" || (echo "Użycie: make imgl-execute PROMPT='wpisz test w Chat input'" && exit 1)
IMGL_ROOT="$(IMGL_ROOT)" KORU_IMGL_IMAGE=$(IMGL_IMAGE) $(VENV)/bin/koru imgl execute "$(PROMPT)" --image $(IMGL_IMAGE) --window $(IMGL_WINDOW) --execute --format $(or $(FORMAT),markdown)
imgl-execute-dry: $(VENV)/.imgl-bridge-installed
@test -f "$(IMGL_IMAGE)" || (echo "Brak zrzutu — najpierw: make imgl-capture-interactive" && exit 1)
@test -n "$(PROMPT)" || (echo "Użycie: make imgl-execute-dry PROMPT='wpisz test w Chat input'" && exit 1)
IMGL_ROOT="$(IMGL_ROOT)" KORU_IMGL_IMAGE=$(IMGL_IMAGE) $(VENV)/bin/koru imgl execute "$(PROMPT)" --image $(IMGL_IMAGE) --window $(IMGL_WINDOW) --dry-run --format $(or $(FORMAT),markdown)
imgl-shot: imgl-capture-interactive imgl-execute
imgl-doctor: $(VENV)/.imgl-bridge-installed
IMGL_ROOT="$(IMGL_ROOT)" KORU_IMGL_IMAGE=$(IMGL_IMAGE) $(VENV)/bin/koru imgl doctor --image $(IMGL_IMAGE) --format $(or $(FORMAT),auto)
imgl-serve-rest:
@test -x "$(IMGL_ROOT)/.venv/bin/rest2imgl" || (cd "$(IMGL_ROOT)" && make install-control)
$(IMGL_ROOT)/.venv/bin/rest2imgl serve --port 8219
sync-plugin-version:
python3 scripts/sync-plugin-version.py --ide vscode
python3 scripts/sync-plugin-version.py --ide cursor
sync-plugin-shared:
python3 scripts/sync-plugin-shared.py
# =============================================================================
# Release
# =============================================================================
VERSION = $(shell $(PYTHON) scripts/bump_version.py --show)
.PHONY: build clean-dist bump-patch bump-minor bump-major publish publish-test check-dist
.PHONY: packages-build packages-check packages-publish-test packages-publish
PACKAGE_DIRS := $(shell find packages -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sort)
clean-dist:
rm -f dist/koru-*
build: clean-dist
rm -rf build/ *.egg-info src/*.egg-info
$(PYTHON) -m pip install -q build
$(PYTHON) -m build
@echo "✓ Built dist/koru-$(VERSION)*"
check-dist:
@test -n "$(VERSION)" || (echo "Could not read version from pyproject.toml" && exit 1)
@test -n "$$(ls dist/koru-$(VERSION)* 2>/dev/null)" || (echo "No artifacts for $(VERSION) in dist/ — run make build" && exit 1)
@$(PYTHON) -m pip install -q twine
@$(PYTHON) -m twine check dist/koru-$(VERSION)*
bump-patch:
@echo "🔢 Bumping patch version..."
$(PYTHON) scripts/bump_version.py patch
bump-minor:
@echo "🔢 Bumping minor version..."
$(PYTHON) scripts/bump_version.py minor
bump-major:
@echo "🔢 Bumping major version..."
$(PYTHON) scripts/bump_version.py major
publish-test: build check-dist
@echo "🚀 Publishing to TestPyPI..."
@bash -c '\
if [ -n "$${PYPI_API_TOKEN}" ] && [ -z "$${TWINE_PASSWORD}" ]; then \
export TWINE_USERNAME=__token__ TWINE_PASSWORD="$${PYPI_API_TOKEN}"; \
fi; \
if [ -z "$${TWINE_USERNAME}" ] && [ -z "$${TWINE_PASSWORD}" ]; then \
echo "⚠️ No PyPI credentials. Set TWINE_USERNAME/TWINE_PASSWORD or PYPI_API_TOKEN"; \
echo " Skipping upload (dist/koru-$(VERSION)* built and twine-checked)."; \
else \
$(PYTHON) -m pip install -q twine && \
$(PYTHON) -m twine upload --repository testpypi dist/koru-$(VERSION)* && \
echo "✓ Published koru $(VERSION) to TestPyPI"; \
fi'
publish:
@echo "🚀 Publishing to PyPI..."
@bash -c '\
if [ -z "$${PYPI_API_TOKEN}" ] && [ -z "$${TWINE_USERNAME}" ] && [ -z "$${TWINE_PASSWORD}" ] && [ ! -f "$${HOME}/.pypirc" ]; then \
echo "⚠️ No PyPI credentials. Set PYPI_API_TOKEN or TWINE_USERNAME/TWINE_PASSWORD (no version bump performed)."; \
echo " Example: PYPI_API_TOKEN=pypi-xxx make publish"; \
exit 1; \
fi'
@$(MAKE) bump-patch
@$(MAKE) build
@$(MAKE) check-dist
@bash -c 'set -euo pipefail; \
if [ -n "$${PYPI_API_TOKEN:-}" ] && [ -z "$${TWINE_PASSWORD:-}" ]; then \
export TWINE_USERNAME=__token__ TWINE_PASSWORD="$${PYPI_API_TOKEN}"; \
fi; \
FILES="$$(ls dist/koru-*.whl dist/koru-*.tar.gz 2>/dev/null)"; \
test -n "$${FILES}" || { echo "No built artifacts in dist/ — run make build"; exit 1; }; \
echo "📦 Uploading to PyPI:"; echo "$${FILES}" | sed "s/^/ /"; \
$(PYTHON) -m pip install -q twine; \
$(PYTHON) -m twine upload $${FILES}; \
echo "✓ Published koru to PyPI"'
# =============================================================================
# Packages/* release helpers (coru, koruenv, ...)
# =============================================================================
packages-build:
@set -euo pipefail; \
if [ -z "$(PACKAGE_DIRS)" ]; then \
echo "No package directories found under packages/"; \
exit 1; \
fi; \
$(PYTHON) -m pip install -q build; \
for pkg in $(PACKAGE_DIRS); do \
if [ ! -f "$$pkg/pyproject.toml" ]; then \
echo "- skipping $$pkg (no pyproject.toml)"; \
continue; \
fi; \
echo "📦 building $$pkg"; \
rm -rf "$$pkg/dist" "$$pkg/build" "$$pkg"/*.egg-info "$$pkg/src"/*.egg-info; \
$(PYTHON) -m build "$$pkg"; \
done
packages-check:
@set -euo pipefail; \
$(PYTHON) -m pip install -q twine; \
for pkg in $(PACKAGE_DIRS); do \
if [ ! -f "$$pkg/pyproject.toml" ]; then \
continue; \
fi; \
if ls "$$pkg"/dist/* >/dev/null 2>&1; then \
echo "🔎 twine check $$pkg/dist/*"; \
$(PYTHON) -m twine check "$$pkg"/dist/*; \
else \
echo "No artifacts in $$pkg/dist (run: make packages-build)"; \
exit 1; \
fi; \
done
packages-publish-test: packages-build packages-check
@echo "🚀 Publishing packages/* to TestPyPI..."
@bash -c '\
if [ -n "$${PYPI_API_TOKEN}" ] && [ -z "$${TWINE_PASSWORD}" ]; then \
export TWINE_USERNAME=__token__ TWINE_PASSWORD="$${PYPI_API_TOKEN}"; \
fi; \
if [ -z "$${TWINE_USERNAME}" ] && [ -z "$${TWINE_PASSWORD}" ]; then \
echo "⚠️ No PyPI credentials. Set TWINE_USERNAME/TWINE_PASSWORD or PYPI_API_TOKEN"; \
echo " Skipping upload (artifacts are built and twine-checked)."; \
exit 0; \
fi; \
for pkg in $(PACKAGE_DIRS); do \
if [ ! -f "$$pkg/pyproject.toml" ]; then \
continue; \
fi; \
echo "⬆️ testpypi upload $$pkg/dist/*"; \
$(PYTHON) -m twine upload --repository testpypi "$$pkg"/dist/*; \
done; \
echo "✓ Published all packages/* to TestPyPI"'
packages-publish: packages-build packages-check
@echo "🚀 Publishing packages/* to PyPI..."
@bash -c '\
if [ -n "$${PYPI_API_TOKEN}" ] && [ -z "$${TWINE_PASSWORD}" ]; then \
export TWINE_USERNAME=__token__ TWINE_PASSWORD="$${PYPI_API_TOKEN}"; \
fi; \
if [ -z "$${TWINE_USERNAME}" ] && [ -z "$${TWINE_PASSWORD}" ]; then \
echo "⚠️ No PyPI credentials. Set TWINE_USERNAME/TWINE_PASSWORD or PYPI_API_TOKEN"; \
exit 1; \
fi; \
for pkg in $(PACKAGE_DIRS); do \
if [ ! -f "$$pkg/pyproject.toml" ]; then \
continue; \
fi; \
echo "⬆️ pypi upload $$pkg/dist/*"; \
$(PYTHON) -m twine upload "$$pkg"/dist/*; \
done; \
echo "✓ Published all packages/* to PyPI"'