Skip to content
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

WX-1407 Fix contract tests #7340

Merged
merged 30 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e5b63cd
Rename suggested by Ivan
aednichols Dec 8, 2023
22ee967
Interrogate
aednichols Dec 8, 2023
3ee27fb
Test
aednichols Dec 8, 2023
fc34958
Fix version?
aednichols Dec 8, 2023
722041c
Fix
aednichols Dec 8, 2023
faf943c
Comment commit
aednichols Dec 8, 2023
4eee177
Try noop change
ichengchang Dec 8, 2023
0c3f58b
Updated workflow-dispatch to v4.0.0
ichengchang Dec 8, 2023
1cc35cd
Fix request header
ichengchang Dec 9, 2023
7e63e47
Fix headers
ichengchang Dec 9, 2023
f2dbe9b
Revert
ichengchang Dec 9, 2023
a83cb52
revert
ichengchang Dec 9, 2023
52a55b7
testing
ichengchang Dec 9, 2023
993cdcc
Update drshub naming
ichengchang Dec 9, 2023
43f63b5
Update drshub naming
ichengchang Dec 9, 2023
8d45265
Enabled drshub for contract tests
ichengchang Dec 9, 2023
dfb3214
Test consumer
ichengchang Dec 9, 2023
dce8166
test webhook
ichengchang Dec 9, 2023
d23c2d2
test webhook
ichengchang Dec 9, 2023
743ba7b
Use CROMWELL_VERSION to publish pacts for now. This needs to change t…
ichengchang Dec 9, 2023
394105f
Force verification
ichengchang Dec 9, 2023
2f6c291
typo
ichengchang Dec 9, 2023
4341eb0
Clean up
ichengchang Dec 9, 2023
cf5129b
Bump pact4s from 0.9.0 -> 0.10.0
ichengchang Dec 10, 2023
61721ec
Try Content-type
ichengchang Dec 10, 2023
d9b295e
Revert to Content-Type
ichengchang Dec 10, 2023
01ec364
Revert to 0.9.0
ichengchang Dec 10, 2023
55e6b40
Content-type -> Content-Type
ichengchang Dec 10, 2023
1540216
Merge branch 'develop' into aen_fix_contract_tests
aednichols Dec 11, 2023
3bcd619
Merge branch 'develop' into aen_fix_contract_tests
aednichols Dec 12, 2023
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
57 changes: 47 additions & 10 deletions .github/workflows/consumer_contract_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,25 @@ name: Consumer contract tests
# Consumer kicks off can-i-deploy on process to determine if changes can be promoted and used for deployment.
#
# 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:
- develop
paths-ignore:
- 'README.md'
push:
branches:
- develop
paths-ignore:
- 'README.md'
merge_group:
branches:
- develop

env:
PUBLISH_CONTRACTS_RUN_NAME: 'publish-contracts-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
CAN_I_DEPLOY_RUN_NAME: 'can-i-deploy-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'

jobs:
init-github-context:
runs-on: ubuntu-latest
Expand All @@ -52,6 +59,23 @@ jobs:
steps:
- uses: actions/checkout@v3

