forked from openfga/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (48 loc) · 2.06 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
#-----------------------------------------------------------------------------------------------------------------------
# Variables (https://www.gnu.org/software/make/manual/html_node/Using-Variables.html#Using-Variables)
#-----------------------------------------------------------------------------------------------------------------------
BINARY_NAME = fga
BUILD_DIR ?= $(CURDIR)/dist
GO_BIN ?= $(shell go env GOPATH)/bin
#-----------------------------------------------------------------------------------------------------------------------
# Rules (https://www.gnu.org/software/make/manual/html_node/Rule-Introduction.html#Rule-Introduction)
#-----------------------------------------------------------------------------------------------------------------------
$(GO_BIN)/golangci-lint:
@echo "==> Installing golangci-lint within "${GO_BIN}""
@go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
$(GO_BIN)/govulncheck:
@echo "==> Installing govulncheck within "${GO_BIN}""
@go install -v golang.org/x/vuln/cmd/govulncheck@latest
$(GO_BIN)/gofumpt:
@echo "==> Installing gofumpt within "${GO_BIN}""
@go install -v mvdan.cc/gofumpt@latest
$(BUILD_DIR)/$(BINARY_NAME):
@echo "==> Building binary within ${BUILD_DIR}/${BINARY_NAME}"
go build -v -o ${BUILD_DIR}/${BINARY_NAME} main.go
.PHONY: build run clean test lint audit format
build: $(BUILD_DIR)/$(BINARY_NAME)
run: $(BUILD_DIR)/$(BINARY_NAME)
${BUILD_DIR}/${BINARY_NAME} $(ARGS)
clean:
@echo "==> Cleaning project files"
go clean
rm -f ${BUILD_DIR}
test:
go test -race \
-coverpkg=./... \
-coverprofile=coverageunit.tmp.out \
-covermode=atomic \
-count=1 \
-timeout=5m \
./...
@cat coverageunit.tmp.out | grep -v "mocks" > coverageunit.out
@rm coverageunit.tmp.out
lint: $(GO_BIN)/golangci-lint
@echo "==> Linting Go source files"
@golangci-lint run -v --fix -c .golangci.yaml ./...
audit: $(GO_BIN)/govulncheck
@echo "==> Checking Go source files for vulnerabilities"
govulncheck ./...
format: $(GO_BIN)/gofumpt $(GO_BIN)/gci
@echo "==> Formatting project files"
gofumpt -w .