Skip to content

Commit b3e0725

Browse files
authored
Merge pull request #37 from pactflow/deps/springboot3
chore(deps):springboot 3.3x/pact 4.5.x/gradle 8
2 parents 12ff221 + 92b2372 commit b3e0725

File tree

12 files changed

+314
-215
lines changed

12 files changed

+314
-215
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
test:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v2
21-
- name: Set up JDK 11
22-
uses: actions/setup-java@v2
20+
- uses: actions/checkout@v4
21+
- name: Set up JDK 17
22+
uses: actions/setup-java@v4
2323
with:
2424
distribution: 'zulu'
25-
java-version: '11'
25+
java-version: '17'
2626
- name: Test
2727
run: GIT_BRANCH=${GITHUB_REF:11} make test
2828

@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
needs: test
3333
steps:
34-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v4
3535
- run: docker pull pactfoundation/pact-cli:latest
3636
- name: Can I deploy?
3737
run: GIT_BRANCH=${GITHUB_REF:11} make can_i_deploy
@@ -41,7 +41,7 @@ jobs:
4141
runs-on: ubuntu-latest
4242
needs: can-i-deploy
4343
steps:
44-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v4
4545
- run: docker pull pactfoundation/pact-cli:latest
4646
- name: Deploy
4747
run: GIT_BRANCH=${GITHUB_REF:11} make deploy
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: contract_requiring_verification_published
2+
3+
# This workflow leverages the https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event webhook
4+
5+
on:
6+
repository_dispatch:
7+
types:
8+
- contract_requiring_verification_published
9+
workflow_dispatch:
10+
# inputs aren't available on push, so we set them explicitly in separate steps
11+
inputs:
12+
PACT_URL:
13+
description: URL of pact to verify
14+
required: true
15+
16+
env:
17+
PACT_BROKER_BASE_URL: https://test.pactflow.io
18+
PACT_BROKER_TOKEN: ${{ secrets.PACTFLOW_TOKEN_FOR_CI_CD_WORKSHOP }}
19+
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS: true
20+
PACT_BROKER_HOST: test.pactflow.io # For pact-jvm
21+
PACT_URL: ${{ github.event.client_payload.pact_url }}
22+
GIT_COMMIT: ${{ github.event.client_payload.sha }}
23+
GIT_BRANCH: ${{ github.event.client_payload.branch }}
24+
DESCRIPTION: ${{ github.event.client_payload.message }}
25+
26+
jobs:
27+
verify-contract-requiring-verification:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: checkout default branch if user manually provides pact URL
31+
uses: actions/checkout@v4
32+
if: ${{ github.event.inputs.PACT_URL }}
33+
- name: checkout specific SHA if webhook provides pact URL
34+
uses: actions/checkout@v4
35+
if: ${{ github.event.client_payload.pact_url }}
36+
with:
37+
ref: ${{env.GIT_COMMIT}}
38+
- name: Set up JDK 17
39+
uses: actions/setup-java@v4
40+
with:
41+
distribution: 'zulu'
42+
java-version: '17'
43+
- run: docker pull pactfoundation/pact-cli:latest
44+
- name: ${{env.DESCRIPTION}}
45+
run: make ci_webhook

.github/workflows/verify_changed_pact.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.java-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17.0

Makefile

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
PACTICIPANT := "pactflow-example-provider-java-soap"
2-
WEBHOOK_UUID := "962805aa-9f31-4a07-8d54-2355344a6f47"
2+
GITHUB_REPO := "pactflow/example-provider-java-soap"
3+
CONTRACT_REQUIRING_VERIFICATION_PUBLISHED_WEBHOOK_UUID := "962805aa-9f31-4a07-8d54-2355344a6f47"
34
PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:latest"
45

56
# Only deploy from master
@@ -24,7 +25,7 @@ fake_ci: .env
2425
CI=true \
2526
GIT_COMMIT=`git rev-parse --short HEAD`+`date +%s` \
2627
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` \
27-
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true \
28+
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=false \
2829
make ci
2930

3031
ci_webhook: .env
@@ -34,7 +35,7 @@ fake_ci_webhook:
3435
CI=true \
3536
GIT_COMMIT=`git rev-parse --short HEAD`+`date +%s` \
3637
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` \
37-
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true \
38+
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=false \
3839
make ci_webhook
3940

4041
## =====================
@@ -48,7 +49,7 @@ test: .env
4849
## Deploy tasks
4950
## =====================
5051

51-
deploy: deploy_app tag record_deployment
52+
deploy: deploy_app record_deployment
5253

5354
no_deploy:
5455
@echo "Not deploying as not on master branch"
@@ -65,13 +66,6 @@ can_i_deploy: .env
6566
deploy_app:
6667
@echo "Deploying to prod"
6768

68-
tag: .env
69-
@"${PACT_CLI}" broker create-version-tag \
70-
--pacticipant ${PACTICIPANT} \
71-
--version ${GIT_COMMIT} \
72-
--auto-create-version \
73-
--tag ${GIT_BRANCH}
74-
7569
record_deployment: .env
7670
@"${PACT_CLI}" broker record-deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment production
7771

@@ -89,20 +83,20 @@ create_github_token_secret:
8983

