forked from integrations/terraform-provider-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGNUmakefile
More file actions
87 lines (70 loc) · 2.8 KB
/
GNUmakefile
File metadata and controls
87 lines (70 loc) · 2.8 KB
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
SWEEP?=repositories,teams
PKG_NAME=github
TEST?=./$(PKG_NAME)/...
WEBSITE_REPO=github.com/hashicorp/terraform-website
COVERAGEARGS?=-race -coverprofile=coverage.txt -covermode=atomic
# VARIABLE REFERENCE:
#
# Test-specific variables:
# T=<pattern> - Test name pattern (e.g., TestAccGithubRepository)
# COV=true - Enable coverage
#
#
# Examples:
# make test T=TestMigrate # Run only schema migration unit tests
# make test COV=true # Run all unit tests with coverage
# make testacc T=TestAccGithubRepositories\$$ COV=true # Run only acceptance tests for a specific Test name with coverage
ifneq ($(origin T), undefined)
RUNARGS = -run='$(T)'
endif
ifneq ($(origin COV), undefined)
RUNARGS += $(COVERAGEARGS)
endif
default: build
tools:
go install github.com/client9/misspell/cmd/misspell@v0.3.4
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0
build: lintcheck
CGO_ENABLED=0 go build -ldflags="-s -w" ./...
fmt:
@echo "==> Fixing source code formatting..."
golangci-lint fmt ./...
lint:
@echo "==> Checking source code against linters and fixing..."
golangci-lint run --fix ./...
lintcheck:
@echo "==> Checking source code against linters..."
golangci-lint run ./...
test:
@branch=$$(git rev-parse --abbrev-ref HEAD); \
printf "==> Running unit tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿"
CGO_ENABLED=0 go test $(TEST) \
-timeout=30s \
-parallel=4 \
-v \
-skip '^TestAcc' \
$(RUNARGS) $(TESTARGS) \
-count 1;
testacc:
@branch=$$(git rev-parse --abbrev-ref HEAD); \
printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿"
TF_ACC=1 CGO_ENABLED=0 go test $(TEST) -v -run '^TestAcc' $(RUNARGS) $(TESTARGS) -timeout 120m -count=1
sweep:
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
go test $(TEST) -v -sweep=$(SWEEP) $(SWEEPARGS)
website:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
website-lint:
@echo "==> Checking website against linters..."
@misspell -error -source=text website/
website-test:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
.PHONY: build test testacc fmt lint lintcheck tools website website-lint website-test sweep