-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
executable file
Β·137 lines (111 loc) Β· 4.79 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
TEST?=./...
.DEFAULT_GOAL := ci
GITHUB_RUN_ID?=1
PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:latest"
export TF_VAR_build_number=$(GITHUB_RUN_ID)
export TF_VAR_api_token=$(ACCEPTANCE_PACT_BROKER_TOKEN)
export TF_VAR_broker_base_url=$(ACCEPTANCE_PACT_BROKER_BASE_URL)
ci:: clean docker deps pact-go vet bin test pact publish acceptance-test
local-no-clean: build
terraform init && \
TF_LOG=DEBUG TF_LOG_PATH=log/tf.log terraform apply -auto-approve
local: build clean
terraform init && \
TF_LOG=DEBUG TF_LOG_PATH=log/tf.log terraform apply -auto-approve
local-destroy:
terraform destroy -auto-approve
build:
go build -o bin/terraform-provider-pact
mkdir -p ~/.terraform.d/plugins/github.com/pactflow/pact/0.0.1/darwin_amd64
cp bin/terraform-provider-pact ~/.terraform.d/plugins/github.com/pactflow/pact/0.0.1/darwin_amd64/
clean:
mkdir -p ./log acceptance/oss/log acceptance/pactflow/log client/pacts && \
touch terraform.tfstate terraform.tfstate.backup log/tf.log client/pacts/pact.json && \
rm terraform.tf* log/tf.log client/pacts/*.json
clean-acceptance:
mkdir -p ./acceptance/pactflow/.terraform && \
cd ./acceptance/pactflow/ && \
touch terraform.tfstate terraform.tfstate.backup .terraform.lock.hcl log/tf.log && \
rm -rf terraform.tf* log/tf.log .terraform*
docker:
docker-compose up -d
bin:
$$(go env GOPATH)/bin/gox -os="darwin" -arch="arm64" -output="bin/terraform-provider-pact_{{.OS}}_{{.Arch}}"
$$(go env GOPATH)/bin/gox -os="darwin" -arch="amd64" -output="bin/terraform-provider-pact_{{.OS}}_{{.Arch}}"
$$(go env GOPATH)/bin/gox -os="windows" -arch="386" -output="bin/terraform-provider-pact_{{.OS}}_{{.Arch}}"
$$(go env GOPATH)/bin/gox -os="linux" -arch="386" -output="bin/terraform-provider-pact_{{.OS}}_{{.Arch}}"
$$(go env GOPATH)/bin/gox -os="linux" -arch="amd64" -output="bin/terraform-provider-pact_{{.OS}}_{{.Arch}}"
@echo "==> Results:"
ls -hl bin/
deps:
@echo "--- πΏ Fetching build dependencies "
cd /tmp; \
go install github.com/axw/gocov/gocov@latest; \
go install github.com/mattn/goveralls@latest; \
go install golang.org/x/tools/cmd/cover@latest; \
go install github.com/modocache/gover@latest; \
go install github.com/mitchellh/gox@latest; \
cd -
go install github.com/pact-foundation/pact-go/[email protected];
goveralls:
goveralls -service="travis-ci" -coverprofile=coverage.txt -repotoken $(COVERALLS_TOKEN)
test:
@echo "--- β
Running tests"
@if [ -f coverage.txt ]; then rm coverage.txt; fi;
@echo "mode: count" > coverage.txt
@for d in $$(go list ./... | grep -v vendor | grep -v examples); \
do \
go test -race -coverprofile=profile.out -covermode=atomic $$d; \
if [ -f profile.out ]; then \
cat profile.out | tail -n +2 >> coverage.txt; \
rm profile.out; \
fi; \
done; \
go tool cover -func coverage.txt
pact-go:
echo "--- πΏ Installing Pact FFI dependencies"
pact-go -l DEBUG install --libDir /tmp
pact: clean pact-go
@echo "--- π€ Running Pact tests"
go test -tags=consumer -count=1 -v github.com/pactflow/terraform/client/...
publish:
@echo "--- π€ Transforming Broken Keys in Pact File"
"$(PWD)/scripts/transform-broken-keys.sh"
@echo "--- π€ Publishing Pact"
"${PACT_CLI}" publish ${PWD}/client/pacts --consumer-app-version ${GITHUB_SHA} --tag ${GITHUB_BRANCH}
can-i-deploy:
@echo "--- π€ Can I Deploy?"
# @"${PACT_CLI}" broker can-i-deploy \
# --pacticipant "terraform-client" \
# --version ${GITHUB_SHA} \
# --to prod
oss-acceptance-test:
@echo "--- Running OSS acceptance tests"
cd acceptance/oss && \
terraform init && \
terraform apply -auto-approve && \
terraform destroy -auto-approve
pactflow-acceptance-test:
@echo "--- Running Pactflow acceptance tests"
cd acceptance/pactflow && \
mkdir -p ./log && \
terraform init && \
TF_LOG=DEBUG TF_LOG_PATH=log/tf.log terraform apply -auto-approve && \
mv pactflow.tf pactflow.tf.old && mv pactflow-update.tf.next pactflow-update.tf && \
TF_LOG=DEBUG TF_LOG_PATH=log/tf.log terraform apply -auto-approve && \
TF_LOG=DEBUG TF_LOG_PATH=log/tf.log terraform destroy -auto-approve && \
mv pactflow.tf.old pactflow.tf && mv pactflow-update.tf pactflow-update.tf.next
binary-acceptance-test:
@echo "--- Checking binary acceptance test"
mkdir -p ~/.terraform.d/plugins/github.com/pactflow/pact/0.0.1/linux_amd64
cp bin/terraform-provider-pact_linux_amd64 ~/.terraform.d/plugins/github.com/pactflow/pact/0.0.1/linux_amd64/terraform-provider-pact
terraform init
acceptance-test: binary-acceptance-test oss-acceptance-test pactflow-acceptance-test
@echo "--- β
Acceptance tests complete"
release:
@echo "--- π Releasing it"
"$(CURDIR)/scripts/release.sh"
vet:
@echo "--- β
Running go vet"
go vet -all ./...
.PHONY: build clean local bin deps goveralls release acceptance-test docker oss-acceptance-test