Skip to content

Commit

Permalink
PP-9238: Frontend build post merge to master (#2738)
Browse files Browse the repository at this point in the history
* PP-9238: Frontend build post merge to master

On a post merge to master:
- publish the pact
- run frontend as consumer pact test

Co-authored-by: Jonathan Harden <[email protected]>
Co-authored-by: Kat Stevens <[email protected]>
  • Loading branch information
3 people authored Mar 14, 2022
1 parent d342697 commit af49a78
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Post Merge

on:
push:
branches:
- master

permissions:
contents: read

jobs:
tests:
uses: ./.github/workflows/run-tests.yml

publish-frontend-consumer-contract-tests:
needs: tests
runs-on: ubuntu-18.04

name: Publish and tag frontend consumer pact
steps:
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
- name: Parse Node version
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: parse-node-version
- name: Setup
uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a
with:
node-version: "${{ steps.parse-node-version.outputs.NVMRC }}"
- name: Cache build directories
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
with:
path: |
node_modules
govuk_modules
public
key: ${{ runner.os }}-build-id-${{ github.head_ref }}-${{ github.sha }}
- name: Cache pacts directory
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
with:
path: pacts
key: ${{ runner.os }}-build-id-${{ github.head_ref }}-${{ github.sha }}-pacts
- name: Publish and tag frontend consumer pact
env:
PACT_BROKER_URL: https://pay-pact-broker.cloudapps.digital
PACT_CONSUMER_VERSION: ${{ github.sha }}
PACT_BROKER_USERNAME: ${{ secrets.pact_broker_username }}
PACT_BROKER_PASSWORD: ${{ secrets.pact_broker_password }}
PACT_CONSUMER_TAG: master
run: npm run publish-pacts

connector-provider-contract-tests:
needs: publish-frontend-consumer-contract-tests
uses: alphagov/pay-connector/.github/workflows/_run-pact-provider-tests.yml@master
with:
consumer: frontend
consumer_tag: master
secrets:
pact_broker_username: ${{ secrets.pact_broker_username }}
pact_broker_password: ${{ secrets.pact_broker_password }}
9 changes: 6 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Github Actions Tests

on:
push:
branches:
- master
workflow_call:
pull_request:

permissions:
Expand Down Expand Up @@ -76,6 +74,11 @@ jobs:
govuk_modules
public
key: ${{ runner.os }}-build-id-${{ github.head_ref }}-${{ github.sha }}
- name: Cache pacts directory
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
with:
path: pacts
key: ${{ runner.os }}-build-id-${{ github.head_ref }}-${{ github.sha }}-pacts
- name: Run unit tests
run: npm test -- --forbid-only --forbid-pending

Expand Down
1 change: 1 addition & 0 deletions bin/publish-pacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async function run () {
await publish()
} catch (e) {
console.log('Unable to publish pacts', e)
throw e
}
}

Expand Down

0 comments on commit af49a78

Please sign in to comment.