forked from Snowflake-Labs/terraform-provider-snowflake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
130 lines (105 loc) · 4.08 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
125
126
127
128
129
130
SHA=$(shell git rev-parse --short HEAD)
VERSION=$(shell cat VERSION)
export DIRTY=$(shell if `git diff-index --quiet HEAD --`; then echo false; else echo true; fi)
LDFLAGS=-ldflags "-w -s -X github.com/chanzuckerberg/go-misc/ver.GitSha=${SHA} -X github.com/chanzuckerberg/go-misc/ver.Version=${VERSION} -X github.com/chanzuckerberg/go-misc/ver.Dirty=${DIRTY}"
export BASE_BINARY_NAME=terraform-provider-snowflake_v$(VERSION)
export GO111MODULE=on
export TF_ACC_TERRAFORM_VERSION=0.12.29
export SKIP_EXTERNAL_TABLE_TESTS=true
go_test ?= -
ifeq (, $(shell which gotest))
go_test=go test
else
go_test=gotest
endif
all: test docs install
.PHONY: all
setup: ## setup development dependencies
curl -sfL https://raw.githubusercontent.com/chanzuckerberg/bff/main/download.sh | sh
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh
bash .download-tfproviderlint.sh
go get golang.org/x/tools/cmd/goimports
.PHONY: setup
lint: fmt ## run the fast go linters
./bin/reviewdog -conf .reviewdog.yml -diff "git diff main"
.PHONY: lint
lint-ci: ## run the fast go linters
./bin/reviewdog -conf .reviewdog.yml -reporter=github-pr-review -tee
.PHONY: lint-ci
lint-all: fmt ## run the fast go linters
./bin/reviewdog -conf .reviewdog.yml -filter-mode nofilter
.PHONY: lint-all
lint-missing-acceptance-tests:
@for r in `ls pkg/resources/ | grep -v list_expansion | grep -v privileges | grep -v grant_helpers | grep -v test | xargs -I{} basename {} .go`; do \
if [ ! -f pkg/resources/"$$r"_acceptance_test.go ]; then \
echo $$r; \
fi; \
done
.PHONY: lint-missing-acceptance-tests
check-release-prereqs:
ifndef KEYBASE_KEY_ID
$(error KEYBASE_KEY_ID is undefined)
endif
.PHONY: check-release-prereqs
release: setup check-release-prereqs ## run a release
./bin/bff bump
git push
goreleaser release --debug --rm-dist
.PHONY: release
release-prerelease: check-release-prereqs build ## release to github as a 'pre-release'
version=`./$(BASE_BINARY_NAME) -version`; \
git tag v"$$version"; \
git push
git push --tags
goreleaser release -f .goreleaser.prerelease.yml --debug --rm-dist
.PHONY: release-prerelease
release-snapshot: ## run a release
goreleaser release --snapshot
.PHONY: release-snapshot
build: ## build the binary
go build ${LDFLAGS} -o $(BASE_BINARY_NAME) .
.PHONY: build
coverage: ## run the go coverage tool, reading file coverage.out
go tool cover -html=coverage.txt
.PHONY: coverage
test: fmt deps ## run the tests
CGO_ENABLED=1 $(go_test) -race -coverprofile=coverage.txt -covermode=atomic $(TESTARGS) ./...
.PHONY: test
test-acceptance: fmt deps ## runs all tests, including the acceptance tests which create and destroys real resources
SKIP_MANAGED_ACCOUNT_TEST=1 TF_ACC=1 $(go_test) -v -coverprofile=coverage.txt -covermode=atomic $(TESTARGS) ./...
.PHONY: test-acceptance
deps:
go mod tidy
.PHONY: deps
install: ## install the terraform-provider-snowflake binary in $GOPATH/bin
go install ${LDFLAGS} .
.PHONY: install
install-tf: build ## installs plugin where terraform can find it
mkdir -p $(HOME)/.terraform.d/plugins
cp ./$(BASE_BINARY_NAME) $(HOME)/.terraform.d/plugins/$(BASE_BINARY_NAME)
.PHONY: install-tf
uninstall-tf: build ## uninstalls plugin from where terraform can find it
rm $(HOME)/.terraform.d/plugins/$(BASE_BINARY_NAME) 2>/dev/null
.PHONY: install-tf
help: ## display help for this makefile
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help
clean: ## clean the repo
rm terraform-provider-snowflake 2>/dev/null || true
go clean
rm -rf dist
.PHONY: clean
docs:
SNOWFLAKE_USER= SNOWFLAKE_ACCOUNT= go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
.PHONY: docs
check-docs: docs ## check that docs have been generated
git diff --exit-code -- docs
.PHONY: check-docs
check-mod:
go mod tidy
git diff --exit-code -- go.mod go.sum
.PHONY: check-mod
fmt:
goimports -w -d $$(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./dist/*")
.PHONY: fmt