Skip to content

nathandeamer/pact-order

Repository files navigation

PACT Provider example

Setup:

  1. Get (and set) your PACT environment variables by clicking 'Copy Env Vars' for Read/write token (CI).
    (used in pact section of build.gradle)
export PACT_BROKER_BASE_URL=https://[user].pactflow.io
export PACT_BROKER_TOKEN=NotMyRealBrokerToken
  1. Create dev, staging and prod environments in pactflow Pact Environments Remember to mark 'prod' as a Production environment when asked.
  2. Download the standalone pact-cli and add to your $PATH export PATH=$HOME/bin/pact/bin:$PATH or via brew

Run (No publish) the provider tests:

  1. /gradlew clean pactTest --tests "*ProviderPactTest"

Run and Publish the results of the provider tests:

  1. ./gradlew clean -DpactPublishResults=true test --tests "*ProviderPactTest"
    The provider version and branch are also set. See test section of build.gradle

Can I deploy

Choose one of the following options:

  1. gradle: At time of writing the pact gradle canIDeploy task does not support branches and environments.
  2. pact-cli: pact-broker can-i-deploy --pacticipant=$(basename `git rev-parse --show-toplevel`) --version=$(git rev-parse HEAD) --branch=$(git rev-parse --abbrev-ref HEAD) --to-environment=dev
    ** Remember to replace the --to-environment with the environment you want to check if you can deploy too.

To get can-i-deploy to pass you need to make sure all consumer tests have passed. See pact-mobile-app

Record a deployment

After the provider tests have passed and the service has been deployed to an environment we should record a deployment

Choose one of the following options:

  1. gradle: At time of writing the pact gradle plugin does not support recording a deployment
  2. pact-cli: pact-broker record-deployment --pacticipant=$(basename `git rev-parse --show-toplevel`) --version=$(git rev-parse HEAD) --environment=dev

Pact Record Deployment

Record a release

When a version has been deployed to production we should record a release.

  1. gradle: At time of writing the pact gradle plugin does not support recording a deployment
  2. pact-cli: pact-broker record-release --pacticipant=$(basename `git rev-parse --show-toplevel`) --version=$(git rev-parse HEAD) --environment=prod

Pact Record Release

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published