-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (73 loc) · 2.84 KB
/
Copy pathMakefile
File metadata and controls
98 lines (73 loc) · 2.84 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
.PHONY: dev build build-all test test-cover test-race bench integration
.PHONY: lint vet check openapi-check openapi-gen tidy-check
.PHONY: docker-build docker-up docker-down
.PHONY: migrate-up migrate-down migrate-version
.PHONY: clean
DEV_DSN ?= postgres://postgres:postgres@localhost:5432/orbitjob?sslmode=disable
DATABASE_URL ?= postgres://postgres:postgres@localhost:5432/orbitjob?sslmode=disable
# ---- Development ----
dev:
DEV_DSN=$(DEV_DSN) go run ./cmd/devserver
# ---- Build ----
build:
go build ./...
build-all:
@mkdir -p bin
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o bin/admin-api ./cmd/admin-api/
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o bin/scheduler ./cmd/scheduler/
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o bin/dispatcher ./cmd/dispatcher/
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o bin/worker ./cmd/worker/
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o bin/bootstrap ./cmd/bootstrap/
# ---- Test ----
test:
go test ./...
test-cover:
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
test-race:
go test -race ./...
bench:
go test -bench=. -benchmem ./...
bench-etcd-memory:
go test -bench=. -benchmem -count=5 ./internal/platform/election/ ./internal/platform/discovery/
bench-etcd:
go test -tags etcd -bench=. -benchmem -count=5 ./internal/platform/election/ ./internal/platform/discovery/
bench-etcd-compare:
bash scripts/bench-etcd.sh
integration:
go test -count=1 -tags integration ./db/migrations ./internal/platform/postgrestest ./internal/admin/bootstrap ./internal/admin/http ./internal/admin/store/postgres ./internal/core/store/postgres ./test/integration
# ---- Lint & Vet ----
lint:
golangci-lint run
vet:
go vet ./...
# ---- Quality Checks ----
check: lint vet test-race openapi-check tidy-check
@echo "All checks passed."
openapi-check:
go run ./cmd/openapi-gen -check -out api/openapi.yaml
openapi-gen:
go run ./cmd/openapi-gen -out api/openapi.yaml
tidy-check:
go mod tidy && git diff --exit-code go.sum
# ---- Docker ----
docker-build:
docker build --target admin -t orbitjob-admin:latest .
docker build --target scheduler -t orbitjob-scheduler:latest .
docker build --target dispatcher -t orbitjob-dispatcher:latest .
docker build --target worker -t orbitjob-worker:latest .
docker-up:
docker compose up -d
docker-down:
docker compose down
# ---- Database Migrations ----
migrate-up:
golang-migrate -path db/migrations -database "$(DATABASE_URL)" up
migrate-down:
golang-migrate -path db/migrations -database "$(DATABASE_URL)" down 1
migrate-version:
golang-migrate -path db/migrations -database "$(DATABASE_URL)" version
# ---- Clean ----
clean:
rm -f coverage.out
rm -rf bin/