-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (99 loc) · 3.77 KB
/
Copy pathMakefile
File metadata and controls
125 lines (99 loc) · 3.77 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
.DEFAULT_GOAL := help
SHELL := /bin/sh
PY ?= python
VENV ?= .venv
ifeq ($(OS),Windows_NT)
BIN := $(VENV)/Scripts
else
BIN := $(VENV)/bin
endif
TEST_DB_COMPOSE := deploy/docker-compose.test.yml
REGTEST_COMPOSE := deploy/docker-compose.regtest.yml
.PHONY: help
help:
@grep -hE '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | awk -F':.*?## ' '{printf " %-18s %s\n", $$1, $$2}'
.PHONY: venv
venv: ## Create the local virtualenv
$(PY) -m venv $(VENV)
.PHONY: install
install: ## Install the package plus dev tooling in editable mode
$(BIN)/python -m pip install -U pip
$(BIN)/python -m pip install -e ".[dev]"
.PHONY: lint
lint: ## ruff check + format check
$(BIN)/ruff check .
$(BIN)/ruff format --check .
.PHONY: fmt
fmt: ## Apply ruff formatting and autofixes
$(BIN)/ruff check --fix .
$(BIN)/ruff format .
.PHONY: typecheck
typecheck: ## mypy --strict over src/
$(BIN)/mypy
.PHONY: test-unit
test-unit: ## Unit tests only (no containers needed)
$(BIN)/pytest tests/unit
.PHONY: test-int
test-int: ## Integration tests against the dockerized test Postgres
$(BIN)/pytest tests/integration -m integration
.PHONY: test
test: test-unit test-int ## Full test suite
.PHONY: contracts
contracts: ## Regenerate the committed OpenAPI, webhook, signature and config references
$(BIN)/python scripts/export_openapi.py
$(BIN)/python scripts/export_signature_vectors.py
$(BIN)/python scripts/export_config_reference.py
$(BIN)/python scripts/generate_event_types.py
.PHONY: sdk-python
sdk-python: ## Regenerate the Python SDK core from the committed spec
# Deleted first, so a route that no longer exists leaves a deletion in the
# diff instead of a stale file the drift gate would happily ignore.
rm -rf sdks/python/crypto_processing_client/_generated
openapi-python-client generate \
--path docs/reference/openapi.json \
--meta none \
--config sdks/python/openapi-python-client.yaml \
--output-path sdks/python/crypto_processing_client/_generated \
--overwrite
.PHONY: sdk-ts
sdk-ts: ## Regenerate the TypeScript SDK core from the committed spec
cd sdks/typescript && npm ci && npm run generate
.PHONY: sdks
sdks: contracts sdk-python sdk-ts ## Regenerate every generated file both SDKs contain
.PHONY: cov
cov: ## Coverage gates: 97% over src/, 85% over the ledger (what CI runs)
$(BIN)/pytest --cov=src/crypto_processing_api --cov-report=term-missing --cov-fail-under=97
$(BIN)/coverage report --include="src/crypto_processing_api/ledger/*" --fail-under=85
.PHONY: db-up
db-up: ## Start the throwaway test Postgres (host port 54329)
docker compose -f $(TEST_DB_COMPOSE) up -d
.PHONY: db-down
db-down: ## Stop and wipe the test Postgres
docker compose -f $(TEST_DB_COMPOSE) down -v
.PHONY: migrate
migrate: ## Run alembic upgrade head + idempotent asset seed
$(BIN)/python -m crypto_processing_api.cli migrate
.PHONY: regtest-up
regtest-up: ## Boot the local BTCPay regtest stack
docker compose -f $(REGTEST_COMPOSE) up -d
.PHONY: regtest-down
regtest-down: ## Tear down the regtest stack and its volumes
docker compose -f $(REGTEST_COMPOSE) down -v
.PHONY: bootstrap
bootstrap: ## Configure the regtest BTCPay instance (idempotent)
$(BIN)/python scripts/bootstrap_btcpay.py
.PHONY: mine
mine: ## Mine N regtest blocks, e.g. make mine N=101
sh scripts/dev/mine.sh $(N)
.PHONY: docker-build
docker-build: ## Build the API image
docker build -t crypto-processing-api:dev .
# Needs the example's own pinned dependencies, which the [dev] extra does not
# carry: cd examples/platform-demo && pip install -r requirements.txt
.PHONY: example
example: ## Lint, typecheck and build the example integration app
$(BIN)/ruff check examples
$(BIN)/mypy examples/platform-demo/app.py
docker build -f examples/platform-demo/Dockerfile -t platform-demo:dev .
.PHONY: ci
ci: lint typecheck test cov ## Everything CI runs