-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (104 loc) · 2.88 KB
/
Makefile
File metadata and controls
130 lines (104 loc) · 2.88 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
VIRTUAL_ENV ?= .venv
EXAMPLE = example
PACKAGE = muffin_admin
all: $(VIRTUAL_ENV)
.PHONY: help
# target: help - Display callable targets
help:
@egrep "^# target:" [Mm]akefile
.PHONY: clean
# target: clean - Display callable targets
clean:
rm -rf build/ dist/ docs/_build *.egg-info
find $(CURDIR) -name "*.py[co]" -delete
find $(CURDIR) -name "*.orig" -delete
find $(CURDIR)/$(MODULE) -name "__pycache__" | xargs rm -rf
# =============
# Development
# =============
$(VIRTUAL_ENV): pyproject.toml .pre-commit-config.yaml
@uv sync
@uv run pre-commit install
@touch $(VIRTUAL_ENV)
.PHONY: test t
# target: test - Runs tests
test t: $(VIRTUAL_ENV)
@uv run pytest tests
example/db.sqlite: $(VIRTUAL_ENV)
@uv run muffin $(EXAMPLE) db
@uv run muffin $(EXAMPLE) devdata
sqlite: example/db.sqlite
sqlite3 example/db.sqlite
.PHONY: locales
LOCALE ?= ru
locales: $(VIRTUAL_ENV)/bin/py.test db.sqlite
@uv run muffin $(EXAMPLE) extract_messages $(PACKAGE) --locale $(LOCALE)
@uv run muffin $(EXAMPLE) compile_messages
.PHONY: front
front:
make -C frontend
.PHONY: front-watch
front-watch:
make -C frontend watch
.PHONY: front-dev
front-dev:
make -C frontend dev
.PHONY: dev
dev:
BACKEND_PORT=5555 make -j example-peewee front-dev
.PHONY: lint
lint: $(VIRTUAL_ENV)
@uv run mypy $(PACKAGE)
@uv run ruff check $(PACKAGE)
BACKEND_PORT ?= 8080
.PHONY: example-peewee
# target: example-peewee - Run example
example-peewee: $(VIRTUAL_ENV) front
@MUFFIN_AIOLIB=asyncio uv run muffin example.peewee_orm db
@MUFFIN_AIOLIB=asyncio uv run muffin example.peewee_orm devdata
@MUFFIN_AIOLIB=asyncio uv run uvicorn example.peewee_orm:app --reload --port=$(BACKEND_PORT)
shell: $(VIRTUAL_ENV)
@uv run muffin example.peewee_orm shell
.PHONY: example-sqlalchemy
# target: example-sqlalchemy - Run example
example-sqlalchemy: $(VIRTUAL_ENV) front
@uv run uvicorn example.sqlalchemy_core:app --reload --port=8080
# ==============
# Bump version
# ==============
VERSION ?= minor
MAIN_BRANCH = master
STAGE_BRANCH = develop
.PHONY: release
# target: release - Bump version
release:
git checkout $(MAIN_BRANCH)
git pull
git checkout $(STAGE_BRANCH)
git pull
uvx bump-my-version bump $(VERSION)
uv lock
@CVER="$$(uv version --short)"; \
{ \
printf 'build(release): %s\n\n' "$$CVER"; \
printf 'Changes:\n\n'; \
git log --oneline --pretty=format:'%s [%an]' $(MAIN_BRANCH)..$(STAGE_BRANCH) | grep -Evi 'github|^Merge' || true; \
} | git commit -a -F -; \
git tag -a "$$CVER" -m "$$CVER";
git checkout $(MAIN_BRANCH)
git merge $(STAGE_BRANCH)
git checkout $(STAGE_BRANCH)
git merge $(MAIN_BRANCH)
@git -c push.followTags=false push origin $(STAGE_BRANCH) $(MAIN_BRANCH)
@git push --tags origin
@echo "Release process complete for `uv version --short`"
.PHONY: minor
minor: release
.PHONY: patch
patch:
make release VERSION=patch
.PHONY: major
major:
make release VERSION=major
version v:
uv version --short