Skip to content

Commit f4f8d28

Browse files
Гилевич КириллГилевич Кирилл
Гилевич Кирилл
authored and
Гилевич Кирилл
committed
works
0 parents  commit f4f8d28

File tree

58 files changed

+6110
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6110
-0
lines changed

Diff for: Makefile

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
PACTICIPANT := "pactflow-example-bi-directional-provider-restassured"
2+
GITHUB_REPO := "pactflow/example-bi-directional-provider-restassured"
3+
PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:latest"
4+
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:
20+
@if make test; then \
21+
make publish_contract; \
22+
else \
23+
make publish_failure; \
24+
fi;
25+
26+
create_branch_version:
27+
PACTICIPANT=${PACTICIPANT} ./scripts/create_branch_version.sh
28+
29+
create_version_tag:
30+
PACTICIPANT=${PACTICIPANT} ./scripts/create_version_tag.sh
31+
32+
publish_contract: create_branch_version create_version_tag
33+
@echo "\n========== STAGE: publish contract + results (success) ==========\n"
34+
PACTICIPANT=${PACTICIPANT} ./scripts/publish.sh true
35+
36+
publish_failure: create_branch_version create_version_tag
37+
@echo "\n========== STAGE: publish contract + results (failure) ==========\n"
38+
PACTICIPANT=${PACTICIPANT} ./scripts/publish.sh false
39+
40+
# Run the ci target from a developer machine with the environment variables
41+
# set as if it was on GitHub Actions
42+
# Use this for quick feedback when playing around with your workflows.
43+
fake_ci:
44+
GIT_COMMIT=`git rev-parse --short HEAD` \
45+
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` \
46+
make ci;
47+
GIT_COMMIT=`git rev-parse --short HEAD` \
48+
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` \
49+
make deploy_target
50+
51+
deploy_target: can_i_deploy $(DEPLOY_TARGET)
52+
53+
## =====================
54+
## Build/test tasks
55+
## =====================
56+
57+
test:
58+
./../gradlew clean :provider:test --tests "au.com.dius.pactworkshop.provider.ProductsProviderBiDirectionalTest" -i
59+
60+
## =====================
61+
## Deploy tasks
62+
## =====================
63+
64+
deploy: can_i_deploy deploy_app
65+
66+
no_deploy:
67+
@echo "Not deploying as not on master branch"
68+
69+
can_i_deploy:
70+
@docker run --rm \
71+
-e PACT_BROKER_BASE_URL \
72+
-e PACT_BROKER_TOKEN \
73+
pactfoundation/pact-cli:latest \
74+
broker can-i-deploy \
75+
--pacticipant ${PACTICIPANT} \
76+
--version ${GIT_COMMIT} \
77+
--to-environment production
78+
79+
deploy_app: record_deployment
80+
@echo "Deploying to prod"
81+
82+
record_deployment:
83+
@"${PACT_CLI}" broker record_deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment production
84+
85+
## =====================
86+
## Pactflow set up tasks
87+
## =====================
88+
89+
## ======================
90+
## Misc
91+
## ======================

Diff for: build.gradle

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
plugins {
2+
id 'org.springframework.boot' version '2.7.1'
3+
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
4+
id 'java'
5+
}
6+
7+
group = 'au.com.dius.pactworkshop'
8+
version = '0.0.1'
9+
sourceCompatibility = "16"
10+
targetCompatibility = "16"
11+
12+
configurations {
13+
compileOnly {
14+
extendsFrom annotationProcessor
15+
}
16+
}
17+
18+
repositories {
19+
mavenCentral()
20+
}
21+
22+
dependencyManagement {
23+
imports {
24+
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:3.1.3"
25+
}
26+
}
27+
28+
dependencies {
29+
//Spring
30+
implementation 'org.springframework.boot:spring-boot-starter'
31+
implementation 'org.springframework.boot:spring-boot-starter-web'
32+
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
33+
testImplementation('org.springframework.boot:spring-boot-starter-test') {
34+
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
35+
}
36+
//Pact
37+
testImplementation("au.com.dius.pact.provider:junit5:4.3.11")
38+
39+
//DB
40+
runtimeOnly 'com.h2database:h2'
41+
42+
//Lombok
43+
compileOnly 'org.projectlombok:lombok'
44+
annotationProcessor 'org.projectlombok:lombok'
45+
46+
//Swager validator
47+
implementation 'com.atlassian.oai:swagger-request-validator-mockmvc:2.28.2'
48+
implementation 'com.atlassian.oai:swagger-request-validator-restassured:2.28.2'
49+
implementation 'com.atlassian.oai:swagger-request-validator-pact:2.28.2'
50+
implementation 'com.atlassian.oai:swagger-request-validator-core:2.28.2'
51+
52+
53+
}
54+
55+
def getGitHash = { ->
56+
def stdout = new ByteArrayOutputStream()
57+
exec {
58+
commandLine 'git', 'rev-parse', '--short', 'HEAD'
59+
standardOutput = stdout
60+
}
61+
return stdout.toString().trim()
62+
}
63+
64+
def getGitBranch = { ->
65+
def stdout = new ByteArrayOutputStream()
66+
exec {
67+
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
68+
standardOutput = stdout
69+
}
70+
return stdout.toString().trim()
71+
}
72+
73+
test {
74+
useJUnitPlatform()
75+
76+
if (System.getProperty('pactPublishResults') == 'true') {
77+
systemProperty 'pact.provider.version', version + "+" + getGitHash()
78+
systemProperty 'pact.provider.tag', getGitBranch()
79+
systemProperty 'pact.verifier.publishResults', 'true'
80+
}
81+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)