pactflow / example-provider

An example of a provider that uses Pact+PactFlow to honour a consumer driven contract with its consumer
MIT License
19 stars 502 forks source link

BDCT/CDCT Dual Workflow + Design Candidate Demonstration #33

Closed YOU54F closed 1 year ago

YOU54F commented 1 year ago

Showcase Consumer-Driven & Bi-Directional Contract Testing working together.

The main aim of this workflow is to show how BDCT/CDCT can be used to the same consumer/provider pair, provide a dual safety net.

It also provides a secondary function, which is to show how you can utilise an OpenAPI specification, to get early feedback at design-time, and for the best authoring experience, storing the OpenAPI spec master in SwaggerHub, and syncing it back to this project

  1. This PR includes a GitHub Actions workflow ./github/workflows/ProviderDesignFeedback.yml
  2. Changes in oas/** folder are detected, on swaggerhub* branch or design-candidate
  3. oas/openapi.yaml is uploaded to Pactflow, as pactflow-example-provider representing our Product Provider API with a unique version number consisting of the OpenAPI Version + Commit SHA + design
  4. The specification is checked against any deployed or released consumers and their respective head of the main branches, registered with the provider.
  5. Feedback is provided in the can-i-deploy tool

This can also be linked up with SwaggerHub

  1. Sync OpenAPI -> SCM with Github Sync - https://support.smartbear.com/swaggerhub/docs/integrations/github-sync.html
    1. Open the API page in SwaggerHub.
    2. Click the API name, switch to the Integrations tab, and click Add New Integrations:
    3. Select GitHub Sync.
    4. In the subsequent dialog, specify the integration parameters:
      1. Name – Required. A display name for the integration. gh-design-to-pactflow
      2. GitHub Token – Required. The GitHub access token that SwaggerHub will use to access the target GitHub repository.
      3. The easiest way to get the token is to click Connect to GitHub and allow SwaggerHub to retrieve information from your GitHub account:
      4. Click Next in the GitHub Token edit box to continue. SwaggerHub will validate the token and then display other parameters.
      5. Repository Owner – Select you GitHub user or organization that owns the repository where you forked this example provider project
      6. Repository – Select the forked example-provider project
    5. Sync Method – Select the synchronization type: Basic Sync
    6. Branch – Required. The repository branch to push the code to. If this branch does not exist, it will be created based on the repository’s default branch. Choose swaggerhub
    7. Generated API Code – Required. Select what you want to generate: YAML(Resolved)
    8. Output Folder - Select oas
    9. Output File - Select openapi.yaml
    10. Click Create And Execute -> Done.