Skip to content

Commit c1ea4c5

Browse files
committed
chore: update makefile
Updates the `GNUmakefile` to: - Support HCL formatting in `docs/` and `examples/. - Remove unneeded options. Signed-off-by: Ryan Johnson <[email protected]>
1 parent be19081 commit c1ea4c5

File tree

1 file changed

+16
-48
lines changed

1 file changed

+16
-48
lines changed

GNUmakefile

+16-48
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
TEST?=$$(go list ./... |grep -v 'vendor')
2-
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
3-
WEBSITE_REPO=github.com/hashicorp/terraform-website
4-
PKG_NAME=vmc
1+
TEST ?= $(shell go list ./... | grep -v 'vendor')
2+
GOFMT_FILES ?= $(shell find . -name '*.go' | grep -v vendor)
3+
PKG_NAME = vmc
54

65
default: build
76

@@ -15,71 +14,40 @@ init:
1514
debug:
1615
go build -gcflags="all=-N -l"
1716

18-
plan: init
19-
terraform plan
20-
21-
apply: init
22-
terraform apply
23-
2417
test: fmtcheck
2518
go test $(TEST) || exit 1
26-
echo $(TEST) | \
27-
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
19+
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
2820

2921
testacc:
3022
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 240m
3123

3224
debugacc: fmtcheck
33-
TF_ACC=1 dlv test $(TEST) -- -test.v $(TESTARGS)
25+
TF_ACC=1 dlv test -o /dev/null $(TEST) -- -test.v $(TESTARGS)
3426

3527
vet:
3628
@echo "go vet ."
37-
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
38-
echo ""; \
39-
echo "Vet found suspicious constructs. Please check the reported constructs"; \
40-
echo "and fix them if necessary before submitting the code for review."; \
41-
exit 1; \
42-
fi
29+
@go vet $(shell go list ./... | grep -v vendor/) || { echo ""; echo "Vet found suspicious constructs. Please fix them before submitting your code."; exit 1; }
4330

4431
fmt:
4532
gofmt -w -s $(GOFMT_FILES)
4633

4734
fmtcheck:
48-
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
35+
@$(CURDIR)/scripts/gofmtcheck.sh
4936

5037
test-compile:
51-
@if [ "$(TEST)" = "./..." ]; then \
52-
echo "ERROR: Set TEST to a specific package. For example,"; \
53-
echo " make test-compile TEST=./$(PKG_NAME)"; \
54-
exit 1; \
55-
fi
38+
@if [ "$(TEST)" = "./..." ]; then echo "ERROR: Set TEST to a specific package. For example,"; echo " make test-compile TEST=./$(PKG_NAME)"; exit 1; fi
5639
go test -c $(TEST) $(TESTARGS)
5740

58-
lint:
59-
@echo "==> Checking source code against linters..."
60-
@golangci-lint --disable errcheck run ./$(PKG_NAME)/...
61-
6241
tools:
63-
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
6442
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
43+
GO111MODULE=on go install -mod=mod github.com/katbyte/terrafmt
6544

66-
website:
67-
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
68-
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
69-
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
70-
endif
71-
echo $(MAKE)
72-
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
73-
74-
website-test:
75-
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
76-
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
77-
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
78-
endif
79-
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
45+
docs-hcl-lint:
46+
@echo "==> Checking HCL formatting..."
47+
@terrafmt diff ./docs --check --pattern '*.md' --quiet || (echo; echo "Unexpected HCL differences. Run 'make docs-hcl-fix'."; exit 1)
8048

81-
website-lint:
82-
@echo "==> Checking website against linters..."
83-
@misspell -error -source=text website/
49+
docs-hcl-fix:
50+
@echo "==> Applying HCL formatting..."
51+
@terrafmt fmt ./docs --pattern '*.md'
8452

85-
.PHONY: build init plan apply test testacc debugacc fmt fmtcheck vet lint tools test-compile website website-lint website-test test-compile
53+
.PHONY: build init test testacc debugacc fmt fmtcheck vet tools test-compile docs-hcl-lint docs-hcl-fix

0 commit comments

Comments
 (0)