forked from splunk/terraform-provider-scp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
93 lines (75 loc) · 2.38 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
86
87
88
89
90
91
92
93
SHELL = /bin/bash
OPENAPI_JSON_URL=https://admin.splunk.com/service/info/specs/v2/openapi.json
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
OS=$(shell uname | tr A-Z a-z)
ARCH=$(shell uname -m)
ifeq ($(ARCH), x86_64)
ARCH=amd64
endif
####################################
# Building binary
####################################
vendor:
go mod vendor
generate: vendor oapi-codegen
# generate the openapi related code
$(OAPI_CODEGEN) --generate types,client --package v2 $(OPENAPI_JSON_URL) > acs/v2/api.gen.go
# generate the mocks for api.ClientInterface
$(MOCKERY) --dir acs/v2 --name ClientInterface --output acs/v2/mocks
default: build
fmt:
go fmt ./...
@terraform fmt -recursive
build:
go build -o bin/terraform-provider-scp .
###################################
# Testing commands
###################################
#run unit tests
test: go-junit-report
go test -short -covermode=atomic -coverprofile=./coverage.txt ./... -v 2>&1 | tee ./test.txt && ./scripts/exclude-from-unit-test.sh
cat test.txt | $(GO_JUNIT_REPORT) > ./report.xml
go tool cover -func=./coverage.txt
#run acceptance tests
testacc:
TF_ACC=1 go test -run "^TestAcc" ./... -v
###################################
# Install dependency
###################################
# find or download oapi-codegen
# See https://pkg.go.dev/cmd/go#hdr-Compile_and_install_packages_and_dependencies, go doesn't use `go get` to install packages anymore.
oapi-codegen:
ifneq (0, $(shell command -v oapi-codegen ; echo $$?))
@ go install github.com/deepmap/oapi-codegen/cmd/[email protected]
OAPI_CODEGEN=$(GOBIN)/oapi-codegen
else
OAPI_CODEGEN=$(shell which oapi-codegen)
endif
# find or download go-junit-report
go-junit-report:
ifneq (0, $(shell command -v go-junit-report ; echo $$?))
@ go install github.com/jstemmer/go-junit-report@latest
GO_JUNIT_REPORT=$(GOBIN)/go-junit-report
else
GO_JUNIT_REPORT=$(shell which go-junit-report)
endif
# find or download mockery
mockery:
ifneq (0, $(shell command -v mockery ; echo $$?))
@ go install github.com/vektra/mockery/v2/[email protected]
MOCKERY=$(GOBIN)/mockery
else
MOCKERY=$(shell which mockery)
endif
## Run acceptance tests
#.PHONY: testacc
###################################
# CICD
###################################
push-to-staging:
./scripts/push-to-staging.sh