Skip to content

Commit

Permalink
Create project, add server with endpoints for health readiness and 10…
Browse files Browse the repository at this point in the history
… test endpoints. Include pact consumer/provider tests, swagger-codegen, github workflows
  • Loading branch information
matthewmurphy committed May 22, 2024
1 parent 6fe4cb1 commit 3230baa
Show file tree
Hide file tree
Showing 21 changed files with 4,383 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CI build

on:
push:
branches: ["main"]
pull_request:

workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: "npm"
node-version-file: ".nvmrc"

- name: NPM install
run: npm install

- name: Compile to JavaScript
run: npm run build

- name: Pact - Run consumer tests
run: npm run pact:consumer

- name: Pact - Provider verify local pacts
run: npm run pact:provider
env:
BRANCH_NAME: ${{ github.ref }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

- name: Pact - Publish consumer pacts
run: npm run pact:publish-consumer
env:
BRANCH_NAME: ${{ github.ref }}
PACT_BROKER_URL: ${{ vars.PACT_BROKER_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

- name: Pact - Provider verify PactFlow pacts
run: npm run pact:provider
env:
BRANCH_NAME: ${{ github.ref }}
PACT_BROKER_URL: ${{ vars.PACT_BROKER_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
USE_PACTFLOW: true
PUBLISH_VERIFICATION_RESULTS: false

- name: Pact - Can-i-deploy - Provider
run: npm run pact:can-i-deploy-provider
env:
BRANCH_NAME: ${{ github.ref }}
PACT_BROKER_URL: ${{ vars.PACT_BROKER_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

- name: Pact - Record release - Provider
run: npm run pact:release-provider
if: ${{ github.ref == 'refs/heads/main' }}
env:
BRANCH_NAME: ${{ github.ref }}
PACT_BROKER_URL: ${{ vars.PACT_BROKER_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

- name: Pact - Can-i-deploy - Consumer
run: npm run pact:can-i-deploy-consumer
if: ${{ github.ref == 'refs/heads/main' }}
env:
BRANCH_NAME: ${{ github.ref }}
PACT_BROKER_URL: ${{ vars.PACT_BROKER_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

- name: Pact - Record release - Consumer
run: npm run pact:release-consumer
if: ${{ github.ref == 'refs/heads/main' }}
env:
BRANCH_NAME: ${{ github.ref }}
PACT_BROKER_URL: ${{ vars.PACT_BROKER_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
66 changes: 66 additions & 0 deletions .github/workflows/contract_requiring_verification_published.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: contract_requiring_verification_published

# This workflow leverages the https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event webhook

on:
repository_dispatch:
types:
- contract_requiring_verification_published
workflow_dispatch:
inputs:
PACT_URL:
description: URL of pact to verify
required: true
PACT_BROKER_URL:
required: true
PACT_BROKER_PUBLISH_VERIFICATION_RESULTS:
required: true
GIT_COMMIT:
required: true
GIT_BRANCH:
required: true
DESCRIPTION:
required: true

jobs:
verify-contract-requiring-verification:
runs-on: ubuntu-latest
steps:
- name: event
run: echo "${{github.event}}"
- name: pact_url
run: echo "${{github.event.client_payload.pact_url}}"
- name: sha
run: echo "${{github.event.client_payload.sha}}"
- name: branch
run: echo "${{github.event.client_payload.branch}}"
- name: description
run: echo "${{github.event.client_payload.message}}"

- name: checkout specific SHA if webhook providers pact URL
uses: actions/checkout@v4
if: ${{ github.event.client_payload.pact_url }}
with:
ref: ${{ env.client_payload.sha }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: "npm"
node-version-file: ".nvmrc"

- name: NPM install
run: npm install

- name: Compile to JavaScript
run: npm run build

- name: Pact - Provider verify pact from webhook
run: npm run pact:provider
env:
USE_PACTFLOW: true
PACT_URL: ${{ github.event.client_payload.pact_url }}
BRANCH_NAME: ${{ github.ref }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
PROVIDER_VERSION: ${{ github.event.client_payload.sha }}
PUBLISH_VERIFICATION_RESULTS: true
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
out/
coverage/
dist/
gen/
charts/**/*.tgz

# macOS
.DS_Store
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
Loading

0 comments on commit 3230baa

Please sign in to comment.