generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 47
/
GNUmakefile
83 lines (70 loc) · 3.24 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
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
INSTALL_PATH=~/.local/share/terraform/plugins/localhost/providers/hcp/0.0.1/linux_$(GOARCH)
BUILD_ALL_PATH=${PWD}/bin
TEST?=./internal/...
GO_LINT ?= golangci-lint
GO_LINT_CONFIG_PATH ?= ./golangci-config.yml
TIMEOUT?=360m
ifeq ($(GOOS), darwin)
INSTALL_PATH=~/Library/Application\ Support/io.terraform/plugins/localhost/providers/hcp/0.0.1/darwin_$(GOARCH)
endif
ifeq ($(GOOS), "windows")
INSTALL_PATH=%APPDATA%/HashiCorp/Terraform/plugins/localhost/providers/hcp/0.0.1/windows_$(GOARCH)
endif
default: dev
dev:
mkdir -p $(INSTALL_PATH)
go build -o $(INSTALL_PATH)/terraform-provider-hcp main.go
all:
mkdir -p $(BUILD_ALL_PATH)
GOOS=darwin go build -o $(BUILD_ALL_PATH)/terraform-provider-hcp_darwin-amd64 main.go
GOOS=windows go build -o $(BUILD_ALL_PATH)/terraform-provider-hcp_windows-amd64 main.go
GOOS=linux go build -o $(BUILD_ALL_PATH)/terraform-provider-hcp_linux-amd64 main.go
fmt:
@echo "==> Fixing source code with gofmt..."
gofmt -s -w ./internal
fmtcheck:
@./scripts/gofmtcheck.sh
$(GO_LINT) run --config $(GO_LINT_CONFIG_PATH) $(GO_LINT_ARGS)
test: fmtcheck
go test $(TEST) $(TESTARGS) -timeout=5m -parallel=4
test-ci: fmtcheck
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
testacc: fmtcheck
@if [ "$(TESTARGS)" = "-run=TestAccXXX" ]; then \
echo ""; \
echo "Error: Skipping example acceptance testing pattern. Update TESTARGS to match the test naming in the relevant *_test.go file."; \
echo ""; \
echo "For example if updating resource_hvn.go, use the test names in resource_hvn_test.go starting with TestAcc:"; \
echo "make testacc TESTARGS='-run=TestAccHvn'"; \
echo ""; \
echo "See the contributing guide for more information: https://github.com/hashicorp/terraform-provider-hcp/blob/main/contributing/writing-tests.md"; \
exit 1; \
fi
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout $(TIMEOUT) -parallel=10
testacc-ci: fmtcheck
@if [ "$(TESTARGS)" = "-run=TestAccXXX" ]; then \
echo ""; \
echo "Error: Skipping example acceptance testing pattern. Update TESTARGS to match the test naming in the relevant *_test.go file."; \
echo ""; \
echo "For example if updating resource_hvn.go, use the test names in resource_hvn_test.go starting with TestAcc:"; \
echo "make testacc TESTARGS='-run=TestAccHvn'"; \
echo ""; \
echo "See the contributing guide for more information: https://github.com/hashicorp/terraform-provider-hcp/blob/main/contributing/writing-tests.md"; \
exit 1; \
fi
TF_ACC=1 go test -short -coverprofile=coverage-e2e.out $(TEST) -v $(TESTARGS) -timeout $(TIMEOUT) -parallel=10
go tool cover -html=coverage-e2e.out -o coverage-e2e.html
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)
gencheck:
@echo "==> Checking generated source code..."
go generate
@git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate' command and commit."; exit 1)
.PHONY: dev all fmt fmtcheck test test-ci testacc depscheck gencheck