-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathMakefile
64 lines (50 loc) · 1.42 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
SHELL := /bin/bash
GO := GO111MODULE=on go
GO_NOMOD :=GO111MODULE=off go
NAME := bucketrepo
OS := $(shell uname)
MAIN_GO := ./internal
ROOT_PACKAGE := $(GIT_PROVIDER)/$(ORG)/$(NAME)
GO_VERSION := $(shell $(GO) version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/')
BUILDFLAGS := ''
CGO_ENABLED = 0
GOSEC := GO111MODULE=on $(GOPATH)/bin/gosec
GOLINT := GO111MODULE=on $(GOPATH)/bin/golint
all: build fmt lint sec test
.PHONY: build
build:
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
.PHONY: test
test:
CGO_ENABLED=$(CGO_ENABLED) $(GO) test ./... -test.v
.PHONY: install
install:
GOBIN=${GOPATH}/bin $(GO) install -ldflags $(BUILDFLAGS) $(MAIN_GO)
.PHONY: fmt
fmt:
@echo "FORMATTING"
@FORMATTED=`$(GO) fmt ./...`
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
.PHONY: clean
clean:
rm -rf bin release
lint_install:
$(GO_NOMOD) get -u golang.org/x/lint/golint
.PHONY: lint
lint: lint_install
@echo "LINTING"
$(GOLINT) -set_exit_status ./...
@echo "VETTING"
$(GO) vet ./...
sec_install:
$(GO_NOMOD) get -u github.com/securego/gosec/cmd/gosec
.PHONY: sec
sec: sec_install
@echo "SECURITY SCANNING"
$(GOSEC) -fmt=csv ./...
.PHONY: release
release: clean linux test
linux:
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
docker: linux
docker build -t jenkinsxio/bucketrepo:latest .