-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile
88 lines (77 loc) · 3.12 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
include ./make/config.mk
PACT_GO_VERSION=2.0.8
PACT_DOWNLOAD_DIR=/tmp
ifeq ($(OS),Windows_NT)
PACT_DOWNLOAD_DIR=$$TMP
endif
install_cli:
@if [ ! -d pact/bin ]; then\
echo "--- Installing Pact CLI dependencies";\
curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | bash;\
fi
install:
go install github.com/pact-foundation/pact-go/v2@v$(PACT_GO_VERSION)
pact-go -l DEBUG install --libDir $(PACT_DOWNLOAD_DIR);
run-consumer:
@go run consumer/client/cmd/main.go
run-provider:
@go run provider/cmd/usersvc/main.go
deploy-consumer:
@echo "--- ✅ Checking if we can deploy consumer"
pact/bin/pact-broker can-i-deploy \
--pacticipant $(CONSUMER_NAME) \
--broker-base-url ${PACT_BROKER_PROTO}://$(PACT_BROKER_URL) \
--broker-username $(PACT_BROKER_USERNAME) \
--broker-password $(PACT_BROKER_PASSWORD) \
--version ${VERSION_COMMIT} \
--to-environment production
deploy-provider:
@echo "--- ✅ Checking if we can deploy provider"
pact/bin/pact-broker can-i-deploy \
--pacticipant $(PROVIDER_NAME) \
--broker-base-url ${PACT_BROKER_PROTO}://$(PACT_BROKER_URL) \
--broker-username $(PACT_BROKER_USERNAME) \
--broker-password $(PACT_BROKER_PASSWORD) \
--version ${VERSION_COMMIT} \
--to-environment production
record-deploy-consumer:
@echo "--- ✅ Recording deployment of consumer"
pact/bin/pact-broker record-deployment \
--pacticipant $(CONSUMER_NAME) \
--broker-base-url ${PACT_BROKER_PROTO}://$(PACT_BROKER_URL) \
--broker-username $(PACT_BROKER_USERNAME) \
--broker-password $(PACT_BROKER_PASSWORD) \
--version ${VERSION_COMMIT} \
--environment production
record-deploy-provider:
@echo "--- ✅ Recording deployment of provider"
pact/bin/pact-broker record-deployment \
--pacticipant $(PROVIDER_NAME) \
--broker-base-url ${PACT_BROKER_PROTO}://$(PACT_BROKER_URL) \
--broker-username $(PACT_BROKER_USERNAME) \
--broker-password $(PACT_BROKER_PASSWORD) \
--version ${VERSION_COMMIT} \
--environment production
publish:
@echo "--- 📝 Publishing Pacts"
pact/bin/pact-broker publish ${PWD}/pacts --consumer-app-version ${VERSION_COMMIT} --branch ${VERSION_BRANCH} \
-b $(PACT_BROKER_PROTO)://$(PACT_BROKER_URL) -u ${PACT_BROKER_USERNAME} -p ${PACT_BROKER_PASSWORD}
@echo
@echo "Pact contract publishing complete!"
@echo
@echo "Head over to $(PACT_BROKER_PROTO)://$(PACT_BROKER_URL) and login with $(PACT_BROKER_USERNAME)/$(PACT_BROKER_PASSWORD)"
@echo "to see your published contracts. "
unit:
@echo "--- 🔨Running Unit tests "
go test -tags=unit -count=1 github.com/pact-foundation/pact-workshop-go/consumer/client -run 'TestClientUnit'
consumer: export PACT_TEST := true
consumer:
@echo "--- 🔨Running Consumer Pact tests "
go test -tags=integration -count=1 github.com/pact-foundation/pact-workshop-go/consumer/client -run 'TestClientPact' -v
provider: export PACT_TEST := true
provider:
@echo "--- 🔨Running Provider Pact tests "
go test -count=1 -tags=integration github.com/pact-foundation/pact-workshop-go/provider -run "TestPactProvider" -v
broker:
docker compose up -d
.PHONY: deploy-consumer deploy-provider publish unit consumer provider