generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
75 lines (60 loc) · 1.84 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
NAME=linode
BINARY=packer-plugin-${NAME}
PLUGIN_FQN="$(shell grep -E '^module' <go.mod | sed -E 's/module *//')"
COUNT?=1
TEST?=$(shell go list ./...)
HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/packer-plugin-sdk | cut -d " " -f2)
PACKER_SDC_REPO ?= github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc
.DEFAULT_GOAL = dev
# install is an alias of dev
.PHONY: install
install: dev
.PHONY: dev
dev:
@go build -ldflags="-X '${PLUGIN_FQN}/version.VersionPrerelease=dev'" -o '${BINARY}'
packer plugins install --path ${BINARY} "$(shell echo "${PLUGIN_FQN}" | sed 's/packer-plugin-//')"
.PHONY: build
build: fmtcheck
@go build -o ${BINARY}
.PHONY: test
test: fmtcheck acctest
.PHONY: install-packer-sdc
install-packer-sdc: ## Install packer sofware development command
@go install ${PACKER_SDC_REPO}@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}
.PHONY: plugin-check
plugin-check: install-packer-sdc build
@packer-sdc plugin-check ${BINARY}
.PHONY: unit-test
unit-test: dev
@go test -race -count $(COUNT) -v $(TEST) -timeout=10m
# int-test is an alias of acctest
.PHONY: int-test
int-test: acctest
.PHONY: acctest
acctest: dev
@PACKER_ACC=1 go test -race -count $(COUNT) -v $(TEST) -timeout=100m
.PHONY: generate
generate: install-packer-sdc
@go generate ./...
@rm -rf .docs
@packer-sdc renderdocs -src "docs" -partials docs-partials/ -dst ".docs/"
@./.web-docs/scripts/compile-to-webdocs.sh "." ".docs" ".web-docs" "linode"
@rm -r ".docs"
.PHONY: fmtcheck
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
.PHONY: lint
lint: fmtcheck
@golangci-lint run
.PHONY: format
format:
@gofumpt -w .
.PHONY: deps
deps: install-packer-sdc
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install mvdan.cc/gofumpt@latest
.PHONY: clean
clean:
@rm -rf .docs
@rm -rf ./packer-plugin-linode
@rm -rf ./docs-partials