-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (49 loc) · 2.04 KB
/
Copy pathMakefile
File metadata and controls
59 lines (49 loc) · 2.04 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
.PHONY: db db-init db-reset test test-integration lint build dev-webhook dev-cycle dev-egress-sync
# Start infrastructure (Postgres)
db:
docker compose up -d postgres
@echo "Postgres: localhost:5432"
# Initialize DB schemas + migrations (run once after first `make db`)
db-init:
@sleep 2
psql -h localhost -U mirrorstack -d mirrorstack -f scripts/init-db.sql
# Reset DB (drop + recreate)
db-reset:
docker compose down -v
docker compose up -d postgres
@sleep 2
psql -h localhost -U mirrorstack -d mirrorstack -f scripts/init-db.sql
# Tests (unit only — no external deps)
test:
go test ./...
# Integration tests (require Docker — testcontainers-go boots Postgres as needed).
test-integration:
go test -tags=integration -race -count=1 ./...
# Lint
lint:
go vet ./...
# Build
build:
go build ./...
# Run the local-HTTP webhook receiver. Requires STRIPE_WEBHOOK_SECRET
# and DATABASE_URL set in the environment (load .env.local first).
# Pair with `stripe listen --forward-to localhost:8092/webhook` to
# receive real test-mode events from your Stripe sandbox.
dev-webhook:
cd cmd/account-webhook && go run .
# Run the billing charge cycle once locally (the USAGE/arrears leg, Milestone D
# PR #6). Derives the just-closed UTC calendar-month window, charges every
# account with unbilled usage in it via Stripe, then exits. Requires
# DATABASE_URL + STRIPE_SECRET_KEY (use a restricted rk_test_* key from
# .env.local). Prod runs the same binary on an EventBridge schedule.
dev-cycle:
cd cmd/billing-cycle && go run .
# Run the CDN-egress puller once locally (the platform-infra egress metering
# chokepoint, Milestone D PR #10c). Sweeps the last few CLOSED hour windows,
# queries the Cloudflare Analytics Engine "cdn_egress" dataset, and records each
# (app, module) egress total via RecordInfraUsage (idempotent on a deterministic
# event_id), then exits. Requires DATABASE_URL + CF_ANALYTICS_API_TOKEN (a
# READ-ONLY CF API token) + CF_ACCOUNT_ID. Prod runs the same binary on an
# EventBridge schedule.
dev-egress-sync:
cd cmd/infra-egress-sync && go run .