WOR-1148 capture pod logs (#1398) #464
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Consumer contract tests | |
# The purpose of this workflow is to validate the service level contract | |
# using the Pact framework. | |
# | |
# More details on Contract Testing can be found in our handbook | |
# | |
# https://broadworkbench.atlassian.net/wiki/spaces/IRT/pages/2660368406/Getting+Started+with+Pact+Contract+Testing | |
# | |
# | |
# | |
# NOTE: The publish-contracts workflow will use the latest commit of the branch that triggers this workflow to publish the unique consumer contract version to Pact Broker. | |
on: | |
pull_request: | |
branches: [ main ] | |
paths-ignore: [ '**.md' ] | |
push: | |
branches: [ main ] | |
paths-ignore: [ '**.md' ] | |
merge_group: | |
branches: [ main ] | |
paths-ignore: [ '**.md' ] | |
jobs: | |
init-github-context: | |
runs-on: ubuntu-latest | |
outputs: | |
repo-branch: ${{ steps.extract-branch.outputs.repo-branch }} | |
repo-version: ${{ steps.extract-branch.outputs.repo-version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: extract-branch | |
run: | | |
GITHUB_EVENT_NAME=${{ github.event_name }} | |
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then | |
GITHUB_REF=${{ github.ref }} | |
GITHUB_SHA=${{ github.sha }} | |
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then | |
GITHUB_REF=refs/heads/${{ github.head_ref }} | |
GITHUB_SHA=${{ github.event.pull_request.head.sha }} | |
elif [[ "$GITHUB_EVENT_NAME" == "merge_group" ]]; then | |
GITHUB_REF=refs/heads/${{ github.head_ref }} | |
else | |
echo "Failed to extract branch information" | |
exit 1 | |
fi | |
echo "repo-branch=${GITHUB_REF/refs\/heads\//""}" >> $GITHUB_OUTPUT | |
echo "repo-version=${GITHUB_SHA}" >> $GITHUB_OUTPUT | |
- name: Echo repo and branch information | |
run: | | |
echo "repo-owner=${{ github.repository_owner }}" | |
echo "repo-name=${{ github.event.repository.name }}" | |
echo "repo-branch=${{ steps.extract-branch.outputs.repo-branch }}" | |
echo "repo-version=${{ steps.extract-branch.outputs.repo-version }}" | |
wsm-consumer-contract-tests: | |
runs-on: ubuntu-latest | |
needs: [init-github-context] | |
outputs: | |
pact-b64: ${{ steps.encode-pact.outputs.pact-b64 }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Run consumer tests | |
run: ./gradlew pactTests | |
- name: Output consumer contract as non-breaking base64 string | |
id: encode-pact | |
run: | | |
NON_BREAKING_B64=$(cat service/build/pacts/wsm-consumer-bpm-provider.json | base64 -w 0) | |
echo "pact-b64=${NON_BREAKING_B64}" >> $GITHUB_OUTPUT | |
publish-contracts: | |
runs-on: ubuntu-latest | |
needs: [ init-github-context, wsm-consumer-contract-tests ] | |
steps: | |
- name: Dispatch to terra-github-workflows | |
uses: broadinstitute/workflow-dispatch@v3 | |
with: | |
workflow: .github/workflows/publish-contracts.yaml | |
repo: broadinstitute/terra-github-workflows | |
ref: refs/heads/main | |
token: ${{ secrets.BROADBOT_TOKEN }} # github token for access to kick off a job in the private repo | |
inputs: '{ "pact-b64": "${{ needs.wsm-consumer-contract-tests.outputs.pact-b64 }}", "repo-owner": "${{ github.repository_owner }}", "repo-name": "${{ github.event.repository.name }}", "repo-branch": "${{ needs.init-github-context.outputs.repo-branch }}" }' | |