-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (52 loc) · 2.32 KB
/
Copy pathMakefile
File metadata and controls
72 lines (52 loc) · 2.32 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
BINARY := cernbox
CMD := ./cmd/cernbox
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)
COMPOSE := docker compose -f dev/docker-compose.yaml
.PHONY: all build install test test-race test-cover test-integration test-all \
lint vet fmt tidy clean completions dev-up dev-down dev-logs help
all: build
build: ## Build the cernbox binary
go build -ldflags "$(LDFLAGS)" -o $(BINARY) $(CMD)
install: ## Install the cernbox binary into GOBIN
go install -ldflags "$(LDFLAGS)" $(CMD)
test: ## Run unit tests
go test ./...
test-race: ## Run unit tests with the race detector
go test -race ./...
test-cover: ## Run unit tests and write coverage.out / coverage.html
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@go tool cover -func=coverage.out | tail -1
test-integration: build ## Run integration tests (requires: make dev-up)
go test -tags integration -count=1 -timeout 20m ./integration/...
test-all: dev-up test test-integration ## Run every test suite
lint: vet ## Run go vet and golangci-lint
@command -v golangci-lint >/dev/null 2>&1 && golangci-lint run ./... || \
echo "golangci-lint not installed, skipping"
vet: ## Run go vet
go vet ./...
fmt: ## Format the code
go fmt ./...
tidy: ## Tidy go.mod
go mod tidy
completions: ## Generate shell completion scripts for packaging
@mkdir -p packaging/completions
go run $(CMD) completion bash > packaging/completions/cernbox.bash
go run $(CMD) completion zsh > packaging/completions/cernbox.zsh
go run $(CMD) completion fish > packaging/completions/cernbox.fish
clean: ## Remove build and test artifacts
rm -f $(BINARY) coverage.out coverage.html
rm -rf packaging/completions
dev-up: ## Start the dev environment (revad + EOS)
$(COMPOSE) up -d --build
@./dev/wait-for-revad.sh
dev-down: ## Stop the dev environment
$(COMPOSE) down -v
dev-logs: ## Tail revad logs
$(COMPOSE) logs -f revad
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'