-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add BDCT workflow to showcase with CDCT
- Loading branch information
Showing
2 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Provider Design Feedback | ||
|
||
# Create/Edit OpenAPI Document in SwaggerHub or store OpenAPI document locally in env.oas_file_location below | ||
# Sync OpenAPI -> SCM with Github Sync - https://support.smartbear.com/swaggerhub/docs/integrations/github-sync.html | ||
# Version number = <OAS Version>-<GitHub Commit SHA>-design | ||
# OpenAPI + Provider Test Report = Provider Contract Uploaded to Pactflow | ||
# *** Test Report is just OAS file, as the design will not be tested against an API mock or real implementation at this stage *** | ||
# Pactflow compares OpenAPI against any registered consumers | ||
# Visiblity into affected consumers visible via can-i-deploy | ||
|
||
on: | ||
push: | ||
branches: ['design-candidate*','swaggerhub*', 'main'] | ||
paths: | ||
- 'oas/**' | ||
pull_request: | ||
branches: ['main'] | ||
paths: | ||
- 'oas/**' | ||
|
||
workflow_dispatch: | ||
|
||
env: | ||
oas_file_location: oas/openapi.yaml | ||
application_name: pactflow-example-provider | ||
PACT_BROKER_BASE_URL: https://saflow.pactflow.io | ||
PACT_BROKER_TOKEN: ${{ secrets.PACTFLOW_TOKEN_FOR_CI_CD_WORKSHOP }} | ||
|
||
jobs: | ||
pact-publish-oas-action: | ||
# Remove the following condition to run this on your own fork | ||
if: github.owner == 'pactflow' | ||
# This workflow is disabled by default to allow users to run the Consumer-Driven Contract | ||
# testing workshop without distraction. By removing the condition, this workflow will | ||
# upload an OpenAPI Design candidate showcasing Bi-Directional Contract testing | ||
# working alongside Bi-Directional Contract Testing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: get version of OAS | ||
run: | | ||
sudo snap install yq | ||
UNIQUE_VERSION=$(yq '.info.version' ${{ env.oas_file_location }})-${{ github.sha }}-design | ||
echo "version=${UNIQUE_VERSION}" >> $GITHUB_ENV | ||
- name: publishing ${{ env.application_name }} with ${{ env.version }} to Pactflow | ||
uses: pactflow/actions/publish-provider-contract@v1.0.1 | ||
env: | ||
oas_file: ${{ env.oas_file_location }} | ||
results_file: ${{ env.oas_file_location }} | ||
outputs: | ||
version: ${{ env.version }} | ||
|
||
pact-can-i-deploy: | ||
strategy: | ||
matrix: | ||
environment: [test, production] | ||
fail-fast: false | ||
needs: pact-publish-oas-action | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: can-i-deploy ${{ env.application_name }} to ${{ matrix.environment }} | ||
uses: pactflow/actions/can-i-deploy@v1.0.1 | ||
env: | ||
to_environment: ${{ matrix.environment }} | ||
version: ${{ needs.pact-publish-oas-action.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: Product API | ||
description: Pactflow Product API demo | ||
version: 1.0.0 | ||
servers: | ||
- url: / | ||
paths: | ||
/products: | ||
get: | ||
summary: List all products | ||
description: Returns all products | ||
operationId: getAllProducts | ||
responses: | ||
"200": | ||
description: successful operation | ||
content: | ||
application/json;charset=utf-8: | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Product' | ||
examples: | ||
application/json: | ||
value: | ||
- id: "1234" | ||
type: food | ||
price: 42 | ||
"400": | ||
description: Invalid ID supplied | ||
content: {} | ||
post: | ||
summary: Create a product | ||
description: Creates a new product | ||
operationId: createProduct | ||
requestBody: | ||
description: Create a new Product | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Product' | ||
examples: | ||
application/json: | ||
value: | ||
id: "1234" | ||
type: food | ||
price: 42 | ||
name: burger | ||
required: true | ||
responses: | ||
"200": | ||
description: successful operation | ||
content: | ||
application/json;charset=utf-8: | ||
schema: | ||
$ref: '#/components/schemas/Product' | ||
examples: | ||
application/json: | ||
value: | ||
id: "1234" | ||
type: food | ||
price: 42 | ||
name: burger | ||
/product/{id}: | ||
get: | ||
summary: Find product by ID | ||
description: Returns a single product | ||
operationId: getProductByID | ||
parameters: | ||
- name: id | ||
in: path | ||
description: ID of product to get | ||
required: true | ||
style: simple | ||
explode: false | ||
schema: | ||
type: string | ||
example: 10 | ||
responses: | ||
"200": | ||
description: successful operation | ||
content: | ||
application/json;charset=utf-8: | ||
schema: | ||
$ref: '#/components/schemas/Product' | ||
examples: | ||
application/json: | ||
value: | ||
id: "1234" | ||
type: food | ||
price: 42 | ||
"400": | ||
description: Invalid ID supplied | ||
content: {} | ||
"404": | ||
description: Product not found | ||
content: {} | ||
components: | ||
schemas: | ||
Product: | ||
required: | ||
- id | ||
- name | ||
- price | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
type: | ||
type: string | ||
name: | ||
type: string | ||
version: | ||
type: string | ||
price: | ||
type: number |