1515
1616SHELL =/bin/bash -o pipefail
1717
18- # The binary to build (just the basename).
18+ GO_PKG := stash.appscode.dev
19+ REPO := $(notdir $(shell pwd) )
1920BIN := kubectl-stash
2021COMPRESS ?= no
2122
4344# ## These variables should not need tweaking.
4445# ##
4546
46- SRC_DIRS := cmd pkg hack/gendocs # directories which hold app source (not vendored)
47+ SRC_PKGS := cmd pkg
48+ SRC_DIRS := $(SRC_PKGS ) hack/gendocs # directories which hold app source (not vendored)
4749
4850DOCKER_PLATFORMS := linux/amd64 linux/arm linux/arm64
4951BIN_PLATFORMS := $(DOCKER_PLATFORMS ) windows/amd64 darwin/amd64
@@ -52,7 +54,7 @@ BIN_PLATFORMS := $(DOCKER_PLATFORMS) windows/amd64 darwin/amd64
5254OS := $(if $(GOOS ) ,$(GOOS ) ,$(shell go env GOOS) )
5355ARCH := $(if $(GOARCH ) ,$(GOARCH ) ,$(shell go env GOARCH) )
5456
55- GO_VERSION ?= 1.12.10
57+ GO_VERSION ?= 1.12.12
5658BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION ) -stretch
5759
5860OUTBIN = bin/$(OS ) _$(ARCH ) /$(BIN )
6365# Directories that we need created to build/test.
6466BUILD_DIRS := bin/$(OS ) _$(ARCH ) \
6567 .go/bin/$(OS ) _$(ARCH ) \
66- .go/cache
68+ .go/cache \
69+ hack/config \
70+ $(HOME ) /.credentials \
71+ $(HOME ) /.kube \
72+ $(HOME ) /.minikube
6773
6874# If you want to build all binaries, see the 'all-build' rule.
6975# If you want to build all containers, see the 'all-container' rule.
@@ -90,7 +96,7 @@ version:
9096 @echo ::set-output name=commit_timestamp::$(commit_timestamp )
9197
9298gen :
93- ./hack/codegen.sh
99+ @true
94100
95101fmt : $(BUILD_DIRS )
96102 @docker run \
@@ -105,7 +111,10 @@ fmt: $(BUILD_DIRS)
105111 --env HTTP_PROXY=$(HTTP_PROXY ) \
106112 --env HTTPS_PROXY=$(HTTPS_PROXY ) \
107113 $(BUILD_IMAGE ) \
108- ./hack/fmt.sh $(SRC_DIRS )
114+ /bin/bash -c " \
115+ REPO_PKG=$(GO_PKG ) \
116+ ./hack/fmt.sh $(SRC_DIRS ) \
117+ "
109118
110119build : $(OUTBIN )
111120
@@ -165,7 +174,10 @@ $(OUTBIN): .go/$(OUTBIN).stamp
165174 fi
166175 @echo
167176
168- test : $(BUILD_DIRS )
177+ .PHONY : test
178+ test : unit-tests
179+
180+ unit-tests : $(BUILD_DIRS )
169181 @docker run \
170182 -i \
171183 --rm \
@@ -204,16 +216,33 @@ lint: $(BUILD_DIRS)
204216 --env GO111MODULE=on \
205217 --env GOFLAGS=" -mod=vendor" \
206218 $(BUILD_IMAGE ) \
207- golangci-lint run --enable $(ADDTL_LINTERS ) --skip-dirs-use-default --deadline=10m
219+ golangci-lint run --enable $(ADDTL_LINTERS ) --deadline=10m -- skip-files= " generated.*\.go$ \" --skip- dirs-use-default
208220
209221$(BUILD_DIRS ) :
210222 @mkdir -p $@
211223
212224.PHONY : dev
213225dev : gen fmt build
214226
227+ .PHONY : verify
228+ verify : verify-modules verify-gen
229+
230+ .PHONY : verify-modules
231+ verify-modules :
232+ GO111MODULE=on go mod tidy
233+ GO111MODULE=on go mod vendor
234+ @if ! (git diff --exit-code HEAD); then \
235+ echo " go module files are out of date" ; exit 1; \
236+ fi
237+
238+ .PHONY : verify-gen
239+ verify-gen : gen fmt
240+ @if ! (git diff --exit-code HEAD); then \
241+ echo " files are out of date, run make gen fmt" ; exit 1; \
242+ fi
243+
215244.PHONY : ci
216- ci : lint test build # cover
245+ ci : verify lint build unit-tests # cover
217246
218247.PHONY : qa
219248qa :
0 commit comments