-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (45 loc) · 1.28 KB
/
Copy pathMakefile
File metadata and controls
57 lines (45 loc) · 1.28 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
APP_NAME = dbtop
BUILD_DIR = bin
DOCKER_COMPOSE ?= docker compose
dbtop_TEST_DSN_POSTGRES ?= postgres://postgres:pass@127.0.0.1:5432/dev?sslmode=disable
dbtop_TEST_DSN_MYSQL ?= mysql://root:pass@127.0.0.1:3306/dev?parseTime=true
.PHONY: all build install uninstall clean test test-integration compose-up compose-down lint
all: build
build:
@echo "Building $(APP_NAME)..."
@mkdir -p $(BUILD_DIR)
go build -o $(BUILD_DIR)/$(APP_NAME) .
install:
@echo "Installing $(APP_NAME)..."
@bin_dir=$$(go env GOBIN); \
if [ -z "$$bin_dir" ]; then \
bin_dir=$$(go env GOPATH)/bin; \
fi; \
mkdir -p "$$bin_dir"; \
echo "Installing to $$bin_dir/$(APP_NAME)"; \
go build -o "$$bin_dir/$(APP_NAME)" .
uninstall:
@echo "Uninstalling $(APP_NAME)..."
@bin_dir=$$(go env GOBIN); \
if [ -z "$$bin_dir" ]; then \
bin_dir=$$(go env GOPATH)/bin; \
fi; \
echo "Removing $$bin_dir/$(APP_NAME)"; \
rm -f "$$bin_dir/$(APP_NAME)"
clean:
@echo "Cleaning up..."
rm -rf $(BUILD_DIR)
test:
go test ./... -race
test-integration:
go test -tags=integration -p 1 ./... -race $(GOTESTFLAGS)
compose-up:
$(DOCKER_COMPOSE) up -d --wait
compose-down:
$(DOCKER_COMPOSE) down
lint:
@command -v golangci-lint >/dev/null 2>&1 || { \
echo "golangci-lint is not installed"; \
exit 1; \
}
golangci-lint run