forked from drone/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (38 loc) · 1.31 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
# Make does not offer a recursive wildcard function, so here's one:
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
GO_DEPENDENCIES := $(call rwildcard,pkg/,*.go) $(call rwildcard,scm/,*.go)
GO := GO111MODULE=on go
GO_NOMOD := GO111MODULE=off go
build: test
test:
go test ./...
linux: build
.PHONY: check
check: fmt lint sec ## Runs Go format check as well as security checks
get-fmt-deps:
$(GO_NOMOD) get golang.org/x/tools/cmd/goimports
.PHONY: importfmt
importfmt: get-fmt-deps ## Checks the import format of the Go source files
@echo "FORMATTING IMPORTS"
@goimports -w $(GO_DEPENDENCIES)
.PHONY: fmt ## Checks Go source files are formatted properly
fmt: importfmt
@echo "FORMATTING SOURCE"
FORMATTED=`$(GO) fmt ./...`
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed un-formatted files:\n$(FORMATTED)") || true
GOLINT := $(GOPATH)/bin/golint
$(GOLINT):
$(GO_NOMOD) get -u golang.org/x/lint/golint
.PHONY: lint
lint: $(GOLINT) ## Runs 'go vet' anf 'go lint'
@echo "VETTING"
$(GO) vet ./...
@echo "LINTING"
$(GOLINT) -set_exit_status ./...
GOSEC := $(GOPATH)/bin/gosec
$(GOSEC):
$(GO_NOMOD) get -u github.com/securego/gosec/cmd/gosec
.PHONY: sec
sec: $(GOSEC) ## Runs gosec to check for potential security issues in the Go source
@echo "SECURITY SCANNING"
$(GOSEC) -quiet -fmt=csv ./...