1+ PACTICIPANT := "pactflow-example-provider-java-graphql"
2+ WEBHOOK_UUID := "9GS-Z8nSAbUzvJW4xmhdsg"
3+ PACT_CHANGED_WEBHOOK_UUID := "c76b601e-d66a-4eb1-88a4-6ebc50c0df8b"
4+ PACT_CLI ="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli"
5+
6+ # Only deploy from master
7+ ifeq ($(GIT_BRANCH ) ,master)
8+ DEPLOY_TARGET=deploy
9+ else
10+ DEPLOY_TARGET=no_deploy
11+ endif
12+
13+ all : test
14+
15+ # # ====================
16+ # # CI tasks
17+ # # ====================
18+
19+ ci : test $(DEPLOY_TARGET )
20+
21+ # Run the ci target from a developer machine with the environment variables
22+ # set as if it was on GitHub Actions
23+ # Use this for quick feedback when playing around with your workflows.
24+ fake_ci : .env
25+ CI=true \
26+ GIT_COMMIT=` git rev-parse --short HEAD` +` date +%s` \
27+ GIT_BRANCH=` git rev-parse --abbrev-ref HEAD` \
28+ PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true \
29+ make ci
30+
31+ ci_webhook : .env
32+ ./gradlew clean test -i
33+
34+ fake_ci_webhook :
35+ CI=true \
36+ GIT_COMMIT=` git rev-parse --short HEAD` +` date +%s` \
37+ GIT_BRANCH=` git rev-parse --abbrev-ref HEAD` \
38+ PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true \
39+ make ci_webhook
40+
41+ # # =====================
42+ # # Build/test tasks
43+ # # =====================
44+
45+ test : .env
46+ ./gradlew clean test -i
47+
48+ # # =====================
49+ # # Deploy tasks
50+ # # =====================
51+
52+ deploy : can_i_deploy deploy_app record_deployment
53+
54+ no_deploy :
55+ @echo " Not deploying as not on master branch"
56+
57+ can_i_deploy : .env
58+ @" ${PACT_CLI} " broker can-i-deploy --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --to-environment production
59+
60+ deploy_app :
61+ @echo " Deploying to prod"
62+
63+ record_deployment :
64+ @" ${PACT_CLI} " broker record_deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment production
65+
66+ # # =====================
67+ # # PactFlow set up tasks
68+ # # =====================
69+
70+ # export the GITHUB_TOKEN environment variable before running this
71+ create_github_token_secret :
72+ curl -v -X POST ${PACT_BROKER_BASE_URL} /secrets \
73+ -H " Authorization: Bearer ${PACT_BROKER_TOKEN} " \
74+ -H " Content-Type: application/json" \
75+ -H " Accept: application/hal+json" \
76+ -d " {\" name\" :\" githubToken\" ,\" description\" :\" Github token\" ,\" value\" :\" ${GITHUB_TOKEN} \" }"
77+
78+ # NOTE: the github token secret must be created (either through the UI or using the
79+ # `create_github_token_secret` target) before the webhook is invoked.
80+ create_or_update_pact_changed_webhook :
81+ " ${PACT_CLI} " \
82+ broker create-or-update-webhook \
83+ " https://api.github.com/repos/${GITHUB_REPO} /dispatches" \
84+ --header ' Content-Type: application/json' ' Accept: application/vnd.github.everest-preview+json' ' Authorization: Bearer $${user.githubToken}' \
85+ --request POST \
86+ --data ' { "event_type": "pact_changed", "client_payload": { "pact_url": "$${pactbroker.pactUrl}" } }' \
87+ --uuid ${PACT_CHANGED_WEBHOOK_UUID} \
88+ --consumer ${PACTICIPANT} \
89+ --contract-content-changed \
90+ --description " Pact content changed for ${PACTICIPANT} "
91+
92+ test_pact_changed_webhook :
93+ @curl -v -X POST ${PACT_BROKER_BASE_URL} /webhooks/${PACT_CHANGED_WEBHOOK_UUID} /execute -H " Authorization: Bearer ${PACT_BROKER_TOKEN} "
94+
95+ # # ======================
96+ # # Misc
97+ # # ======================
98+
99+ .env :
100+ touch .env
101+
102+ schema-test :
103+ # @./node_modules/.bin/swagger-mock-validator ./oas/swagger.yml ../example-consumer-cypress/pacts/example-cypress-consumer-pactflow-example-provider.json
104+ ./node_modules/.bin/swagger-mock-validator --user dXfltyFMgNOFZAxr8io9wJ37iUpY42M:O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1 --tag master --provider pactflow-example-provider ./oas/swagger.yml https://test.pactflow.io
0 commit comments