Skip to content

chore(deps):springboot 3.3x/pact 4.5.x/gradle 8 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 19
uses: actions/setup-java@v2
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '19'
java-version: '17'
- name: Test
run: GIT_BRANCH=${GITHUB_REF:11} make test

Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: docker pull pactfoundation/pact-cli:latest
- name: Can I deploy?
run: GIT_BRANCH=${GITHUB_REF:11} make can_i_deploy
Expand All @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
needs: can-i-deploy
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: docker pull pactfoundation/pact-cli:latest
- name: Deploy
run: GIT_BRANCH=${GITHUB_REF:11} make deploy
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/contract_requiring_verification_published.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: contract_requiring_verification_published

# This workflow leverages the https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event webhook

on:
repository_dispatch:
types:
- contract_requiring_verification_published
workflow_dispatch:
# inputs aren't available on push, so we set them explicitly in separate steps
inputs:
PACT_URL:
description: URL of pact to verify
required: true

env:
PACT_BROKER_BASE_URL: https://test.pactflow.io
PACT_BROKER_TOKEN: ${{ secrets.PACTFLOW_TOKEN_FOR_CI_CD_WORKSHOP }}
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS: true
PACT_BROKER_HOST: test.pactflow.io # For pact-jvm
PACT_URL: ${{ github.event.client_payload.pact_url }}
GIT_COMMIT: ${{ github.event.client_payload.sha }}
GIT_BRANCH: ${{ github.event.client_payload.branch }}
DESCRIPTION: ${{ github.event.client_payload.message }}

jobs:
verify-contract-requiring-verification:
runs-on: ubuntu-latest
steps:
- name: checkout default branch if user manually provides pact URL
uses: actions/checkout@v4
if: ${{ github.event.inputs.PACT_URL }}
- name: checkout specific SHA if webhook provides pact URL
uses: actions/checkout@v4
if: ${{ github.event.client_payload.pact_url }}
with:
ref: ${{env.GIT_COMMIT}}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- run: docker pull pactfoundation/pact-cli:latest
- name: ${{env.DESCRIPTION}}
run: make ci_webhook
29 changes: 29 additions & 0 deletions .github/workflows/trigger_partner_docs_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Trigger update to partners.pactflow.io

on:
push:
branches:
- master
paths:
- '**.md'

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Trigger docs.pact.io update workflow
run: |
curl -X POST https://api.github.com/repos/pactflow/docs.pactflow.io/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-d '{"event_type": "pactflow-example-provider-java-graphql-updated"}'
env:
GITHUB_TOKEN: ${{ secrets.GHTOKENFORTRIGGERINGPACTDOCSUPDATE }}
- name: Trigger partners.pact.io update workflow
run: |
curl -X POST https://api.github.com/repos/pactflow/partners.pactflow.io/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-d '{"event_type": "pactflow-example-provider-java-graphql-updated"}'
env:
GITHUB_TOKEN: ${{ secrets.GHTOKENFORTRIGGERINGPACTDOCSUPDATE }}
27 changes: 0 additions & 27 deletions .github/workflows/verify_changed_pact.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11
17.0
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ fake_ci_webhook:

test: .env
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` ./gradlew clean test -i

## =====================
## Deploy tasks
## =====================
Expand Down
44 changes: 34 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
plugins {
id 'org.springframework.boot' version '2.7.8'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'org.springframework.boot' version '3.3.4'
id 'io.spring.dependency-management' version '1.1.6'
id 'java'
id "au.com.dius.pact" version "4.1.39"
id "au.com.dius.pact" version "4.5.13"
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '15'
java {
sourceCompatibility = '17'
}

repositories {
mavenCentral()
Expand All @@ -23,9 +25,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-graphql'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
testImplementation 'au.com.dius.pact.provider:junit:4.1.39'
testImplementation 'au.com.dius.pact.provider:junit5:4.1.39'
testImplementation 'au.com.dius.pact.provider:spring:4.1.39'
testImplementation 'au.com.dius.pact.provider:junit:4.5.13'
testImplementation 'au.com.dius.pact.provider:junit5:4.5.13'
testImplementation 'au.com.dius.pact.provider:spring:4.5.13'

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

// These properties need to be set on the test JVM process

// required variables for fetching dynamic pacts, & publishing verification results
// used for fetching dynamic pacts
systemProperty("pactbroker.providerBranch", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH"))
// used for publishing verification results
systemProperty("pact.provider.branch", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH"))
systemProperty("pact.provider.version", System.getenv("GIT_COMMIT") == null ? "" : System.getenv("GIT_COMMIT"))
systemProperty("pact.provider.tag", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH"))
systemProperty("pact.provider.branch", System.getenv("GIT_BRANCH") == null ? "main" : System.getenv("GIT_BRANCH"))
systemProperty("pactbroker.consumerversionselectors.rawjson", "[{\"mainBranch\":true}]")

// only publish verification results from CI allowing developers to run tests locally and debug, without affecting broker results
// only verification results from a known source (such at a commit in a VCS and a reproducible environment such as CI) should be published
systemProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "false" : "true")

// Consumer version selectors for dynamically fetching pacts
// https://docs.pact.io/implementation_guides/jvm/provider/junit#selecting-the-pacts-to-verify-with-consumer-version-selectors-4314
// Runs when the provider code changes
systemProperty("pactbroker.consumerversionselectors.rawjson", "[{\"mainBranch\":true},{\"deployedOrReleased\":true},{\"matchingBranch\":true}]")
// Allow just the changed pact triggered by webhook, to be verified, ignoring the consumer version selectors above
// https://docs.pact.io/implementation_guides/jvm/provider/junit#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406
// Runs when the consumer contract changes
systemProperty("pact.filter.pacturl", System.getenv("PACT_URL") == null ? null : System.getenv("PACT_URL"))
systemProperty("pact.filter.consumers", System.getenv("PACT_URL") == null ? null : System.getenv("PACT_URL").split("/consumer/")[1])

// pending pacts
systemProperty("pactbroker.enablePending", true)

// work in progress pacts
systemProperty("pactbroker.includeWipPactsSince", java.time.LocalDate.now().minusMonths(6).format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")))
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 1 addition & 2 deletions src/main/java/com/example/springboot/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.*;

import com.fasterxml.jackson.annotation.JsonFormat;

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/example/springboot/ProductsPactTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@Provider("pactflow-example-provider-java-graphql")
@PactBroker(scheme = "https", host = "${PACT_BROKER_HOST}", providerBranch = "${GIT_BRANCH}", enablePendingPacts = "true", authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}"))
@AllowOverridePactUrl
@PactBroker(scheme = "https", host = "${PACT_BROKER_HOST}", authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}"))
class ProductsPactTest {

@Autowired
Expand Down