forked from huaweicloud/packer-plugin-huaweicloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (40 loc) · 1.5 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
BINARY = packer-builder-huaweicloud-ecs
PLUGIN_DIR = ~/.packer.d/plugins
PLUGIN_FILE = ${PLUGIN_DIR}/${BINARY}
GOBIN = $(shell go env GOPATH)/bin
BINARY_FILE = ${GOBIN}/${BINARY}
GORELEASER_VER = 0.110.0
GOLANGCI_LINT_VER = 1.17.1
.PHONY: default
default: build test install
.PHONY: build
build:
go install
.PHONY: install
install: build
mkdir -p ${PLUGIN_DIR}
@if [ -f ${PLUGIN_FILE} ]; then\
rm ${PLUGIN_FILE};\
fi
ln -s ${BINARY_FILE} ${PLUGIN_FILE}
.PHONY: test
test:
go test -v . ./huaweicloud
.PHONY: lint
lint:
golint . ./huaweicloud
golangci-lint run --skip-dirs=test,vendor --fast ./...
.PHONY: clean
clean:
rm -rf ${BINARY_FILE} ${PLUGIN_FILE}
.PHONY: setup-tools
setup-tools:
# we want that `go get` install utilities, but in the module mode its
# behaviour is different; actually, `go get` would rather modify the
# local `go.mod`, so let's disable modules here.
GO111MODULE=off go get -u golang.org/x/lint/golint
GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports
# goreleaser and golangci-lint take pretty long to build
# as an optimization, let's just download the binaries
curl -sL "https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VER}/goreleaser_Linux_x86_64.tar.gz" | tar -xzf - -C ${GOBIN} goreleaser
curl -sL "https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VER}/golangci-lint-${GOLANGCI_LINT_VER}-linux-amd64.tar.gz" | tar -xzf - -C ${GOBIN} --strip-components=1 "golangci-lint-${GOLANGCI_LINT_VER}-linux-amd64/golangci-lint"