Skip to content
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
9 changes: 1 addition & 8 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
* @hmcts/platform-operations @hmcts/developer-enablement

# Ignore files updated by Renovate
gradle/wrapper/gradle-wrapper.properties
Dockerfile
build.gradle
charts/**/Chart.yaml
.github/workflows/*.yaml
* @hmcts/cp-x-cjs-data-api
125 changes: 96 additions & 29 deletions .github/workflows/ci-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
required: true
HMCTS_ADO_PAT:
required: true
PACT_BROKER_TOKEN:
required: true
inputs:
is_release:
required: false
Expand All @@ -23,6 +25,12 @@ on:
trigger_deploy:
required: true
type: boolean
pacticipant:
required: true
type: string
pact_env:
required: true
type: string

jobs:
Artefact-Version:
Expand All @@ -49,6 +57,10 @@ jobs:
outputs:
repo_name: ${{ steps.repo_vars.outputs.repo_name }}
artefact_name: ${{ steps.repo_vars.outputs.artefact_name }}
env:
PACT_BROKER_BASE_URL: "https://hmcts-dts.pactflow.io"
PACT_ENV: "dev/pactTest"

steps:
- name: Checkout source code
uses: actions/checkout@v4
Expand All @@ -64,36 +76,12 @@ jobs:
with:
gradle-version: current

- name: Gradle Build and Publish
- name: Gradle Build
env:
ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
run: |
echo "Building with ARTEFACT_VERSION=$ARTEFACT_VERSION"

gradle build -DARTEFACT_VERSION=$ARTEFACT_VERSION

if [ -z "AZURE_DEVOPS_ARTIFACT_USERNAME" ]; then
echo "::warning::AZURE_DEVOPS_ARTIFACT_USERNAME is null or not set"
fi

if [ -z "$AZURE_DEVOPS_ARTIFACT_TOKEN" ]; then
echo "::warning::AZURE_DEVOPS_ARTIFACT_TOKEN is null or not set"
fi

if [ "${{ inputs.is_publish }}" == "true" ]; then
echo "Publishing artefact for version: $ARTEFACT_VERSION"

gradle publish \
-DARTEFACT_VERSION=$ARTEFACT_VERSION \
-DGITHUB_REPOSITORY=${{ github.repository }} \
-DGITHUB_ACTOR=${{ github.actor }} \
-DGITHUB_TOKEN=$GITHUB_TOKEN \
-DAZURE_DEVOPS_ARTIFACT_USERNAME=$AZURE_DEVOPS_ARTIFACT_USERNAME \
-DAZURE_DEVOPS_ARTIFACT_TOKEN=$AZURE_DEVOPS_ARTIFACT_TOKEN
fi
gradle build -DARTEFACT_VERSION=$ARTEFACT_VERSION

- name: Extract repo name
id: repo_vars
Expand All @@ -108,8 +96,87 @@ jobs:
name: app.jar
path: build/libs/${{ steps.repo_vars.outputs.artefact_name }}.jar

Provider-Deploy:
needs: [ Artefact-Version, Build ]
runs-on: ubuntu-latest
env:
PACT_PROVIDER_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }}
PACT_BROKER_URL: "https://hmcts-dts.pactflow.io"
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
PACT_ENV: ${{ inputs.pact_env }}
PACTICIPANT: ${{ inputs.pacticipant }}
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: current

# If the results are not published, the Pact Broker will not be able to find the version
# NOTE: if the version is not found and verification step is successful, check that 'pact.verifier.publishResults' is set to true in the gradle task
- name: Pact Provider Verification and Publish Results
env:
PACT_PROVIDER_BRANCH: ${{ github.ref_name }}
PACT_VERIFIER_PUBLISH_RESULTS: true
run: |
echo "PACT_PROVIDER_VERSION=$PACT_PROVIDER_VERSION"
echo "PACT_VERIFIER_PUBLISH_RESULTS=$PACT_VERIFIER_PUBLISH_RESULTS"
echo "PACT_PROVIDER_BRANCH=$PACT_PROVIDER_BRANCH"
echo "PACT_BROKER_TOKEN=$PACT_BROKER_TOKEN"
echo "PACT_BROKER_URL=$PACT_BROKER_URL"
echo "PACT_ENV=$PACT_ENV"

gradle pactVerificationTest \
-Dpact.provider.version="$PACT_PROVIDER_VERSION" \
-Dpact.verifier.publishResults="$PACT_VERIFIER_PUBLISH_RESULTS" \
-Dpact.provider.branch="$PACT_PROVIDER_BRANCH" \
-Dpact.broker.token="$PACT_BROKER_TOKEN" \
-Dpact.broker.url="$PACT_BROKER_URL" \
-Dpact.env="$PACT_ENV"

- uses: hmcts/pact-can-i-deploy@main
with:
pact_broker_token: ${{ secrets.PACT_BROKER_TOKEN }}
pacticipant: ${{ inputs.pacticipant }}
pacticipant_version: ${{ env.PACT_PROVIDER_VERSION }}
pact_env: ${{ env.PACT_ENV }}

- name: Gradle Publish
if: ${{ inputs.is_publish }}
env:
ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
run: |
if [ -z "AZURE_DEVOPS_ARTIFACT_USERNAME" ]; then
echo "::warning::AZURE_DEVOPS_ARTIFACT_USERNAME is null or not set"
fi

if [ -z "$AZURE_DEVOPS_ARTIFACT_TOKEN" ]; then
echo "::warning::AZURE_DEVOPS_ARTIFACT_TOKEN is null or not set"
fi

echo "Publishing artefact for version: $ARTEFACT_VERSION"

gradle publish \
-DARTEFACT_VERSION=$ARTEFACT_VERSION \
-DGITHUB_REPOSITORY=${{ github.repository }} \
-DGITHUB_ACTOR=${{ github.actor }} \
-DGITHUB_TOKEN=$GITHUB_TOKEN \
-DAZURE_DEVOPS_ARTIFACT_USERNAME=$AZURE_DEVOPS_ARTIFACT_USERNAME \
-DAZURE_DEVOPS_ARTIFACT_TOKEN=$AZURE_DEVOPS_ARTIFACT_TOKEN

Build-Docker:
needs: [ Build, Artefact-Version ]
needs: [ Provider-Deploy, Build, Artefact-Version ]
if: ${{ inputs.trigger_docker }}
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -145,7 +212,7 @@ jobs:
JAR_FILENAME=${{ needs.Build.outputs.artefact_name }}.jar

Deploy:
needs: [ Build, Artefact-Version ]
needs: [ Provider-Deploy, Build, Artefact-Version ]
if: ${{ inputs.trigger_deploy }}
runs-on: ubuntu-latest
steps:
Expand All @@ -163,4 +230,4 @@ jobs:
"ARTIFACT_ID": "${{ env.REPO_NAME }}",
"ARTIFACT_VERSION": "${{ needs.Artefact-Version.outputs.artefact_version }}",
"TARGET_REPOSITORY": "${{ github.repository }}"
}
}
4 changes: 3 additions & 1 deletion .github/workflows/ci-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
HMCTS_ADO_PAT: ${{ secrets.HMCTS_ADO_PAT }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
with:
is_publish: ${{ github.event_name == 'push' }}
trigger_docker: ${{ github.event_name == 'push' }}
trigger_deploy: ${{ github.event_name == 'push' }}

pacticipant: CPCourtScheduleProvider
pact_env: dev/pactTest
3 changes: 3 additions & 0 deletions .github/workflows/ci-released.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ jobs:
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
HMCTS_ADO_PAT: ${{ secrets.HMCTS_ADO_PAT }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
with:
is_release: true
is_publish: true
trigger_docker: true
trigger_deploy: true
pacticipant: CPCourtScheduleProvider
pact_env: dev/pactTest
10 changes: 2 additions & 8 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
languages: ${{ matrix.language }}
queries: security-extended


- uses: actions/setup-java@v4
with:
distribution: 'temurin'
Expand All @@ -47,14 +46,9 @@ jobs:
with:
gradle-version: current

- name: Gradle Build and Publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Gradle Build
run: |
gradle build cyclonedxBom -x test \
-DGITHUB_REPOSITORY=${{ github.repository }} \
-DGITHUB_ACTOR=${{ github.actor }} \
-DGITHUB_TOKEN=$GITHUB_TOKEN
gradle build cyclonedxBom -x test

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/publish-pact-verification.yml

This file was deleted.

22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@

Further documentation see the [HMCTS Marketplace Springboot template readme](https://github.com/hmcts/service-hmcts-marketplace-springboot-template/blob/main/README.md).

### Run pact provider test and publish verification report to pact broker locally
## Pact Provider Test

update .env file with below details
PACT_BROKER_URL= <<PactFlow broker url>>
PACT_BROKER_HOST=<<PactFlow broker url excluding https://>>
PACT_BROKER_TOKEN= <<Your PactFlow broker token>>
PACT_ENV= << This is the environment in PactFlow broker to which we tag the contracts>
PACT_VERIFIER_PUBLISH_RESULTS=true
run ./publish-pacts.sh
Run pact provider test and publish verification report to pact broker locally

Update .env file with below details (replacing placeholders with actual values):
```bash
export PACT_BROKER_URL="https://hmcts-dts.pactflow.io"
export PACT_BROKER_TOKEN="YOUR_PACTFLOW_BROKER_TOKEN"
export PACT_ENV="local" # or value based on the environment you are testing against
export PACT_VERIFIER_PUBLISH_RESULTS=true
```
Run Pact tests:
```bash
gradle pactVerificationTest
```

## License

Expand Down
Loading
Loading