9084
# NOTE: the github token secret must be created (either through the UI or using the
9185
# `create_github_token_secret` target) before the webhook is invoked.
92-
create_or_update_pact_changed_webhook:
86+
create_or_update_contract_requiring_verification_published_webhook:
9387
"${PACT_CLI}" \
9488
broker create-or-update-webhook \
9589
"https://api.github.com/repos/${GITHUB_REPO}/dispatches" \
9690
--header 'Content-Type: application/json' 'Accept: application/vnd.github.everest-preview+json' 'Authorization: Bearer $${user.githubToken}' \
9791
--request POST \
98-
--data '{ "event_type": "pact_changed", "client_payload": { "pact_url": "$${pactbroker.pactUrl}" } }' \
99-
--uuid ${PACT_CHANGED_WEBHOOK_UUID} \
100-
--consumer ${PACTICIPANT} \
101-
--contract-content-changed \
102-
--description "Pact content changed for ${PACTICIPANT}"
103-
104-
test_pact_changed_webhook:
105-
@curl -v -X POST ${PACT_BROKER_BASE_URL}/webhooks/${PACT_CHANGED_WEBHOOK_UUID}/execute -H "Authorization: Bearer ${PACT_BROKER_TOKEN}"
92+
--data '{ "event_type": "contract_requiring_verification_published","client_payload": { "pact_url": "$${pactbroker.pactUrl}", "sha": "$${pactbroker.providerVersionNumber}", "branch":"$${pactbroker.providerVersionBranch}" , "message": "Verify changed pact for $${pactbroker.consumerName} version $${pactbroker.consumerVersionNumber} branch $${pactbroker.consumerVersionBranch} by $${pactbroker.providerVersionNumber} ($${pactbroker.providerVersionDescriptions})" } }' \
93+
--uuid ${CONTRACT_REQUIRING_VERIFICATION_PUBLISHED_WEBHOOK_UUID} \
94+
--provider ${PACTICIPANT} \
95+
--contract-requiring-verification-published \
96+
--description "contract_requiring_verification_published for ${PACTICIPANT}"
97+
98+
test_contract_requiring_verification_published_webhook:
99+
@curl -v -X POST ${PACT_BROKER_BASE_URL}/webhooks/${CONTRACT_REQUIRING_VERIFICATION_PUBLISHED_WEBHOOK_UUID}/execute -H "Authorization: Bearer ${PACT_BROKER_TOKEN}"
106100

107101
## ======================
108102
## Misc

build.gradle

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.2.2.RELEASE'
3-
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
2+
id 'org.springframework.boot' version '3.3.4'
3+
id 'io.spring.dependency-management' version '1.1.6'
44
id 'java'
55
}
66

77
group = 'io.pactflow.example.xml.provider'
88
version = '0.0.1-SNAPSHOT'
9-
sourceCompatibility = '11'
9+
java {
10+
sourceCompatibility = '17'
11+
}
1012

1113
repositories {
1214
mavenLocal()
@@ -22,13 +24,13 @@ configurations {
2224
dependencies {
2325
implementation 'org.springframework.boot:spring-boot-starter-web'
2426
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
25-
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.2'
27+
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.0'
2628
runtimeOnly 'com.h2database:h2'
2729
compileOnly 'org.projectlombok:lombok'
2830
annotationProcessor 'org.projectlombok:lombok'
2931

30-
testImplementation 'au.com.dius.pact.provider:junit5:4.1.7'
31-
testImplementation 'au.com.dius.pact.provider:spring:4.1.7'
32+
testImplementation 'au.com.dius.pact.provider:junit5:4.5.13'
33+
testImplementation 'au.com.dius.pact.provider:spring6:4.5.13'
3234
testImplementation 'org.apache.commons:commons-lang3:3.11'
3335
testImplementation('org.springframework.boot:spring-boot-starter-test') {
3436
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
@@ -39,7 +41,34 @@ test {
3941
useJUnitPlatform()
4042

4143
// These properties need to be set on the test JVM process
44+
//https://docs.pact.io/implementation_guides/jvm/provider/junit#using-java-system-properties
45+
46+
47+
// required variables for fetching dynamic pacts, & publishing verification results
48+
// used for fetching dynamic pacts
49+
systemProperty("pactbroker.providerBranch", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH"))
50+
// used for publishing verification results
51+
systemProperty("pact.provider.branch", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH"))
4252
systemProperty("pact.provider.version", System.getenv("GIT_COMMIT") == null ? "" : System.getenv("GIT_COMMIT"))
43-
systemProperty("pact.provider.tag", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH"))
53+
54+
// only publish verification results from CI allowing developers to run tests locally and debug, without affecting broker results
55+
// only verification results from a known source (such at a commit in a VCS and a reproducible environment such as CI) should be published
4456
systemProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "false" : "true")
45-
}
57+
58+
// Consumer version selectors for dynamically fetching pacts
59+
// https://docs.pact.io/implementation_guides/jvm/provider/junit#selecting-the-pacts-to-verify-with-consumer-version-selectors-4314
60+
// Runs when the provider code changes
61+
systemProperty("pactbroker.consumerversionselectors.rawjson", "[{\"mainBranch\":true},{\"deployedOrReleased\":true},{\"matchingBranch\":true}]")
62+
// Allow just the changed pact triggered by webhook, to be verified, ignoring the consumer version selectors above
63+
// https://docs.pact.io/implementation_guides/jvm/provider/junit#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406
64+
// Runs when the consumer contract changes
65+
systemProperty("pact.filter.pacturl", System.getenv("PACT_URL") == null ? null : System.getenv("PACT_URL"))
66+
systemProperty("pact.filter.consumers", System.getenv("PACT_URL") == null ? null : System.getenv("PACT_URL").split("/consumer/")[1])
67+
68+
// pending pacts
69+
systemProperty("pactbroker.enablePending", true)
70+
71+
// work in progress pacts
72+
systemProperty("pactbroker.includeWipPactsSince", java.time.LocalDate.now().minusMonths(6).format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")))
73+
74+
}

gradle/wrapper/gradle-wrapper.jar

-12.3 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)