# Construct a version string like `87-9c6c439`. Adapted from `chart_update_on_merge.yml`.
- name: Find Cromwell short SHA
run: |
set -e
echo "CROMWELL_SHORT_SHA=`git rev-parse --short $GITHUB_SHA`" >> $GITHUB_ENV
- name: Find Cromwell release number
run: |
set -e
previous_version=$(curl -X GET https://api.github.com/repos/broadinstitute/cromwell/releases/latest | jq .tag_name | xargs)
if ! [[ "${previous_version}" =~ ^[0-9][0-9]+$ ]]; then
exit 1
fi
echo "CROMWELL_NUMBER=$((previous_version + 1))" >> $GITHUB_ENV
- name: Save complete image ID
run: |
echo "CROMWELL_VERSION=`echo "$CROMWELL_NUMBER-$CROMWELL_SHORT_SHA"`" >> $GITHUB_ENV

- name: Extract branch
id: extract-branch
run: |
Expand All @@ -70,9 +94,9 @@ jobs:
fi
echo "CURRENT_BRANCH=${GITHUB_REF/refs\/heads\//""}" >> $GITHUB_ENV
echo "CURRENT_SHA=$GITHUB_SHA" >> $GITHUB_ENV

echo "repo-branch=${GITHUB_REF/refs\/heads\//""}" >> $GITHUB_OUTPUT
echo "repo-version=${GITHUB_SHA}" >> $GITHUB_OUTPUT
echo "repo-version=${CROMWELL_VERSION}" >> $GITHUB_OUTPUT
echo "fork=${FORK}" >> $GITHUB_OUTPUT

- name: Is PR triggered by forked repo?
Expand All @@ -88,7 +112,7 @@ jobs:
echo "repo-version=${{ steps.extract-branch.outputs.repo-version }}"
echo "fork=${{ steps.extract-branch.outputs.fork }}"

cromwell-consumer-contract-tests:
cromwell-contract-tests:
runs-on: ubuntu-latest
needs: [init-github-context]
outputs:
Expand All @@ -109,35 +133,48 @@ jobs:
id: encode-pact
run: |
cd pact4s
NON_BREAKING_B64=$(cat target/pacts/cromwell-consumer-drshub-provider.json | base64 -w 0)
NON_BREAKING_B64=$(cat target/pacts/cromwell-drshub.json | base64 -w 0)
echo "pact-b64=${NON_BREAKING_B64}" >> $GITHUB_OUTPUT

# Prevent untrusted sources from using PRs to publish contracts
# since access to secrets is not allowed.
publish-contracts:
runs-on: ubuntu-latest
if: ${{ needs.init-github-context.outputs.fork == 'false' || needs.init-github-context.outputs.fork == ''}}
needs: [init-github-context, cromwell-consumer-contract-tests]
needs: [init-github-context, cromwell-contract-tests]
steps:
- name: Dispatch to terra-github-workflows
uses: broadinstitute/workflow-dispatch@v3
uses: broadinstitute/workflow-dispatch@v4.0.0
with:
run-name: "${{ env.PUBLISH_CONTRACTS_RUN_NAME }}"
workflow: .github/workflows/publish-contracts.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ secrets.BROADBOT_GITHUB_TOKEN }} # github token for access to kick off a job in the private repo
inputs: '{ "pact-b64": "${{ needs.cromwell-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 }}" }'
inputs: '{
"run-name": "${{ env.PUBLISH_CONTRACTS_RUN_NAME }}",
"pact-b64": "${{ needs.cromwell-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 }}",
"release-tag": "${{ needs.init-github-context.outputs.repo-version }}"
}'

can-i-deploy:
runs-on: ubuntu-latest
if: ${{ needs.init-github-context.outputs.fork == 'false' || needs.init-github-context.outputs.fork == ''}}
needs: [ init-github-context, publish-contracts ]
steps:
- name: Dispatch to terra-github-workflows
uses: broadinstitute/workflow-dispatch@v3
uses: broadinstitute/workflow-dispatch@v4.0.0
with:
run-name: "${{ env.CAN_I_DEPLOY_RUN_NAME }}"
workflow: .github/workflows/can-i-deploy.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ secrets.BROADBOT_GITHUB_TOKEN }} # github token for access to kick off a job in the private repo
inputs: '{ "pacticipant": "cromwell-consumer", "version": "${{ needs.init-github-context.outputs.repo-version }}" }'
inputs: '{
"run-name": "${{ env.CAN_I_DEPLOY_RUN_NAME }}",
"pacticipant": "cromwell",
"version": "${{ needs.init-github-context.outputs.repo-version }}"
}'
3 changes: 1 addition & 2 deletions pact4s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ docker run --rm -v $PWD:/working \
```

The generated contracts can be found in the `./target/pacts` folder
- `cromwell-consumer-drshub-provider.json`
- `cromwell-consumer-fake-provider.json`
- `cromwell-drshub.json`

Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ class DrsHubClientSpec extends AnyFlatSpec with Matchers with RequestResponsePac
}.build

val consumerPactBuilder: ConsumerPactBuilder = ConsumerPactBuilder
.consumer("cromwell-consumer")
.consumer("cromwell")

val pactProvider: PactDslWithProvider = consumerPactBuilder
.hasPactWith("drshub-provider")
.hasPactWith("drshub")

var pactDslResponse: PactDslResponse = buildInteraction(
pactProvider,
Expand All @@ -134,7 +134,7 @@ class DrsHubClientSpec extends AnyFlatSpec with Matchers with RequestResponsePac
uponReceiving = "Request to resolve drs url",
method = "POST",
path = "/api/v4/drs/resolve",
requestHeaders = Seq("Content-type" -> "application/json"),
requestHeaders = Seq("Content-Type" -> "application/json"),
requestBody = resourceRequestDsl,
status = 200,
responseHeaders = Seq(),
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ object Dependencies {
"org.lz4" % "lz4-java" % lz4JavaV
)
val scalaTest = "org.scalatest" %% "scalatest" % scalatestV

val testDependencies: List[ModuleID] = List(
"org.scalatest" %% "scalatest" % scalatestV,
// Use mockito Java DSL directly instead of the numerous and often hard to keep updated Scala DSLs.
Expand Down
Loading