-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (68 loc) · 1.88 KB
/
Makefile
File metadata and controls
86 lines (68 loc) · 1.88 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
APP_NAME := seer
START_CMD := start
BIN_DIR := ./bin
SRC_DIR := ./cmd
VERSION := $(shell git describe --tags --always --dirty)
BUILD_TIME := $(shell date -u '+%Y-%m-%dT%H:%M:%S')
GO := go
MOCK_GEN := mockgen
MOCKS_DIR := ./mocks
INTERFACES_DIR := ./interfaces
#Linting and formatting
LINTER := golangci-lint
FMT := gofmt
.PHONY: all build run lint
all: build
mock-gen:
@echo "generating mocks..."
@for file in $(INTERFACES_DIR)/*.go; do \
filename=$$(basename $$file .go); \
$(MOCK_GEN) -source=$$file -destination=$(MOCKS_DIR)/$$filename\_mock.go -package=mocks; \
echo "Generated mock for $$file"; \
done
build: mock-gen
@echo "Building $(APP_NAME)..."
@mkdir -p $(BIN_DIR)
$(GO) build -o $(BIN_DIR)/$(APP_NAME) \
-ldflags "-X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME)" $(SRC_DIR)
deps-up:
@echo "Starting InfluxDB and Grafana containers..."
@env -u INFLUXDB_TOKEN docker-compose up -d
deps-down:
@echo "Stopping InfluxDB and Grafana containers..."
@docker-compose down
deps-wait:
@echo "Waiting for InfluxDB to be ready..."
@until curl --fail --silent --output /dev/null http://localhost:8086/health; do \
echo -n "."; \
sleep 1; \
done
@echo "\nInfluxDB is ready!"
run: build init deps-up deps-wait
@echo "Running $(APP_NAME)..."
cd $(BIN_DIR) && ./$(APP_NAME) $(START_CMD) --config ../config/config.yaml
init:
@echo "setting up tokens and configuration"
@./generate-token.sh
reset-token:
@echo "setting up tokens and configuration"
@./generate-token.sh --force
reset:
@echo "resetting volumes deleting influxdb data"
@docker-compose down -v
test:
@echo "Running tests..."
$(GO) test -v ./...
clean:
@echo "Cleaning build artifacts..."
$(GO) clean -cache
@rm -rf $(BIN_DIR)
lint:
@echo "Linting code..."
$(LINTER) run ./...
format:
@echo "Formating code..."
$(FMT) -s -w .
install:
@echo "Installing dependencies..."
$(GO) mod tidy