-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
74 lines (55 loc) · 1.75 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
66
67
68
69
70
71
72
73
74
SHELL := bash
LINTER_VERSION=v1.51.2
BINARY = sn-export-folder
ifeq ($(OS),Windows_NT)
BINARY := $(BINARY).exe
endif
.PHONY: test run
## default: linting, test and build the application binary
default: build
## mod: run go mod vendor -v
mod:
go mod vendor -v
## tidy: run go mod tidy -v
tidy:
go mod tidy -v
## mod-tidy: runs go mod and tidy together
mod-tidy: mod tidy
## lint: download/install golangci-lint and analyse the source code with the configuration in .golangci.yml
lint: #get-linter
./bin/golangci-lint run --timeout=5m
## lint-fix: download/install golangci-lint, analyse and fix the source code with the configuration in .golangci.yml
lint-fix: get-linter
./bin/golangci-lint run --timeout=5m --fix
get-linter:
command -v ./bin/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(LINTER_VERSION)
## build: test and build the application binary
build: clean test
go build -o ./$(BINARY) ./...
## format: run go format
format:
go fmt ./...
## test: run mod, tidy, linters and run unit tests
test: mod-tidy lint test-unit
## test-unit: run unit tests
test-unit: format
go test ./...
## cover-report: run coverage and show html report
cover-report: cover
go tool cover -html=coverage.out
## cover: run tests with coverage report.
cover:
go test -v -coverprofile=coverage.out -coverpkg=./... ./...
go tool cover -func coverage.out
## run: runs the service locally with go run using the config defined on the Makefile
run:
go run ./...
## clean: remove exported folders, built binary and coverage
clean:
rm -f $(BINARY)
rm -rf exported
rm -f coverage.out
## help: prints this help message
help:
@echo "Usage:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'