Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
190 lines (157 loc) · 6.14 KB
/
Copy pathMakefile
File metadata and controls
190 lines (157 loc) · 6.14 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
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
.DEFAULT_GOAL := help
.PHONY: help s bootstrap build fmt fmt-check vet lint tidy \
test test-unit test-integration test-e2e test-race coverage \
dev-up dev-down dev-recreate dev-api \
svr-up svr-down config docs docs-build docs-serve docs-check \
localstack logs clean
# ---------------------------------------------------------------------------
# Docker Compose — all service files merged via -f flags
# ---------------------------------------------------------------------------
COMPOSE = docker compose --project-directory . \
-f docker/network.yaml \
-f docker/postgres.yaml \
-f docker/pgadmin.yaml \
-f docker/redis.yaml \
-f docker/keycloak.yaml \
-f docker/server.yaml \
-f docker/sample.yaml \
-f docker/localstack.yaml
GO ?= go
BIN_DIR ?= .bin
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
help:
@echo "Gorape development tasks"
@echo ""
@echo " Setup / build"
@echo " make bootstrap Copy etc/*.yaml.example to local config files"
@echo " make build Build binaries into $(BIN_DIR)/"
@echo " make tidy go mod tidy"
@echo ""
@echo " Development environment"
@echo " make dev-up Start postgres, redis, pgadmin, keycloak"
@echo " make dev-down Stop and remove dev containers and volumes"
@echo " make dev-recreate dev-down + dev-up"
@echo " make dev-api Run the API on the host (etc/server.yaml)"
@echo " make svr-up Build and start the server container"
@echo " make svr-down Stop and remove the server container"
@echo " make localstack Start LocalStack (secretsmanager mock)"
@echo " make logs Follow logs (SERVICE=postgres to filter)"
@echo " make config Validate the merged compose configuration"
@echo ""
@echo " Documentation"
@echo " make docs Build the GitHub Pages artifact into _site"
@echo " make docs-check Validate GF source links and OpenAPI endpoint table"
@echo " make docs-serve Build and serve _site at http://localhost:8000"
@echo ""
@echo " Quality"
@echo " make fmt gofmt -w cmd pkg test"
@echo " make fmt-check Fail if any file is not gofmt'd"
@echo " make vet go vet ./..."
@echo " make lint fmt-check + vet"
@echo " make test go test ./..."
@echo " make test-unit go test ./test/unit/..."
@echo " make test-integration go test ./test/integration/..."
@echo " make test-e2e go test -tags=e2e ./test/e2e/..."
@echo " make test-race go test -race ./..."
@echo " make coverage Write coverage.out and coverage.html"
@echo " make clean Remove coverage artifacts"
# ---------------------------------------------------------------------------
# Git shortcut (same as .legacy-cmn-core/Makefile)
# ---------------------------------------------------------------------------
s:
git add .
commit-emoji
git push origin main
# ---------------------------------------------------------------------------
# Setup / build
# ---------------------------------------------------------------------------
bootstrap:
@test -f etc/server.yaml || cp etc/server.yaml.example etc/server.yaml
@test -f etc/app.yaml || cp etc/app.yaml.example etc/app.yaml
@test -f etc/admin.yaml || cp etc/admin.yaml.example etc/admin.yaml
@echo "Local configuration ready in etc/"
build:
mkdir -p $(BIN_DIR)
$(GO) build -o $(BIN_DIR)/gorape ./cmd/server
$(GO) build -o $(BIN_DIR)/gorape-admin ./cmd/client/admin
$(GO) build -o $(BIN_DIR)/gorape-client ./cmd/client/app
$(GO) build -o $(BIN_DIR)/gorape-health ./cmd/client/anonymous
tidy:
$(GO) mod tidy
# ---------------------------------------------------------------------------
# Development environment (core infra + IdP; server excluded)
# ---------------------------------------------------------------------------
dev-up:
$(COMPOSE) up -d postgres redis pgadmin keycloak
dev-down:
$(COMPOSE) down -v --remove-orphans
dev-recreate:
$(MAKE) dev-down
$(MAKE) dev-up
# Run the API on the host against the dockerized dependencies
dev-api:
$(GO) run ./cmd/server -config etc/server.yaml
# App server container (build image and start, dependencies unchanged)
svr-up:
$(COMPOSE) up -d --build --no-deps server
# Sample external service backend + Vue web container
sample-up:
$(COMPOSE) up -d --build --no-deps sample-backend sample-web
sample-down:
$(COMPOSE) stop sample-web sample-backend
$(COMPOSE) rm -f -v sample-web sample-backend
# Stop and remove the app server container only
svr-down:
$(COMPOSE) stop server
$(COMPOSE) rm -f -v server
config:
$(COMPOSE) config --quiet
@echo "Compose configuration is valid"
# ---------------------------------------------------------------------------
# Documentation
# ---------------------------------------------------------------------------
docs-check:
./scripts/check-docs.sh
docs: docs-check
./scripts/main.sh docs build
docs-build: docs
docs-serve: docs-check
./scripts/main.sh docs serve
# ---------------------------------------------------------------------------
# AWS mock (localstack)
# ---------------------------------------------------------------------------
localstack:
$(COMPOSE) up -d localstack
# Logs (pass SERVICE= to filter, e.g. make logs SERVICE=postgres)
logs:
$(COMPOSE) logs -f $(SERVICE)
# ---------------------------------------------------------------------------
# Quality / tests
# ---------------------------------------------------------------------------
fmt:
gofmt -w cmd pkg test
fmt-check:
@test -z "$$(gofmt -l cmd pkg test)" || { \
echo "gofmt required:"; gofmt -l cmd pkg test; exit 1; \
}
vet:
$(GO) vet ./...
lint: fmt-check vet
test:
$(GO) test ./...
test-unit:
$(GO) test ./test/unit/...
test-integration:
$(GO) test ./test/integration/...
test-e2e:
$(GO) test -tags=e2e ./test/e2e/...
test-race:
$(GO) test -race ./...
coverage:
$(GO) test -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
clean:
rm -f coverage.out coverage.html