Skip to content

[DT-1172][risk=no] Draft Attachment POST response should only return refs for objects posted. #1924

[DT-1172][risk=no] Draft Attachment POST response should only return refs for objects posted.

[DT-1172][risk=no] Draft Attachment POST response should only return refs for objects posted. #1924

name: Consumer contract tests
# The purpose of this workflow is to validate the service level contract using the Pact framework.
on:
pull_request:
branches:
- develop
paths-ignore:
- 'README.md'
push:
branches:
- develop
paths-ignore:
- 'README.md'
merge_group:
branches:
- develop
paths-ignore:
- 'README.md'
jobs:
consent-contract-tests:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
outputs:
sha-short: ${{ steps.extract-branch.outputs.sha-short }}
pact-b64: ${{ steps.encode-pact.outputs.pact-b64 }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Extract branch
id: extract-branch
run: |
GITHUB_EVENT_NAME=${{ github.event_name }}
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
GITHUB_REF="${GITHUB_DEFAULT_REF}"
GITHUB_SHA="${GITHUB_DEFAULT_SHA}"
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
GITHUB_REF="refs/heads/${GITHUB_HEAD_REF}"
GITHUB_SHA="${GITHUB_HEAD_SHA}"
else
echo "Failed to extract branch information"
exit 1
fi
echo "ref=$GITHUB_REF" >> $GITHUB_OUTPUT
echo "sha=$GITHUB_SHA" >> $GITHUB_OUTPUT
echo "sha-short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "branch=${GITHUB_REF/refs\/heads\//""}" >> $GITHUB_OUTPUT
env:
GITHUB_DEFAULT_SHA: ${{ github.sha }}
GITHUB_DEFAULT_REF: ${{ github.ref }}
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
- name: Echo branch information
run: |
echo "${BRANCH_REF}"
echo "${BRANCH_SHA}"
echo "${BRANCH_SHA_SHORT}"
echo "${BRANCH_NAME}"
env:
BRANCH_REF: ${{ steps.extract-branch.outputs.ref }}
BRANCH_SHA: ${{ steps.extract-branch.outputs.sha }}
BRANCH_SHA_SHORT: ${{ steps.extract-branch.outputs.sha-short }}
BRANCH_NAME: ${{ steps.extract-branch.outputs.branch }}
- name: Run consumer tests
run: mvn clean test -Ppact-tests
- name: Output consumer contract as non-breaking base64 string
id: encode-pact
run: |
NON_BREAKING_B64=$(cat target/pacts/consent-sam.json | base64 -w 0)
echo "pact-b64=${NON_BREAKING_B64}" >> $GITHUB_OUTPUT
publish-pact:
runs-on: ubuntu-latest
needs: [consent-contract-tests]
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Dispatch to terra-github-workflows
uses: aurelien-baudet/workflow-dispatch@3133c5d135c7dbe4be4f9793872b6ef331b53bc7 #commit sha for v4.0.0
with:
workflow: publish-pacts.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: '{ "consumer-name": "consent", "consumer-version": "${{ needs.consent-contract-tests.outputs.sha-short }}", "provider-name": "sam", "pact-b64": "${{ needs.consent-contract-tests.outputs.pact-b64 }}" }'