forked from gothinkster/realworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (61 loc) Β· 2.1 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
PACTICIPANT ?= "realworld-openapi-spec"
## ====================
## Pactflow Provider Publishing
## ====================
PACT_CLI="docker run --rm -v ${PWD}:/app -w "/app" -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli"
OAS_FILE_PATH?=api/openapi.yml
OAS_FILE_CONTENT_TYPE?=application/yaml
REPORT_FILE_PATH?=api/README.md
REPORT_FILE_CONTENT_TYPE?=text/markdown
VERIFIER_TOOL?=newman
# Export all variable to sub-make if .env exists
ifneq (,$(wildcard ./.env))
include .env
export
endif
default:
cat ./Makefile
ci: ci-test publish_pacts can_i_deploy
# Run the ci target from a developer machine with the environment variables
# set as if it was on CI.
# Use this for quick feedback when playing around with your workflows.
fake_ci:
@CI=true \
GIT_COMMIT=`git rev-parse --short HEAD` \
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` \
make ci
## =====================
## Build/test tasks
## =====================
ci-test:
@echo "\n========== STAGE: CI Tests ==========\n"
## =====================
## Pact tasks
## =====================
publish_pacts:
@echo "\n========== STAGE: publish provider contract (spec + results) - success ==========\n"
PACTICIPANT=${PACTICIPANT} \
"${PACT_CLI}" pactflow publish-provider-contract \
/app/${OAS_FILE_PATH} \
--provider ${PACTICIPANT} \
--provider-app-version ${GIT_COMMIT} \
--branch ${GIT_BRANCH} \
--content-type ${OAS_FILE_CONTENT_TYPE} \
--verification-exit-code=0 \
--verification-results /app/${REPORT_FILE_PATH} \
--verification-results-content-type ${REPORT_FILE_CONTENT_TYPE} \
--verifier ${VERIFIER_TOOL}
deploy: deploy_app record_deployment
can_i_deploy:
@echo "\n========== STAGE: can-i-deploy? π ==========\n"
"${PACT_CLI}" broker can-i-deploy --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --to-environment test
deploy_app:
@echo "\n========== STAGE: deploy ==========\n"
@echo "Deploying to test"
record_deployment:
"${PACT_CLI}" broker record-deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment test
## =====================
## Misc
## =====================
.env:
cp -n .env.example .env || true