forked from carlossg/croc-hunter-jenkinsx-serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (64 loc) · 2.07 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
SHELL := /bin/bash
GO := GO15VENDOREXPERIMENT=1 go
NAME := croc-hunter-jenkinsx
OS := $(shell uname)
MAIN_GO := croc-hunter.go
ROOT_PACKAGE := $(GIT_PROVIDER)/$(ORG)/$(NAME)
GO_VERSION := $(shell $(GO) version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/')
PACKAGE_DIRS := $(shell $(GO) list ./... | grep -v /vendor/)
PKGS := $(shell go list ./... | grep -v /vendor | grep -v generated)
PKGS := $(subst :,_,$(PKGS))
BUILDFLAGS := ''
CGO_ENABLED = 0
VENDOR_DIR=vendor
all: build
check: fmt build test
build: skaffold.yaml.new
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
test:
CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(PACKAGE_DIRS) -test.v
full: $(PKGS)
install:
GOBIN=${GOPATH}/bin $(GO) install -ldflags $(BUILDFLAGS) $(MAIN_GO)
fmt:
@FORMATTED=`$(GO) fmt $(PACKAGE_DIRS)`
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
clean:
rm -rf build release
linux: skaffold.yaml.new
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
.PHONY: release clean
FGT := $(GOPATH)/bin/fgt
$(FGT):
go get github.com/GeertJohan/fgt
GOLINT := $(GOPATH)/bin/golint
$(GOLINT):
go get github.com/golang/lint/golint
$(PKGS): $(GOLINT) $(FGT)
@echo "LINTING"
@$(FGT) $(GOLINT) $(GOPATH)/src/$@/*.go
@echo "VETTING"
@go vet -v $@
@echo "TESTING"
@go test -v $@
skaffold.yaml.new:
cp skaffold.yaml skaffold.yaml.new
ifeq ($(OS),Darwin)
sed -i "" -e "s/{{.VERSION}}/x$(VERSION)/" skaffold.yaml.new
sed -i "" -e "s/{{.GIT_COMMIT}}/$(GIT_COMMIT)/" skaffold.yaml.new
else ifeq ($(OS),Linux)
sed -i -e "s/{{.VERSION}}/$(VERSION)/" skaffold.yaml.new
sed -i -e "s/{{.GIT_COMMIT}}/$(GIT_COMMIT)/" skaffold.yaml.new
else
echo "platfrom $(OS) not supported to release from"
exit -1
endif
.PHONY: lint
lint: vendor | $(PKGS) $(GOLINT) # ❷
@cd $(BASE) && ret=0 && for pkg in $(PKGS); do \
test -z "$$($(GOLINT) $$pkg | tee /dev/stderr)" || ret=1 ; \
done ; exit $$ret
watch:
reflex -r "\.go$" -R "vendor.*" make skaffold-run
skaffold-run: build
skaffold run -p dev