-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (69 loc) · 2.46 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
# Project variables
PROJECT_NAME := terraform-provider-xelon
# Build variables
.DEFAULT_GOAL = test
BUILD_DIR := build
TOOLS_DIR := $(shell pwd)/tools
TOOLS_BIN_DIR := ${TOOLS_DIR}/bin
DEV_GOARCH := $(shell go env GOARCH)
DEV_GOOS := $(shell go env GOOS)
EXE =
ifeq ($(DEV_GOOS),windows)
EXE = .exe
endif
## tools: Install required tooling.
.PHONY: tools
tools:
@echo "==> Installing required tooling..."
@cd ${TOOLS_DIR} && GOBIN=${TOOLS_BIN_DIR} go install github.com/git-chglog/git-chglog/cmd/git-chglog
@cd ${TOOLS_DIR} && GOBIN=${TOOLS_BIN_DIR} go install github.com/golangci/golangci-lint/cmd/golangci-lint
@cd ${TOOLS_DIR} && GOBIN=${TOOLS_BIN_DIR} go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
## clean: Delete the build directory.
.PHONY: clean
clean:
@echo "==> Removing '$(BUILD_DIR)' directory..."
@rm -rf $(BUILD_DIR)
## lint: Lint code with golangci-lint.
.PHONY: lint
lint:
@echo "==> Linting code with 'golangci-lint'..."
@${TOOLS_BIN_DIR}/golangci-lint run
## test: Run all unit tests.
.PHONY: test
test:
@echo "==> Running unit tests..."
@mkdir -p $(BUILD_DIR)
@go test -count=1 -v -cover -coverprofile=$(BUILD_DIR)/coverage.out -parallel=4 ./...
## testacc: Run all acceptance tests.
.PHONY: testacc
testacc:
@echo "==> Running all acceptance tests..."
@mkdir -p $(BUILD_DIR)
@TF_ACC=1 go test -count=1 -v -cover -coverprofile=$(BUILD_DIR)/coverage-with-acceptance.out -parallel=4 -timeout 120m ./...
## sweep: Run sweepers to cleanup leftover infrastructure after acceptance tests.
.PHONY: sweep
sweep:
@echo "==> Running sweepers to cleanup leftover infrastructure..."
@echo " WARNING: This will destroy infrastructure. Use only in development accounts."
@echo ""
@go test -count=1 -v ./internal/xelon -sweep=vdcnew
## build: Build provider for default local system's operating system and architecture.
.PHONY: build
build:
@echo "==> Building provider..."
@echo " running go build for GOOS=$(DEV_GOOS) GOARCH=$(DEV_GOARCH)"
@go build -o $(BUILD_DIR)/$(PROJECT_NAME)$(EXE) main.go
## docs: Generate and validate provider documentation with tfplugindocs.
.PHONY: docs
docs:
@echo "===> Generating and validate provider documentation..."
@rm -f docs/data-sources/*.md
@rm -f docs/resources/*.md
@rm -f docs/index.md
@${TOOLS_BIN_DIR}/tfplugindocs generate
@${TOOLS_BIN_DIR}/tfplugindocs validate
help: Makefile
@echo "Usage: make <command>"
@echo ""
@echo "Commands:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'