|
8 | 8 |
|
9 | 9 | This is an example of a Node consumer using Pact to create a consumer driven contract, and sharing it via [Pactflow](https://pactflow.io).
|
10 | 10 |
|
11 |
| -It is using a public tenant on Pactflow, which you can access [here](https://test.pact.dius.com.au) using the credentials `dXfltyFMgNOFZAxr8io9wJ37iUpY42M`/`O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1`. The latest version of the Example Consumer/Example Provider pact is published [here](https://test.pact.dius.com.au/pacts/provider/pactflow-example-provider/consumer/pactflow-example-consumer/latest). |
| 11 | +It implements a "Product" website, to demonstrate the new bi-directional contract capability of Pactflow (previously referred to as Provider driven contracts, or collaborative contracts). See the [Provider](https://github.com/pactflow/example-collaborative-contracts-provider) counterpart. |
12 | 12 |
|
13 |
| -The project uses a Makefile to simulate a very simple build pipeline with two stages - test and deploy. |
14 | 13 |
|
15 |
| -* Test |
16 |
| - * Run tests (including the pact tests that generate the contract) |
17 |
| - * Publish pacts, tagging the consumer version with the name of the current branch |
18 |
| - * Check if we are safe to deploy to prod (ie. has the pact content been successfully verified) |
19 |
| -* Deploy (only from master) |
20 |
| - * Deploy app (just pretend for the purposes of this example!) |
21 |
| - * Tag the deployed consumer version as 'prod' |
| 14 | +It is using a public tenant on Pactflow, which you can access [here](https://test.pact.dius.com.au) using the credentials `dXfltyFMgNOFZAxr8io9wJ37iUpY42M`/`O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1`. The latest version of the Example Consumer/Example Provider pact is published [here](https://test.pact.dius.com.au/pacts/provider/pactflow-example-collaborative-contracts-provider/consumer/pactflow-example-consumer/latest). |
22 | 15 |
|
| 16 | +In the following diagram, you can see how the consumer testing process works - it's the same as the current Pact process! (We do show an alternative using Nock's record/replay functionality) |
| 17 | + |
| 18 | +When we call "can-i-deploy" the cross-contract validation process kicks off on Pactflow, to ensure any consumer consumes a valid subset of the OAS for the provider. |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +When you run the CI pipeline (see below for doing this), the pipeline should perform the following activities (simplified): |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +## Pre-requisites |
| 27 | + |
| 28 | +**Software**: |
| 29 | + |
| 30 | +* Tools listed at: https://docs.pactflow.io/docs/workshops/ci-cd/set-up-ci/prerequisites/ |
| 31 | +* A pactflow.io account with an valid [API token](https://docs.pactflow.io/docs/getting-started/#configuring-your-api-token) |
| 32 | + |
| 33 | +### Environment variables |
| 34 | + |
| 35 | +To be able to run some of the commands locally, you will need to export the following environment variables into your shell: |
| 36 | + |
| 37 | +* `PACT_BROKER_TOKEN`: a valid [API token](https://docs.pactflow.io/docs/getting-started/#configuring-your-api-token) for Pactflow |
| 38 | +* `PACT_BROKER_BASE_URL`: a fully qualified domain name with protocol to your pact broker e.g. https://testdemo.pactflow.io |
| 39 | +* `PACT_PROVIDER=collaborative-contracts-provider`: this changes the default provider |
23 | 40 | ## Usage
|
24 | 41 |
|
25 |
| -See the [Pactflow CI/CD Workshop](https://github.com/pactflow/ci-cd-workshop). |
| 42 | +### Pact use case |
| 43 | + |
| 44 | +* `make test` - run the pact test locally |
| 45 | +* `make fake_ci` - run the CI process locally |
| 46 | + |
| 47 | +### Nock (record/replay example) |
| 48 | + |
| 49 | +* `make clean` - ensure previous pacts are cleared |
| 50 | +* `make test_nock` - run the nock test locally |
| 51 | +* `make fake_ci_nock` - run the nock version of the CI process locally |
0 commit comments