-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (65 loc) · 1.93 KB
/
Makefile
File metadata and controls
78 lines (65 loc) · 1.93 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
.PHONY: build clean test lint run docker docker-run help
# Build variables
BINARY_NAME=damon
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X main.buildString=${VERSION} -s -w"
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOMOD=$(GOCMD) mod
GOLINT=golangci-lint
# Default target
.DEFAULT_GOAL := help
# Help target for documentation
help:
@echo "Damon - Nomad Event Operator"
@echo ""
@echo "Usage:"
@echo " make build Build the binary"
@echo " make clean Clean build artifacts"
@echo " make test Run unit tests"
@echo " make lint Run linter"
@echo " make run Run the application locally"
@echo " make docker Build Docker image"
@echo " make docker-run Run Docker container"
@echo " make tidy Tidy and verify dependencies"
@echo " make integration Run integration tests"
@echo " make help Show this help message"
# Build the application
build:
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) ./cmd
# Clean build artifacts
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
# Run tests with coverage
test:
$(GOTEST) -v -race -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
# Run integration tests
integration:
DAMON_INTEGRATION_TEST=true $(GOTEST) -v -tags=integration ./test/integration
# Run linter
lint:
$(GOLINT) run
# Run the application locally
run:
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) ./cmd
./$(BINARY_NAME)
# Tidy and verify go modules
tidy:
$(GOMOD) tidy
$(GOMOD) verify
# Build Docker image
docker:
docker build -t $(BINARY_NAME):$(VERSION) -f Dockerfile .
# Run Docker container
docker-run:
docker run --rm -it \
-v $(PWD)/config.toml:/app/config.toml \
-e NOMAD_ADDR=http://host.docker.internal:4646 \
-e NOMAD_TOKEN \
$(BINARY_NAME):$(VERSION)