Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (120 loc) · 6.61 KB
/
Copy pathMakefile
File metadata and controls
141 lines (120 loc) · 6.61 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
.PHONY: help install desktop-install desktop-sync-version bump-version test desktop-test desktop-build coverage lint format translate run dev web pipeline clean publish
.DEFAULT_GOAL := help
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
install: ## Install dependencies and pre-commit hooks
uv sync --all-extras
git config --local --unset-all core.hooksPath 2>/dev/null || true
git config --global --unset-all core.hooksPath 2>/dev/null || true
uv run pre-commit install
desktop-install: ## Install Desktop build dependencies
uv sync --all-extras --group desktop
cd desktop && npm ci
desktop-sync-version: ## Synchronize Desktop package versions from the Python package
uv run python desktop/scripts/sync_version.py
bump-version: ## Bump the product version (usage: make bump-version VERSION=x.y.z)
@if [ "$(origin VERSION)" != "command line" ]; then \
echo "Usage: make bump-version VERSION=<new-version> (e.g. VERSION=0.12.2)"; \
exit 1; \
fi
@echo "$(VERSION)" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.+-]+)?$$' || { \
echo "Invalid SemVer: $(VERSION)"; \
exit 1; \
}
@if grep -q '^__version__ = "$(VERSION)"$$' src/iac_code/__init__.py; then \
echo "Version is already $(VERSION), nothing to bump"; \
exit 1; \
fi
@perl -i -pe 's/^__version__ = ".*"/__version__ = "$(VERSION)"/' src/iac_code/__init__.py
@for lang in $(LOCALES); do \
perl -i -pe 's/^"Project-Id-Version: .*/"Project-Id-Version: iac-code $(VERSION)\\n"/' src/iac_code/i18n/locales/$$lang/LC_MESSAGES/messages.po; \
done
@uv run python desktop/scripts/sync_version.py
@echo "Bumped version to $(VERSION); review changes with: git diff"
desktop-test: ## Run Desktop Python and Rust checks
uv run python desktop/scripts/sync_version.py --check
uv run ruff check src/iac_code/desktop tests/desktop desktop/scripts
uv run pytest tests/desktop tests/web/test_frontend_static.py -q
cd desktop/src-tauri && cargo fmt --check
cd desktop/src-tauri && cargo clippy --all-targets --features updater -- -D warnings
cd desktop/src-tauri && cargo clippy --all-targets --no-default-features -- -D warnings
cd desktop/src-tauri && cargo test --features updater
cd desktop/src-tauri && cargo test --no-default-features
cd desktop/helpers && cargo fmt --check
cd desktop/helpers && cargo clippy --all-targets -- -D warnings
cd desktop/helpers && cargo test
desktop-build: ## Build the native Desktop bundle for this platform
uv run --python 3.12 --group desktop python desktop/scripts/build_desktop.py
PYTHON_VERSIONS := 3.10 3.11 3.12 3.13 3.14
test: ## Run tests (PY=all for all versions, PY=3.x for specific version)
ifeq ($(PY),all)
@for ver in $(PYTHON_VERSIONS); do \
echo "=== Python $$ver ==="; \
uv run --python $$ver --all-extras pytest tests/ -v -n auto || exit 1; \
done
else ifdef PY
uv run --python $(PY) --all-extras pytest tests/ -v -n auto
else
uv run --all-extras pytest tests/ -v -n auto
endif
coverage: ## Run tests with coverage (PY=all for all versions, PY=3.x for specific version)
ifeq ($(PY),all)
@for ver in $(PYTHON_VERSIONS); do \
echo "=== Python $$ver ==="; \
uv run --python $$ver --all-extras pytest tests/ -n auto --cov --cov-report=term-missing --cov-report=html || exit 1; \
done
else ifdef PY
uv run --python $(PY) --all-extras pytest tests/ -n auto --cov --cov-report=term-missing --cov-report=html
else
uv run --all-extras pytest tests/ -n auto --cov --cov-report=term-missing --cov-report=html
endif
@echo "HTML report: htmlcov/index.html"
lint: ## Run linters
uv run ruff check src/ tests/
uv run ty check src/
format: ## Format code
uv run ruff format src/ tests/
LOCALES := zh es fr de ja pt
VERSION := $(shell sed -n 's/^__version__ = "\(.*\)"/\1/p' src/iac_code/__init__.py)
translate: desktop-sync-version ## Extract, update and compile translations
@uv run pybabel extract -F babel.cfg --add-location=file --project=iac-code --version=$(VERSION) -o src/iac_code/i18n/messages.pot . > /dev/null 2>&1 && echo "Extract: OK" || (echo "Extract: FAILED"; exit 1)
@for lang in $(LOCALES); do \
uv run pybabel update --ignore-pot-creation-date -i src/iac_code/i18n/messages.pot -d src/iac_code/i18n/locales -l $$lang > /dev/null 2>&1 && echo "Update $$lang: OK" || (echo "Update $$lang: FAILED"; exit 1); \
done
@for lang in $(LOCALES); do \
perl -i -pe 's/^"Project-Id-Version: .*/"Project-Id-Version: iac-code $(VERSION)\\n"/' src/iac_code/i18n/locales/$$lang/LC_MESSAGES/messages.po; \
done
@for lang in $(LOCALES); do \
uv run pybabel compile -d src/iac_code/i18n/locales -l $$lang > /dev/null 2>&1 && echo "Compile $$lang: OK" || (echo "Compile $$lang: FAILED"; exit 1); \
done
@uv run pybabel extract -F babel_webui.cfg --ignore-dirs='vendor' --add-location=file --project=iac-code --version=$(VERSION) -o src/iac_code/i18n/webui.pot . > /dev/null 2>&1 && echo "Extract webui: OK" || (echo "Extract webui: FAILED"; exit 1)
@for lang in $(LOCALES); do \
if [ -f src/iac_code/i18n/locales/$$lang/LC_MESSAGES/webui.po ]; then \
uv run pybabel update --ignore-pot-creation-date -D webui -i src/iac_code/i18n/webui.pot -d src/iac_code/i18n/locales -l $$lang > /dev/null 2>&1 && echo "Update webui $$lang: OK" || (echo "Update webui $$lang: FAILED"; exit 1); \
else \
uv run pybabel init -D webui -i src/iac_code/i18n/webui.pot -d src/iac_code/i18n/locales -l $$lang > /dev/null 2>&1 && echo "Init webui $$lang: OK" || (echo "Init webui $$lang: FAILED"; exit 1); \
fi; \
done
@for lang in $(LOCALES); do \
uv run pybabel compile -D webui -d src/iac_code/i18n/locales -l $$lang > /dev/null 2>&1 && echo "Compile webui $$lang: OK" || (echo "Compile webui $$lang: FAILED"; exit 1); \
done
run: ## Run iac-code
IAC_CODE_INSTRUCTION_MEMORY_FILE=IAC-CODE.md uv run iac-code
dev: ## Run iac-code in debug mode
IAC_CODE_INSTRUCTION_MEMORY_FILE=IAC-CODE.md uv run iac-code --debug
web: ## Run iac-code as a local Web app
IAC_CODE_INSTRUCTION_MEMORY_FILE=IAC-CODE.md uv run iac-code web
PIPELINE_NAME ?= selling
pipeline: ## Run iac-code in pipeline mode (PIPELINE_NAME=selling by default)
IAC_CODE_INSTRUCTION_MEMORY_FILE=IAC-CODE.md IAC_CODE_MODE=pipeline IAC_CODE_PIPELINE_NAME=$(PIPELINE_NAME) uv run iac-code
clean: ## Clean build artifacts
rm -rf .ruff_cache .pytest_cache dist build htmlcov .coverage coverage.xml
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type d -name "*.egg-info" -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pot" -delete
find . -type f -name "*.mo" -delete
find . -type f -name ".coverage.*" -delete