-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
60 lines (46 loc) · 1.2 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
GO := $(shell which go)
GOPATH := $(shell go env GOPATH)
GOBIN := $(GOPATH)/bin
GOLINT := $(GOBIN)/golint
COVERAGE_FILE := coverage.out
MOCKERY := $(shell which mockery)
# main tasks
.PHONY: run
run:
$(GO) run cmd/main.go
.PHONY: test
test: clean lint vet unit
.PHONY: coverage-html
coverage-html: unit
$(GO) tool cover -html=$(COVERAGE_FILE)
# sub tasks
.PHONY: clean
clean:
rm -rf $(COVERAGE_FILE)
.PHONY: lint-install
lint-install:
test -e $(GOLINT) || $(GO) get -u golang.org/x/lint/golint
.PHONY: lint
lint: lint-install
$(GO) list ./... | grep -v /vendor/ | xargs -L1 $(GOLINT) -set_exit_status
.PHONY: vet
vet:
$(GO) vet ./...
.PHONY: unit
unit:
$(GO) test -race -v ./... -coverprofile=$(COVERAGE_FILE)
.PHONY: coverage
coverage: unit
$(GO) tool cover -func=$(COVERAGE_FILE)
.PHONY: mockery-install
mockery-install:
test -e $(MOCKERY) || $(GO) get github.com/vektra/mockery/v2/.../
.PHONY: generate
generate: mockery-install
$(GO) generate ./...
build:
go build -o bin/twitter-server cmd/main.go && ./bin/twitter-server
build-lambda:
CGO_ENABLED=0 GOOS=linux go build -o bin/twitter-lambda cmd/main.go
scan:
gosec -exclude-generated -nosec=false ./... ./...