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
SHELL = /bin/sh
CARGO ?= cargo
DOCKER_COMPOSE ?= docker compose
COMPOSE_UP_FLAGS ?= -d --wait
COMPOSE_DOWN_FLAGS ?= --remove-orphans
KEEP_COMPOSE ?= 0
CARGO_TEST_ARGS ?= --workspace --all-features
DATABASE_URL ?= postgres://sourced:sourced@localhost:5432/distributed
AMQP_URL ?= amqp://guest:guest@localhost:5672/%2f
KAFKA_BROKERS ?= 127.0.0.1:9092
NATS_URL ?= nats://localhost:4222
test: test-local
.PHONY: test test-local test-cargo compose-up compose-down
test-local:
set -eu; \
if [ "$(KEEP_COMPOSE)" != "1" ]; then \
cleanup() { \
$(DOCKER_COMPOSE) down $(COMPOSE_DOWN_FLAGS); \
}; \
trap cleanup EXIT HUP INT TERM; \
fi; \
$(DOCKER_COMPOSE) up $(COMPOSE_UP_FLAGS); \
export DATABASE_URL="$(DATABASE_URL)"; \
export AMQP_URL="$(AMQP_URL)"; \
export KAFKA_BROKERS="$(KAFKA_BROKERS)"; \
export NATS_URL="$(NATS_URL)"; \
$(CARGO) test $(CARGO_TEST_ARGS) --all-targets; \
$(CARGO) test $(CARGO_TEST_ARGS) --doc
test-cargo:
$(CARGO) test $(CARGO_TEST_ARGS) --all-targets
$(CARGO) test $(CARGO_TEST_ARGS) --doc
compose-up:
$(DOCKER_COMPOSE) up $(COMPOSE_UP_FLAGS)
compose-down:
$(DOCKER_COMPOSE) down $(COMPOSE_DOWN_FLAGS)
.PHONY: contracts-check
## Read-only aggregate contract lifecycle check (never writes tracked files).
contracts-check:
$(CARGO) run -p distributed_cli --quiet -- contracts check --root . --catalog contracts/catalog.json --output human