-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
223 lines (179 loc) · 6.18 KB
/
Makefile
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
.EXPORT_ALL_VARIABLES:
# SHELL = bash
# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-ce/eventstoredb-ce:22.10.4-jammy
# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-ce/eventstoredb-ce:23.10.0-jammy
# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-ce/eventstoredb-oss:24.6.0-jammy
EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore/eventstoredb-ee:24.10.0-x64-8.0-bookworm-slim
# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-ce/eventstoredb-ce:24.2.0-alpha.115-jammy
# EVENTSTORE_DOCKER_IMAGE ?= docker.eventstore.com/eventstore-staging-ce/eventstoredb-ce:24.6.0-nightly-x64-8.0-jammy
POETRY ?= poetry
POETRY_VERSION=1.5.1
POETRY_INSTALLER_URL ?= https://install.python-poetry.org
PYTHONUNBUFFERED=1
SAMPLES_LINE_LENGTH=70
.PHONY: install-poetry
install-poetry:
@curl -sSL $(POETRY_INSTALLER_URL) | python3
$(POETRY) --version
.PHONY: install-packages
install-packages:
$(POETRY) --version
$(POETRY) install --no-root -vv $(opts)
.PHONY: install
install:
$(POETRY) --version
$(POETRY) install -vv $(opts)
.PHONY: install-pre-commit-hooks
install-pre-commit-hooks:
ifeq ($(opts),)
$(POETRY) run pre-commit install
endif
.PHONY: uninstall-pre-commit-hooks
uninstall-pre-commit-hooks:
ifeq ($(opts),)
$(POETRY) run pre-commit uninstall
endif
.PHONY: lock-packages
lock-packages:
$(POETRY) lock -vv --no-update
.PHONY: update-packages
update-packages:
$(POETRY) update -vv
.PHONY: lint-black
lint-black:
$(POETRY) run black --check --diff --extend-exclude samples .
$(POETRY) run black --check --diff --line-length=$(SAMPLES_LINE_LENGTH) ./samples
.PHONY: lint-flake8
lint-flake8:
$(POETRY) run flake8
.PHONY: lint-isort
lint-isort:
$(POETRY) run isort --check-only --diff --extend-skip-glob samples .
$(POETRY) run isort --check-only --diff --line-length=$(SAMPLES_LINE_LENGTH) samples
.PHONY: lint-mypy
lint-mypy:
$(POETRY) run mypy --strict
.PHONY: lint-python
lint-python: lint-black lint-flake8 lint-isort lint-mypy
.PHONY: lint
lint: lint-python
.PHONY: fmt-black
fmt-black:
$(POETRY) run black --extend-exclude=samples .
$(POETRY) run black --line-length=$(SAMPLES_LINE_LENGTH) ./samples
.PHONY: fmt-isort
fmt-isort:
$(POETRY) run isort --extend-skip=samples .
$(POETRY) run isort --line-length=$(SAMPLES_LINE_LENGTH) samples
.PHONY: fmt
fmt: fmt-isort fmt-black
.PHONY: test
test:
@timeout --preserve-status --kill-after=10s 10m $(POETRY) run coverage run -m unittest discover ./tests -v
$(POETRY) run coverage report --fail-under=100 --show-missing
# $(POETRY) run python -m pytest -v $(opts) $(call tests,.) & read -t 1 ||
# $(POETRY) run python -m pytest -v tests/test_docs.py
# $(POETRY) run python -m unittest discover tests -v
.PHONY: build
build:
$(POETRY) build
# $(POETRY) build -f sdist # build source distribution only
.PHONY: publish
publish:
$(POETRY) publish
# Orig proto files: https://github.com/EventStore/EventStore/tree/master/src/Protos/Grpc
.PHONY: grpc-stubs
grpc-stubs:
$(POETRY) run python -m grpc_tools.protoc \
--proto_path=./protos \
--python_out=. \
--grpc_python_out=. \
--mypy_out=. \
protos/esdbclient/protos/Grpc/code.proto \
protos/esdbclient/protos/Grpc/shared.proto \
protos/esdbclient/protos/Grpc/status.proto \
protos/esdbclient/protos/Grpc/streams.proto \
protos/esdbclient/protos/Grpc/persistent.proto \
protos/esdbclient/protos/Grpc/gossip.proto \
protos/esdbclient/protos/Grpc/cluster.proto \
protos/esdbclient/protos/Grpc/projections.proto
.PHONY: start-eventstoredb-insecure
start-eventstoredb-insecure:
@docker run -d -i -t -p 2113:2113 \
--env "EVENTSTORE_ADVERTISE_HOST_TO_CLIENT_AS=localhost" \
--env "EVENTSTORE_ADVERTISE_HTTP_PORT_TO_CLIENT_AS=2113" \
--env "EVENTSTORE_RUN_PROJECTIONS=All" \
--env "EVENTSTORE_START_STANDARD_PROJECTIONS=true" \
--env "EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=true" \
--name my-eventstoredb-insecure \
$(EVENTSTORE_DOCKER_IMAGE) \
--insecure
.PHONY: start-eventstoredb-secure
start-eventstoredb-secure:
@docker run -d -i -t -p 2114:2113 \
--env "HOME=/tmp" \
--env "EVENTSTORE_ADVERTISE_HOST_TO_CLIENT_AS=localhost" \
--env "EVENTSTORE_ADVERTISE_HTTP_PORT_TO_CLIENT_AS=2114" \
--env "EVENTSTORE_RUN_PROJECTIONS=All" \
--env "EVENTSTORE_START_STANDARD_PROJECTIONS=true" \
--name my-eventstoredb-secure \
$(EVENTSTORE_DOCKER_IMAGE) \
--dev
.PHONY: attach-eventstoredb-insecure
attach-eventstoredb-insecure:
@docker exec -it my-eventstoredb-insecure /bin/bash
.PHONY: attach-eventstoredb-secure
attach-eventstoredb-secure:
@docker exec -it my-eventstoredb-secure /bin/bash
.PHONY: stop-eventstoredb-insecure
stop-eventstoredb-insecure:
@docker stop my-eventstoredb-insecure
@docker rm my-eventstoredb-insecure
.PHONY: stop-eventstoredb-secure
stop-eventstoredb-secure:
@docker stop my-eventstoredb-secure
@docker rm my-eventstoredb-secure
.PHONY: start-eventstoredb
start-eventstoredb: start-eventstoredb-insecure start-eventstoredb-secure docker-up
.PHONY: stop-eventstoredb
stop-eventstoredb: stop-eventstoredb-insecure stop-eventstoredb-secure docker-down
.PHONY: docker-pull
docker-pull:
@docker compose pull
.PHONY: docker-build
docker-build:
@docker compose build
.PHONY: docker-up
docker-up:
@docker --version
@docker compose up -d
@echo "Waiting for containers to be healthy"
@until docker compose ps | grep -in "healthy" | wc -l | grep -in 3 > /dev/null; do printf "." && sleep 1; done; echo ""
@docker compose ps
@sleep 15
.PHONY: docker-stop
docker-stop:
@docker compose stop
.PHONY: docker-down
docker-down:
@docker compose down -v --remove-orphans
.PHONY: docker-logs
docker-logs:
@docker compose logs --follow --tail=1000
# Jaeger natively supports OTLP to receive trace data. You can run Jaeger in a docker container
# with the UI accessible on port 16686 and OTLP enabled on ports 4317 and 4318.
# https://opentelemetry.io/docs/languages/python/exporters/#jaeger
.PHONY: start-jaeger
start-jaeger:
@docker run -d \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 16686:16686 \
-p 4317:4317 \
-p 4318:4318 \
-p 9411:9411 \
--name jaeger \
jaegertracing/all-in-one:latest
.PHONY: stop-jaeger
stop-jaeger:
@docker stop jaeger
@docker rm jaeger