-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
55 lines (36 loc) · 1.54 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
#@IgnoreInspection BashAddShebang
export ROOT=$(realpath $(dir $(lastword $(MAKEFILE_LIST))))
export APP=my-app
export BUILD_INFO_PKG="github.com/saman2000hoseini/golang-boilerplate/pkg/version"
export LDFLAGS="-w -s -X '$(BUILD_INFO_PKG).Date=$$(date)' -X '$(BUILD_INFO_PKG).BuildVersion=$$(git rev-parse HEAD | cut -c 1-8)' -X '$(BUILD_INFO_PKG).VCSRef=$$(git rev-parse --abbrev-ref HEAD)'"
all: format lint build
run-version:
go run -ldflags $(LDFLAGS) ./cmd/my-app version
run-api:
go run -ldflags $(LDFLAGS) ./cmd/my-app api
build:
go build -ldflags $(LDFLAGS) ./cmd/my-app
install:
go install -ldflags $(LDFLAGS) ./cmd/my-app
check-formatter:
which goimports || GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports
format: check-formatter
find $(ROOT) -type f -name "*.go" -not -path "$(ROOT)/vendor/*" | xargs -n 1 -I R goimports -w R
find $(ROOT) -type f -name "*.go" -not -path "$(ROOT)/vendor/*" | xargs -n 1 -I R gofmt -s -w R
check-linter:
which golangci-lint || GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint@v1.23.8
lint: check-linter
golangci-lint run $(ROOT)/...
install-hook:
git config --local core.hooksPath ./githooks
test:
go test -ldflags $(LDFLAGS) -v -race -p 1 `go list ./... | grep -v integration`
ci-test:
go test -ldflags $(LDFLAGS) -v -race -p 1 -coverprofile=coverage.txt -covermode=atomic ./...
go tool cover -func coverage.txt
integration-tests:
go test -ldflags $(LDFLAGS) -v -race -p 1 `go list ./... | grep integration`
up:
docker-compose up -d
down:
docker-compose down