Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·97 lines (72 loc) · 3.91 KB
/
Copy pathMakefile
File metadata and controls
executable file
·97 lines (72 loc) · 3.91 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
SHELL := /usr/bin/env bash
.DEFAULT_GOAL := help
SERVICES := gateway identity tenant user question-bank assessment submission judge seb notification analytics
# Go code lives under backend/; the web UI under frontend/; apps/ holds standalone apps.
MODULES := backend/libs/pkg $(addprefix backend/services/,$(SERVICES))
.PHONY: help dev-up dev-down dev-judge-up dev-judge-down build test test-integration test-migrations lint proto migrate bootstrap rotate-authz-key fmt fmt-check vet vuln verify-workspace exam-check exam-build exam-up exam-down
help:
@printf '%s\n' 'Targets: exam-check exam-build exam-up exam-down dev-up dev-down dev-judge-up dev-judge-down build test test-integration test-migrations lint proto migrate bootstrap rotate-authz-key fmt fmt-check vet vuln'
verify-workspace:
@cd backend && go work sync
dev-up:
@docker compose --env-file .env --profile platform up -d
dev-down:
@docker compose --env-file .env --profile platform down --remove-orphans
dev-judge-up:
@test -f .judge-control.env
@docker compose --env-file .judge-control.env -f deploy/compose/judge-control.compose.yaml up -d
dev-judge-down:
@test -f .judge-control.env
@docker compose --env-file .judge-control.env -f deploy/compose/judge-control.compose.yaml down --remove-orphans
build: verify-workspace
@for module in $(MODULES); do (cd $$module && go build ./...); done
test: verify-workspace
@for module in $(MODULES); do (cd $$module && go test ./...); done
test-integration:
@for module in $(MODULES); do (cd $$module && go test -tags=integration ./...); done
lint: verify-workspace
@command -v golangci-lint >/dev/null
@for module in $(MODULES); do (cd $$module && golangci-lint run ./...); done
proto:
@command -v buf >/dev/null
@(cd backend/libs/proto && buf lint && buf generate)
migrate:
@test -n "$(SVC)" && test -n "$(DIR)"
@test -n "$$DATABASE_URL"
@(cd backend/libs/pkg && go run ./cmd/migrate --database-url "$$DATABASE_URL" --source "file://$(CURDIR)/backend/services/$(SVC)/migrations" --direction "$(DIR)")
test-migrations: verify-workspace
@backend/scripts/verify-migrations
bootstrap:
@test -n "$(EMAIL)" || { echo "EMAIL is required"; exit 1; }
@test -n "$(NAME)" || { echo "NAME is required"; exit 1; }
@test -n "$$IDENTITY_DATABASE_URL" || { echo "IDENTITY_DATABASE_URL is required"; exit 1; }
@test -n "$$USER_DATABASE_URL" || { echo "USER_DATABASE_URL is required"; exit 1; }
@(cd backend/libs/pkg && go run ./cmd/bootstrap \
--identity-database-url "$$IDENTITY_DATABASE_URL" \
--user-database-url "$$USER_DATABASE_URL" \
--email "$(EMAIL)" --display-name "$(NAME)")
rotate-authz-key:
@test -n "$(ACTION)" || { echo "ACTION is required (publish|retire)"; exit 1; }
@test -n "$(AUDIENCE)" || { echo "AUDIENCE is required"; exit 1; }
@test -n "$$DATABASE_URL" || { echo "DATABASE_URL is required"; exit 1; }
@(cd backend/libs/pkg && go run ./cmd/rotate-authz-key \
--action "$(ACTION)" --audience "$(AUDIENCE)" --database-url "$$DATABASE_URL" \
$(if $(KEY_ID),--key-id "$(KEY_ID)") $(if $(NOT_BEFORE),--not-before "$(NOT_BEFORE)") $(if $(NOT_AFTER),--not-after "$(NOT_AFTER)"))
fmt:
@for module in $(MODULES); do (cd $$module && gofmt -w $$(find . -name '*.go' -type f)); done
fmt-check: verify-workspace
@UNFORMATTED=$$(for module in $(MODULES); do (cd $$module && gofmt -l $$(find . -name '*.go' -type f)); done); \
if [ -n "$$UNFORMATTED" ]; then printf 'unformatted files:\n%s\n' "$$UNFORMATTED"; exit 1; fi
vet: verify-workspace
@for module in $(MODULES); do (cd $$module && go vet ./...); done
vuln: verify-workspace
@command -v govulncheck >/dev/null
@for module in $(MODULES); do (cd $$module && govulncheck ./...); done
exam-check:
@cd apps/exam-v1 && pnpm install --frozen-lockfile && pnpm typecheck && pnpm test
exam-build:
@cd apps/exam-v1 && pnpm install --frozen-lockfile && pnpm build
exam-up:
@cd apps/exam-v1/deploy && docker compose up -d --build
exam-down:
@cd apps/exam-v1/deploy && docker compose down