-
Notifications
You must be signed in to change notification settings - Fork 11
/
GNUmakefile
86 lines (72 loc) · 2.3 KB
/
GNUmakefile
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
SWEEP?=us-east-1,us-west-2
TEST?=./...
SWEEP_DIR?=./victorops
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
PKG_NAME=victorops
WEBSITE_REPO=github.com/hashicorp/terraform-website
TEST_COUNT?=1
default: build
build: fmtcheck
go install
sweep:
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
go test $(SWEEP_DIR) -v -sweep=$(SWEEP) $(SWEEPARGS) -timeout 60m
test: fmtcheck
go test $(TEST) $(TESTARGS) -short -timeout=120s -parallel=4
testacc: fmtcheck
go test $(TEST) -v -count $(TEST_COUNT) -parallel 20 $(TESTARGS) -timeout 120m
fmt:
@echo "==> Fixing source code with gofmt..."
gofmt -s -w ./$(PKG_NAME)
# Currently required by tf-deploy compile
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
depscheck:
@echo "==> Checking source code with go mod tidy..."
@go mod tidy
@git diff --exit-code -- go.mod go.sum || \
(echo; echo "Unexpected difference in go.mod/go.sum files. Run 'go mod tidy' command or revert any go.mod/go.sum changes and commit."; exit 1)
@echo "==> Checking source code with go mod vendor..."
@go mod vendor
@git diff --compact-summary --exit-code -- vendor || \
(echo; echo "Unexpected difference in vendor/ directory. Run 'go mod vendor' command or revert any go.mod/go.sum/vendor changes and commit."; exit 1)
docscheck:
@tfproviderdocs check
@misspell -error -source text CHANGELOG.md
lint:
@echo "==> Checking source code against linters..."
@golangci-lint run ./$(PKG_NAME)/...
@tfproviderlint \
-c 1 \
-S001 \
-S002 \
-S003 \
-S004 \
-S005 \
-S007 \
-S008 \
-S009 \
-S010 \
-S011 \
-S012 \
-S013 \
-S014 \
-S015 \
-S016 \
-S017 \
-S019 \
./$(PKG_NAME)
tools:
GO111MODULE=on go install github.com/bflad/tfproviderlint/cmd/tfproviderlint
GO111MODULE=on go install github.com/bflad/tfproviderdocs
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
GO111MODULE=on go install github.com/katbyte/terrafmt
test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./$(PKG_NAME)"; \
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)
.PHONY: build sweep test testacc fmt fmtcheck lint tools test-compile depscheck docscheck