-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (35 loc) · 1.04 KB
/
Makefile
File metadata and controls
51 lines (35 loc) · 1.04 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
.PHONY: build run run-with-logs monitor run-monitor test test-race test-v vet lint format clean validate check
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
LDFLAGS := -ldflags "-X main.gitCommit=$(GIT_COMMIT)"
BIN_DIR := bin
$(BIN_DIR):
@mkdir -p $(BIN_DIR)
build: $(BIN_DIR)
go build $(LDFLAGS) -o $(BIN_DIR)/bot ./cmd/bot
run: build
./$(BIN_DIR)/bot -config config.yaml
run-with-logs: build
./$(BIN_DIR)/bot -config config.yaml 2>&1 | tee logs/logs.txt
monitor: $(BIN_DIR)
go build $(LDFLAGS) -o $(BIN_DIR)/monitor ./cmd/monitor
run-monitor: monitor
./$(BIN_DIR)/monitor
test:
go test ./... -count=1
test-race:
go test ./... -count=1 -race
test-v:
go test ./... -count=1 -v
vet:
go vet ./...
format:
go fmt ./...
lint: vet
@which staticcheck > /dev/null 2>&1 && staticcheck ./... || echo "staticcheck not installed, skipping"
clean:
rm -rf $(BIN_DIR)
validate: build
@for f in config.example.yaml; do \
if [ -f "$$f" ]; then ./$(BIN_DIR)/bot -config "$$f" -validate || exit 1; fi; \
done
check: vet validate test-race