Skip to content

Commit 0f5b3f1

Browse files
authored
Merge pull request #1 from pactflow/deps/springboot3
chore(deps):springboot 3.3x/pact 4.5.x/gradle 8
2 parents 183e5c4 + 7d94166 commit 0f5b3f1

File tree

10 files changed

+119
-49
lines changed

10 files changed

+119
-49
lines changed

.github/workflows/build.yml

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

@@ -30,7 +30,7 @@ jobs:
3030
runs-on: ubuntu-latest
3131
needs: test
3232
steps:
33-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v4
3434
- run: docker pull pactfoundation/pact-cli:latest
3535
- name: Can I deploy?
3636
run: GIT_BRANCH=${GITHUB_REF:11} make can_i_deploy
@@ -40,7 +40,7 @@ jobs:
4040
runs-on: ubuntu-latest
4141
needs: can-i-deploy
4242
steps:
43-
- uses: actions/checkout@v2
43+
- uses: actions/checkout@v4
4444
- run: docker pull pactfoundation/pact-cli:latest
4545
- name: Deploy
4646
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
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Trigger update to partners.pactflow.io
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '**.md'
9+
10+
jobs:
11+
run:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Trigger docs.pact.io update workflow
15+
run: |
16+
curl -X POST https://api.github.com/repos/pactflow/docs.pactflow.io/dispatches \
17+
-H 'Accept: application/vnd.github.everest-preview+json' \
18+
-H "Authorization: Bearer $GITHUB_TOKEN" \
19+
-d '{"event_type": "pactflow-example-provider-java-graphql-updated"}'
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GHTOKENFORTRIGGERINGPACTDOCSUPDATE }}
22+
- name: Trigger partners.pact.io update workflow
23+
run: |
24+
curl -X POST https://api.github.com/repos/pactflow/partners.pactflow.io/dispatches \
25+
-H 'Accept: application/vnd.github.everest-preview+json' \
26+
-H "Authorization: Bearer $GITHUB_TOKEN" \
27+
-d '{"event_type": "pactflow-example-provider-java-graphql-updated"}'
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GHTOKENFORTRIGGERINGPACTDOCSUPDATE }}

.github/workflows/verify_changed_pact.yml

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

.java-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11
1+
17.0

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ fake_ci_webhook:
4444

4545
test: .env
4646
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` ./gradlew clean test -i
47-
4847
## =====================
4948
## Deploy tasks
5049
## =====================

build.gradle

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.7.8'
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'
5-
id "au.com.dius.pact" version "4.1.39"
5+
id "au.com.dius.pact" version "4.5.13"
66
}
77

88
group = 'com.example'
99
version = '0.0.1-SNAPSHOT'
10-
sourceCompatibility = '15'
10+
java {
11+
sourceCompatibility = '17'
12+
}
1113

1214
repositories {
1315
mavenCentral()
@@ -23,9 +25,9 @@ dependencies {
2325
implementation 'org.springframework.boot:spring-boot-starter-web'
2426
implementation 'org.springframework.boot:spring-boot-starter-graphql'
2527
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
26-
testImplementation 'au.com.dius.pact.provider:junit:4.1.39'
27-
testImplementation 'au.com.dius.pact.provider:junit5:4.1.39'
28-
testImplementation 'au.com.dius.pact.provider:spring:4.1.39'
28+
testImplementation 'au.com.dius.pact.provider:junit:4.5.13'
29+
testImplementation 'au.com.dius.pact.provider:junit5:4.5.13'
30+
testImplementation 'au.com.dius.pact.provider:spring:4.5.13'
2931

3032
runtimeOnly 'com.h2database:h2'
3133
compileOnly 'org.projectlombok:lombok'
@@ -39,9 +41,31 @@ test {
3941
useJUnitPlatform()
4042

4143
// These properties need to be set on the test JVM process
44+
45+
// required variables for fetching dynamic pacts, & publishing verification results
46+
// used for fetching dynamic pacts
47+
systemProperty("pactbroker.providerBranch", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH"))
48+
// used for publishing verification results
49+
systemProperty("pact.provider.branch", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH"))
4250
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"))
44-
systemProperty("pact.provider.branch", System.getenv("GIT_BRANCH") == null ? "main" : System.getenv("GIT_BRANCH"))
45-
systemProperty("pactbroker.consumerversionselectors.rawjson", "[{\"mainBranch\":true}]")
51+
52+
// only publish verification results from CI allowing developers to run tests locally and debug, without affecting broker results
53+
// only verification results from a known source (such at a commit in a VCS and a reproducible environment such as CI) should be published
4654
systemProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "false" : "true")
55+
56+
// Consumer version selectors for dynamically fetching pacts
57+
// https://docs.pact.io/implementation_guides/jvm/provider/junit#selecting-the-pacts-to-verify-with-consumer-version-selectors-4314
58+
// Runs when the provider code changes
59+
systemProperty("pactbroker.consumerversionselectors.rawjson", "[{\"mainBranch\":true},{\"deployedOrReleased\":true},{\"matchingBranch\":true}]")
60+
// Allow just the changed pact triggered by webhook, to be verified, ignoring the consumer version selectors above
61+
// https://docs.pact.io/implementation_guides/jvm/provider/junit#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406
62+
// Runs when the consumer contract changes
63+
systemProperty("pact.filter.pacturl", System.getenv("PACT_URL") == null ? null : System.getenv("PACT_URL"))
64+
systemProperty("pact.filter.consumers", System.getenv("PACT_URL") == null ? null : System.getenv("PACT_URL").split("/consumer/")[1])
65+
66+
// pending pacts
67+
systemProperty("pactbroker.enablePending", true)
68+
69+
// work in progress pacts
70+
systemProperty("pactbroker.includeWipPactsSince", java.time.LocalDate.now().minusMonths(6).format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")))
4771
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

src/main/java/com/example/springboot/Product.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import lombok.Data;
44

5-
import javax.persistence.Entity;
6-
import javax.persistence.Id;
5+
import jakarta.persistence.*;
76

87
import com.fasterxml.jackson.annotation.JsonFormat;
98

src/test/java/com/example/springboot/ProductsPactTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
@ExtendWith(SpringExtension.class)
1919
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
2020
@Provider("pactflow-example-provider-java-graphql")
21-
@PactBroker(scheme = "https", host = "${PACT_BROKER_HOST}", providerBranch = "${GIT_BRANCH}", enablePendingPacts = "true", authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}"))
21+
@AllowOverridePactUrl
22+
@PactBroker(scheme = "https", host = "${PACT_BROKER_HOST}", authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}"))
2223
class ProductsPactTest {
2324

2425
@Autowired

0 commit comments

Comments
 (0)