pactflow / example-bi-directional-provider-postman

Example provider using Postman collections and PactFlow's bi-directional contracts feature
MIT License
7 stars 46 forks source link

feat: use pact-cli pactflow publish-provider-contract #13

Closed YOU54F closed 2 years ago

YOU54F commented 2 years ago

Improvements to Provider Contract Publishing

https://github.com/pactflow/roadmap/issues/68

The ability to publish a provider contract (such as an OAS) and verification results to Pactflow via a CLI.

pactflow-provider-publish

Original Pages from Docs:-

Step 4 in our BDCT provider testing guide API documentation for call & Example

Example of usage of pact cli pactflow publish-provider-contract command

Steps to use

  1. Download the appropriate CLI version
    • Docker: docker pull pactfoundation/pact-cli:0.50.0.26
  2. Enable Feature to the Docker container.
    • Docker: pass --env PACTFLOW_FEATURES=publish-provider-contract
    • Standalone: set in your shell PACTFLOW_FEATURES=publish-provider-contract
  3. Set up some variables (you can just pass these in directly)
OAS_FILE_PATH?=oas/products.yml
REPORT_FILE_PATH?=output/report.md
REPORT_FILE_CONTENT_TYPE?=text/plain
VERIFIER_TOOL?=dredd

and the usual vars

PACT_BROKER_BASE_URL=
PACT_BROKER_TOKEN=
PACTICIPANT=
VERSION=
BRANCH=
  1. Run the command
  docker run --rm \
   -v "${APPDIR}":/app \
   -w "/app" \
   -e PACT_BROKER_BASE_URL \
   -e PACT_BROKER_TOKEN \
   -e PACTFLOW_FEATURES=publish-provider-contract \
    pactfoundation/pact-cli:0.50.0.26 \
      pactflow publish-provider-contract \
      /app/$OAS_FILE_PATH \
      --provider $PACTICIPANT \
      --provider-app-version $VERSION \
      --branch $BRANCH \
      --content-type application/yaml \
      --verification-exit-code=$1 \
      --verification-results /app/$REPORT_FILE_PATH \
      --verification-results-content-type $REPORT_FILE_CONTENT_TYPE\
      --verifier $VERIFIER_TOOL
bethesque commented 2 years ago

This can be updated to 0.50.0.27 without the PACTFLOW_FEATURES env var now.