2017-06-05 16:59:08 -04:00
|
|
|
TEST?=$$(go list ./... |grep -v 'vendor')
|
|
|
|
|
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
|
2021-03-18 03:30:54 -04:00
|
|
|
PKG_NAME=internal/provider
|
2017-06-05 16:59:08 -04:00
|
|
|
|
|
|
|
|
default: build
|
|
|
|
|
|
|
|
|
|
build: fmtcheck
|
|
|
|
|
go install
|
|
|
|
|
|
2020-12-27 05:02:34 -05:00
|
|
|
setup:
|
2022-07-11 08:55:15 -04:00
|
|
|
go install github.com/katbyte/terrafmt
|
|
|
|
|
go install github.com/client9/misspell/cmd/misspell
|
|
|
|
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint
|
2020-12-27 05:18:22 -05:00
|
|
|
rm -f .git/hooks/commit-msg \
|
|
|
|
|
&& curl --fail -o .git/hooks/commit-msg https://raw.githubusercontent.com/hazcod/semantic-commit-hook/master/commit-msg \
|
|
|
|
|
&& chmod 500 .git/hooks/commit-msg
|
2020-12-27 05:02:34 -05:00
|
|
|
|
|
|
|
|
golangci-lint:
|
2021-05-31 03:11:49 -04:00
|
|
|
@golangci-lint run ./...
|
2020-12-27 05:02:34 -05:00
|
|
|
|
2017-06-06 16:27:01 -04:00
|
|
|
test: fmtcheck
|
2017-06-05 16:59:08 -04:00
|
|
|
go test -i $(TEST) || exit 1
|
|
|
|
|
echo $(TEST) | \
|
|
|
|
|
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
|
|
|
|
|
|
2019-06-01 06:01:42 -04:00
|
|
|
testacc_setup: fmtcheck
|
|
|
|
|
@sh -c "'$(CURDIR)/scripts/testacc_setup.sh'"
|
|
|
|
|
|
2017-06-05 16:59:08 -04:00
|
|
|
testacc: fmtcheck
|
2019-06-01 06:01:42 -04:00
|
|
|
@sh -c "'$(CURDIR)/scripts/testacc_full.sh'"
|
|
|
|
|
|
|
|
|
|
testacc_cleanup: fmtcheck
|
|
|
|
|
@sh -c "'$(CURDIR)/scripts/testacc_cleanup.sh'"
|
2017-06-05 16:59:08 -04:00
|
|
|
|
2018-07-03 11:30:53 -04:00
|
|
|
compile: fmtcheck
|
2021-04-21 08:12:36 -04:00
|
|
|
@sh -c "curl -sL https://git.io/goreleaser | bash -s -- --rm-dist --skip-publish --snapshot --skip-sign"
|
2018-07-03 11:30:53 -04:00
|
|
|
|
2017-06-05 16:59:08 -04:00
|
|
|
vet:
|
|
|
|
|
@echo "go vet ."
|
|
|
|
|
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
|
|
|
|
|
echo ""; \
|
|
|
|
|
echo "Vet found suspicious constructs. Please check the reported constructs"; \
|
|
|
|
|
echo "and fix them if necessary before submitting the code for review."; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
fmt:
|
2020-12-02 07:04:53 -05:00
|
|
|
gofmt -s -w $(GOFMT_FILES)
|
2017-06-05 16:59:08 -04:00
|
|
|
|
|
|
|
|
fmtcheck:
|
|
|
|
|
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
|
|
|
|
|
|
|
|
|
|
errcheck:
|
|
|
|
|
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
|
|
|
|
|
|
|
|
|
|
|
2017-06-30 04:15:38 -04:00
|
|
|
test-compile:
|
|
|
|
|
@if [ "$(TEST)" = "./..." ]; then \
|
|
|
|
|
echo "ERROR: Set TEST to a specific package. For example,"; \
|
2018-04-27 11:57:13 -04:00
|
|
|
echo " make test-compile TEST=./$(PKG_NAME)"; \
|
2017-06-30 04:15:38 -04:00
|
|
|
exit 1; \
|
|
|
|
|
fi
|
|
|
|
|
go test -c $(TEST) $(TESTARGS)
|
|
|
|
|
|
2021-05-21 08:30:56 -04:00
|
|
|
website-generation:
|
|
|
|
|
go generate
|
|
|
|
|
|
2020-12-27 05:02:34 -05:00
|
|
|
website-link-check:
|
|
|
|
|
@scripts/markdown-link-check.sh
|
|
|
|
|
|
|
|
|
|
website-lint:
|
|
|
|
|
@echo "==> Checking website against linters..."
|
2021-05-21 08:30:56 -04:00
|
|
|
@misspell -error -source=text docs/ || (echo; \
|
2020-12-27 05:02:34 -05:00
|
|
|
echo "Unexpected mispelling found in website files."; \
|
|
|
|
|
echo "To automatically fix the misspelling, run 'make website-lint-fix' and commit the changes."; \
|
|
|
|
|
exit 1)
|
2021-06-21 03:24:02 -04:00
|
|
|
@docker run --rm -v $(PWD):/markdown 06kellyjac/markdownlint-cli docs/ || (echo; \
|
2020-12-27 05:02:34 -05:00
|
|
|
echo "Unexpected issues found in website Markdown files."; \
|
|
|
|
|
echo "To apply any automatic fixes, run 'make website-lint-fix' and commit the changes."; \
|
|
|
|
|
exit 1)
|
2021-05-21 08:30:56 -04:00
|
|
|
@terrafmt diff ./docs --check --pattern '*.md' --quiet || (echo; \
|
2020-12-27 05:02:34 -05:00
|
|
|
echo "Unexpected differences in website HCL formatting."; \
|
2021-05-21 08:30:56 -04:00
|
|
|
echo "To see the full differences, run: terrafmt diff ./docs --pattern '*.md'"; \
|
2020-12-27 05:02:34 -05:00
|
|
|
echo "To automatically fix the formatting, run 'make website-lint-fix' and commit the changes."; \
|
|
|
|
|
exit 1)
|
|
|
|
|
|
|
|
|
|
website-lint-fix:
|
|
|
|
|
@echo "==> Applying automatic website linter fixes..."
|
2021-05-21 08:30:56 -04:00
|
|
|
@misspell -w -source=text docs/
|
2021-06-21 03:24:02 -04:00
|
|
|
@docker run --rm -v $(PWD):/markdown 06kellyjac/markdownlint-cli --fix docs/
|
2021-05-21 08:30:56 -04:00
|
|
|
@terrafmt fmt ./docs --pattern '*.md'
|
2020-12-27 05:02:34 -05:00
|
|
|
|
|
|
|
|
.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile website-link-check website-lint website-lint-fix
|
2017-06-05 16:59:08 -04:00
|
|
|
|
2022-07-14 09:36:05 -04:00
|
|
|
chlog-%:
|
|
|
|
|
@echo "Generating CHANGELOG.md"
|
|
|
|
|
git-chglog --next-tag $* -o CHANGELOG.md
|
|
|
|
|
@echo "Version updated to $*!"
|
|
|
|
|
@echo
|
|
|
|
|
@echo "Review the changes made by this script then execute the following:"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
replace-occurences-%:
|
|
|
|
|
@echo "Replace occurences of old version strings..."
|
|
|
|
|
sed -i '' "s/$(shell (svu --strip-prefix current))/$*/g" README.md docs/index.md examples/provider/provider-tf12.tf examples/provider/provider-tf13.tf
|
|
|
|
|
|
|
|
|
|
release-%:
|
|
|
|
|
@echo "Review the changes made by this script then execute the following:"
|
|
|
|
|
@${MAKE} website-generation
|
|
|
|
|
@echo "Review the changes made by this script then execute the following:"
|
|
|
|
|
@echo
|
|
|
|
|
@echo "git add CHANGELOG.md README.md docs/index.md examples/provider/provider-tf12.tf examples/provider/provider-tf13.tf && git commit -m 'Prepare release $*' && git tag -m 'Release $*' ${TAG_PREFIX}$*"
|
|
|
|
|
@echo
|
|
|
|
|
@echo "Finally, push the changes:"
|
|
|
|
|
@echo
|
|
|
|
|
@echo "git push; git push origin ${TAG_PREFIX}$*"
|
|
|
|
|
|
|
|
|
|
patch:
|
|
|
|
|
@${MAKE} chlog-$(shell (svu patch))
|
|
|
|
|
@${MAKE} replace-occurences-$(shell (svu --strip-prefix patch))
|
|
|
|
|
@${MAKE} release-$(shell (svu patch))
|
|
|
|
|
|
|
|
|
|
minor:
|
|
|
|
|
@${MAKE} chlog-$(shell (svu minor))
|
|
|
|
|
@${MAKE} replace-occurences-$(shell (svu --strip-prefix minor))
|
|
|
|
|
@${MAKE} release-$(shell (svu patch))
|
|
|
|
|
|
|
|
|
|
major:
|
|
|
|
|
@${MAKE} chlog-$(shell (svu major))
|
|
|
|
|
@${MAKE} replace-occurences-$(shell (svu --strip-prefix major))
|
|
|
|
|
@${MAKE} release-$(shell (svu patch))
|