Skip to content

Commit

Permalink
ci: verify provider pact
Browse files Browse the repository at this point in the history
  • Loading branch information
jangjunha committed Sep 12, 2023
1 parent 6d581d0 commit a212b97
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Setup Build Environment
description: checkout and setup gradle, java and build plugins
inputs:
ref:
runs:
using: composite
steps:
Expand All @@ -11,6 +13,7 @@ runs:
- uses: actions/checkout@v4
with:
path: ftgo/
ref: ${{ inputs.ref }}

- uses: actions/setup-java@v3
with:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/verify-pact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Verify Pact

on:
push:
repository_dispatch:
types:
- contract_requiring_verification_published

env:
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS: true
PACT_BROKER_BASE_URL: ${{ vars.PACT_BROKER_URL }}
PACT_BROKER_USERNAME: ${{ vars.PACT_BROKER_USERNAME }}
PACT_BROKER_PASSWORD: ${{ secrets.PACT_BROKER_PASSWORD }}
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:
test:
runs-on: ubuntu-latest
environment: pact
defaults:
run:
working-directory: ftgo/
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .github
- uses: ./.github/actions/setup
with:
ref: ${{ env.GIT_COMMIT }}

- uses: actions/setup-java@v3
with:
distribution: liberica
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- uses: jangjunha/pact-broker-actions/install-plugin@main
with:
source: protobuf

- name: Execute Gradle test
run: ./gradlew test
5 changes: 5 additions & 0 deletions ftgo-api-gateway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ dependencyManagement {

tasks.named('test') {
useJUnitPlatform()

systemProperty("pact.provider.version", System.getenv("GIT_COMMIT") ?: "")
systemProperty("pact.provider.tag", System.getenv("GIT_BRANCH") ?: "")
systemProperty("pact.provider.branch", System.getenv("GIT_BRANCH") ?: "")
systemProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "false" : "true")
}

0 comments on commit a212b97

Please sign in to comment.