Skip to content

Commit

Permalink
Merge pull request #3831 from alphagov/pp_12573_pacts_in_github_actions
Browse files Browse the repository at this point in the history
PP-12573 Run pact tests on PRs with GitHub actions
  • Loading branch information
kbottla authored May 13, 2024
2 parents 38fc05e + f5191dd commit b147960
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 186 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/_run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Github Actions Tests

on:
workflow_call:
secrets:
pact_broker_username:
required: true
pact_broker_password:
required: true

permissions:
contents: read

jobs:
detect-secrets:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: Detect secrets
uses: alphagov/pay-ci/actions/detect-secrets@master

install-and-compile:
name: "Install and compile"
uses: alphagov/pay-ci/.github/workflows/_run-node-install-and-compile.yml@master
with:
has_cypress_tests: true

tests:
name: "Unit tests and pacts"
needs: [ install-and-compile ]
uses: alphagov/pay-ci/.github/workflows/_run-node-unit-tests-and-publish-pacts.yml@master
with:
publish_pacts: true
secrets:
pact_broker_username: ${{ secrets.pact_broker_username }}
pact_broker_password: ${{ secrets.pact_broker_password }}

cypress-tests:
name: "Cypress"
needs: [ install-and-compile ]
uses: alphagov/pay-ci/.github/workflows/_run-node-cypress-tests.yml@master

pact-providers-contract-tests:
name: "Provider tests"
needs: tests
uses: alphagov/pay-ci/.github/workflows/_run-provider-pact-tests-for-consumer.yml@master
strategy:
matrix:
provider: [ 'connector' ]
with:
consumer: "frontend"
provider: ${{ matrix.provider }}
secrets:
pact_broker_username: ${{ secrets.pact_broker_username }}
pact_broker_password: ${{ secrets.pact_broker_password }}

check-docker-base-images-are-manifests:
uses: alphagov/pay-ci/.github/workflows/_validate_docker_image_is_manifest.yml@master
48 changes: 2 additions & 46 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,14 @@ concurrency: frontend-post-merge

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

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

name: Publish and tag frontend consumer pact
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: Parse Node version
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: parse-node-version
- name: Setup
uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381
with:
node-version: "${{ steps.parse-node-version.outputs.NVMRC }}"
- name: Cache build directories
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: |
node_modules
govuk_modules
public
key: ${{ runner.os }}-build-id-${{ github.head_ref }}-${{ github.sha }}
- name: Cache pacts directory
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
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://pact-broker.deploy.payments.service.gov.uk
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
uses: ./.github/workflows/_run-tests.yml
secrets:
pact_broker_username: ${{ secrets.pact_broker_username }}
pact_broker_password: ${{ secrets.pact_broker_password }}

tag-release:
needs:
- connector-provider-contract-tests
- tests
permissions:
contents: write
uses: alphagov/pay-ci/.github/workflows/_create-alpha-release-tag.yml@master
14 changes: 14 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: PR

on:
pull_request:

permissions:
contents: read

jobs:
tests:
uses: ./.github/workflows/_run-tests.yml
secrets:
pact_broker_username: ${{ secrets.pact_broker_username }}
pact_broker_password: ${{ secrets.pact_broker_password }}
140 changes: 0 additions & 140 deletions .github/workflows/run-tests.yml

This file was deleted.

0 comments on commit b147960

Please sign in to comment.