forked from elastic/terraform-provider-elasticstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
124 lines (78 loc) · 3.29 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
.DEFAULT_GOAL = help
SHELL := /bin/bash
VERSION ?= 0.3.3
NAME = elasticstack
BINARY = terraform-provider-${NAME}
MARCH = "$$(go env GOOS)_$$(go env GOARCH)"
ACCTEST_PARALLELISM ?= 10
ACCTEST_TIMEOUT = 120m
ACCTEST_COUNT = 1
TEST ?= ./...
export GOBIN = $(shell pwd)/bin
$(GOBIN): ## create bin/ in the current directory
mkdir -p $(GOBIN)
.PHONY: build
build: lint ## build the terraform provider
go build -o ${BINARY}
.PHONY: testacc
testacc: lint ## Run acceptance tests
TF_ACC=1 go test -v ./... -count $(ACCTEST_COUNT) -parallel $(ACCTEST_PARALLELISM) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT)
.PHONY: test
test: lint ## Run unit tests
go test -v $(TEST) $(TESTARGS) -timeout=5m -parallel=4
.PHONY: docs-generate
docs-generate: tools ## Generate documentation for the provider
@ $(GOBIN)/tfplugindocs
.PHONY: gen
gen: docs-generate ## Generate the code and documentation
@ go generate ./...
.PHONY: clean
clean: ## Remove built binary
rm -f ${BINARY}
.PHONY: install
install: build ## Install built provider into the local terraform cache
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/elastic/${NAME}/${VERSION}/${MARCH}
mv ${BINARY} ~/.terraform.d/plugins/registry.terraform.io/elastic/${NAME}/${VERSION}/${MARCH}
.PHONY: tools
tools: $(GOBIN) ## Install useful tools for linting, docs generation and development
@ cd tools && go install github.com/client9/misspell/cmd/misspell
@ cd tools && go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
@ cd tools && go install github.com/golangci/golangci-lint/cmd/golangci-lint
@ cd tools && go install github.com/goreleaser/goreleaser
.PHONY: misspell
misspell:
@ $(GOBIN)/misspell -error -source go ./internal/
@ $(GOBIN)/misspell -error -source text ./templates/
.PHONY: golangci-lint
golangci-lint:
@ $(GOBIN)/golangci-lint run --max-same-issues=0 --timeout=300s $(GOLANGCIFLAGS) ./internal/...
.PHONY: lint
lint: setup misspell golangci-lint ## Run lints to check the spelling and common go patterns
.PHONY: setup
setup: tools ## Setup the dev environment
.PHONY: release-snapshot
release-snapshot: tools ## Make local-only test release to see if it works using "release" command
@ $(GOBIN)/goreleaser release --snapshot --rm-dist
.PHONY: release-no-publish
release-no-publish: tools check-sign-release ## Make a release without publishing artifacts
@ $(GOBIN)/goreleaser release --skip-publish --skip-announce --skip-validate
.PHONY: release
release: tools check-sign-release check-publish-release ## Build, sign, and upload your release
@ $(GOBIN)/goreleaser release --rm-dist
.PHONY: check-sign-release
check-sign-release:
ifndef GPG_FINGERPRINT
$(error GPG_FINGERPRINT is undefined, but required for signing the release)
endif
.PHONY: check-publish-release
check-publish-release:
ifndef GITHUB_TOKEN
$(error GITHUB_TOKEN is undefined, but required to make build and upload the released artifacts)
endif
.PHONY: release-notes
release-notes: ## greps UNRELEASED notes from the CHANGELOG
@ awk '/## \[Unreleased\]/{flag=1;next}/## \[.*\] - /{flag=0}flag' CHANGELOG.md
.PHONY: help
help: ## this help
@ awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m\t%s\n", $$1, $$2 }' $(MAKEFILE_LIST) | column -s$$'\t' -t
include .ci/Makefile.ci