-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (54 loc) · 1.23 KB
/
Makefile
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
# Go parameters
# Set go commands
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
# Linter variables
# Set linter version and binary location
LINTER_VERSION := v1.52.2
LINTER_BINARY := ./bin/golangci-lint
# Binary name
# Set binary name
BINARY_NAME=Similarity
.PHONY: all
# Target to run tests and build the binary
all: lint mocks test build
# Build the project
.PHONY: build
build:
$(GOBUILD) -o ./bin/$(BINARY_NAME) -v ./cmd/...
# Run linter
.PHONY: lint
lint: $(LINTER_BINARY)
$(LINTER_BINARY) run ./...
# Generate mocks
.PHONY: mocks
mocks:
go generate ./...
# Run tests and generate coverage report
.PHONY: test
test: $(LINTER_BINARY)
# Run tests
go test -v -race -coverprofile=coverage.out ./...
# Generate HTML coverage report
go tool cover -html=coverage.out -o coverage.html
# Remove binary and linter binary
.PHONY: clean
clean:
$(GOCLEAN)
rm -rf bin/
# Build and run the binary
.PHONY: run
run: build
./bin/$(BINARY_NAME)
# Download dependencies
.PHONY: deps
deps:
$(GOGET) ./...
# Install linter if necessary
$(LINTER_BINARY):
@mkdir -p $(@D)
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s -- -b $(dir $@) $(LINTER_VERSION)