forked from linode/terraform-provider-linode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (87 loc) · 2.65 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
COUNT?=1
PARALLEL?=10
PKG_NAME=linode/...
TIMEOUT?=240m
RUN_LONG_TESTS?=false
SWEEP?="tf_test,tf-test"
TEST_TAGS="integration"
MARKDOWNLINT_IMG := 06kellyjac/markdownlint-cli
MARKDOWNLINT_TAG := 0.28.1
IP_ENV_FILE := /tmp/linode/ip_vars.env
.PHONY: default
default: build
.PHONY: build
build: format
# trying to copy .goreleaser.yaml
go build -a -ldflags '-s -extldflags "-static"'
.PHONY: clean
clean:
rm -f terraform-provider-linode
.PHONY: lint
lint:
# remove two disabled linters when their errors are addressed
golangci-lint run \
--disable gosimple \
--disable staticcheck \
--timeout 15m0s
tfproviderlint \
-AT001=false \
-AT004=false \
-S006=false \
-R018=false \
-R019=false \
./...
.PHONY: deps
deps:
go generate -tags tools tools/tools.go
.PHONY: format
format:
gofumpt -l -w .
.PHONY: fmt-check err-check imports-check vet
fmt-check:
golangci-lint run --disable-all --enable gofumpt ./...
err-check:
golangci-lint run --disable-all -E errcheck ./...
imports-check:
golangci-lint run --disable-all --enable goimports ./...
vet:
golangci-lint run --disable-all --enable govet ./...
.PHONY: test
test: fmt-check smoke-test unit-test int-test
.PHONY: unit-test
unit-test: fmt-check
go test -v --tags=unit ./$(PKG_NAME)
.PHONY: int-test
int-test: fmt-check generate-ip-env-fw-e2e include-env
TF_ACC=1 \
LINODE_API_VERSION="v4beta" \
RUN_LONG_TESTS=$(RUN_LONG_TESTS) \
TF_VAR_ipv4_addr=${PUBLIC_IPV4} \
TF_VAR_ipv6_addr=${PUBLIC_IPV6} \
go test --tags="$(TEST_TAGS)" -v ./$(PKG_NAME) -count $(COUNT) -timeout $(TIMEOUT) -ldflags="-X=github.com/linode/terraform-provider-linode/v2/version.ProviderVersion=acc" -parallel=$(PARALLEL) $(ARGS)
.PHONY: include-env
include-env: $(IP_ENV_FILE)
-include $(IP_ENV_FILE)
generate-ip-env-fw-e2e: $(IP_ENV_FILE)
$(IP_ENV_FILE):
# Generate env file for E2E cloud firewall
. ./e2e_scripts/cloud_security_scripts/cloud_e2e_firewall/terraform-provider-linode/generate_ip_env_fw_e2e.sh || touch $(IP_ENV_FILE)
.PHONY: smoke-test
smoke-test: fmt-check
TF_ACC=1 \
LINODE_API_VERSION="v4beta" \
RUN_LONG_TESTS=$(RUN_LONG_TESTS) \
go test -v -run smoke ./linode/... -count $(COUNT) -timeout $(TIMEOUT) -parallel=$(PARALLEL) -ldflags="-X=github.com/linode/terraform-provider-linode/v2/version.ProviderVersion=acc"
.PHONY: docs-check
docs-check:
# markdown linter for the documents
docker run --rm \
-v $$(pwd):/markdown:ro \
$(MARKDOWNLINT_IMG):$(MARKDOWNLINT_TAG) \
--config .markdownlint.yml \
docs
.PHONY: sweep
sweep:
# sweep cleans the test infra from your account
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
go test -v ./$(PKG_NAME) -sweep=$(SWEEP) $(ARGS)