-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
150 lines (115 loc) · 4.38 KB
/
Makefile
File metadata and controls
150 lines (115 loc) · 4.38 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
SHELL := /usr/bin/env bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help
GO_MODULES := HadesAPI HadesScheduler HadesScheduler/HadesOperator HadesLogManager shared
GO_PATHS := $(addsuffix /...,$(addprefix ./,$(GO_MODULES)))
COMPOSE ?= docker compose
COMPOSE_FILE ?= compose.yml
.PHONY: help
help: ## Show this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Run (CLI)
.PHONY: run
run: docker-run-nats ## Run api, scheduler, and logmanager locally via go run (Ctrl-C stops all).
@echo "Starting api, scheduler, logmanager (Ctrl-C to stop all)..."
@trap 'kill 0' INT TERM EXIT; \
(cd HadesAPI && go run .) & \
(cd HadesScheduler && go run .) & \
(cd HadesLogManager && go run .) & \
wait
.PHONY: run-api
run-api: ## Run HadesAPI locally via go run.
cd HadesAPI && go run .
.PHONY: run-scheduler
run-scheduler: ## Run HadesScheduler locally via go run.
cd HadesScheduler && go run .
.PHONY: run-logmanager
run-logmanager: ## Run HadesLogManager locally via go run.
cd HadesLogManager && go run .
.PHONY: run-operator
run-operator: ## Run HadesOperator locally via go run (requires a Kubernetes context).
cd HadesScheduler/HadesOperator && go run ./cmd
##@ Run (Docker)
.PHONY: docker-run
docker-run: ## Start the full Hades stack via docker compose.
$(COMPOSE) -f $(COMPOSE_FILE) up -d
.PHONY: docker-run-api
docker-run-api: ## Start only the HadesAPI service via docker compose.
$(COMPOSE) -f $(COMPOSE_FILE) up -d hadesAPI
.PHONY: docker-run-scheduler
docker-run-scheduler: ## Start only the HadesScheduler service via docker compose.
$(COMPOSE) -f $(COMPOSE_FILE) up -d hadesScheduler
.PHONY: docker-run-nats
docker-run-nats: ## Start only the NATS service via docker compose.
$(COMPOSE) -f $(COMPOSE_FILE) up -d nats
.PHONY: docker-stop
docker-stop: ## Stop the local docker compose stack.
$(COMPOSE) -f $(COMPOSE_FILE) down
.PHONY: docker-logs
docker-logs: ## Tail logs from the local docker compose stack.
$(COMPOSE) -f $(COMPOSE_FILE) logs -f
##@ Build
.PHONY: build
build: ## Build all Go modules.
go build $(GO_PATHS)
.PHONY: docker-build
docker-build: ## Build all Hades container images.
docker build -t hades-api:dev -f HadesAPI/Dockerfile .
docker build -t hades-scheduler:dev -f HadesScheduler/Dockerfile .
docker build -t hades-operator:dev -f HadesScheduler/HadesOperator/Dockerfile HadesScheduler/HadesOperator
##@ Quality
.PHONY: test
test: ## Run unit tests across all Go modules.
go test $(GO_PATHS)
.PHONY: test-race
test-race: ## Run unit tests with the race detector.
go test -race $(GO_PATHS)
.PHONY: cover
cover: ## Run tests and open the coverage report for HadesAPI.
cd HadesAPI && go test -coverprofile=cover.out ./... && go tool cover -html=cover.out
.PHONY: test-operator
test-operator: ## Run HadesOperator unit tests (uses envtest).
$(MAKE) -C HadesScheduler/HadesOperator test
.PHONY: test-operator-e2e
test-operator-e2e: ## Run HadesOperator e2e tests (requires Kind).
$(MAKE) -C HadesScheduler/HadesOperator test-e2e
.PHONY: fmt
fmt: ## Format all Go code.
gofmt -s -w $(GO_MODULES)
.PHONY: lint
lint: ## Run go vet across all Go modules.
go vet $(GO_PATHS)
.PHONY: vuln
vuln: ## Run govulncheck across all Go modules.
@command -v govulncheck >/dev/null 2>&1 || { \
echo "Installing govulncheck..."; \
go install golang.org/x/vuln/cmd/govulncheck@latest; \
}
govulncheck $(GO_PATHS)
##@ Dependencies
.PHONY: deps-check
deps-check: ## List outdated direct dependencies across the workspace.
@for m in $(GO_MODULES); do \
echo "==> $$m"; \
(cd $$m && go list -u -m -f '{{if and .Update (not .Indirect)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' all 2>/dev/null | grep -v '^$$') || true; \
done
.PHONY: deps-update
deps-update: ## Bump direct dependencies in every module and tidy.
@for m in $(GO_MODULES); do \
echo "==> $$m"; \
(cd $$m && go get -u ./... && go mod tidy); \
done
go work sync
.PHONY: deps-tidy
deps-tidy: ## Run go mod tidy in every module.
@for m in $(GO_MODULES); do \
echo "==> $$m"; \
(cd $$m && go mod tidy); \
done
go work sync
.PHONY: helm-deps
helm-deps: ## Refresh Helm chart subchart lock file.
helm dependency update ./helm/hades
##@ CI
.PHONY: ci
ci: lint test ## Run lint and test (mirrors CI).