forked from alphagov/whitehall
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (70 loc) · 2.37 KB
/
pact-verify.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Pact verify workflow
#
# This workflow asserts that Pact contract tests are valid against this
# codebase. It is trigged when changes are made to this project and it
# is explicitly called by GDS API Adapters when changes are made there.
name: Run Pact tests
on:
workflow_call:
inputs:
# The commit / tag of this repo to test against
ref:
required: false
type: string
default: main
# A GitHub Action artifact which contains the pact definition files
# Publishing API calls this action to test new pacts against this
# workflow
pact_artifact:
required: false
type: string
# When using an artifact this is the file path to the pact that is verified
# against
pact_artifact_file_to_verify:
required: false
type: string
default: gds_api_adapters-whitehall_api.json
# Which version of the pacts to use from the Pact Broker service
# This option will be ignored if pact_artifact is set
pact_consumer_version:
required: false
type: string
default: branch-main
jobs:
pact_verify:
name: Verify pact tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
ports: ["3306:3306"]
env:
MYSQL_ROOT_PASSWORD: root
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis
ports: ["6379:6379"]
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
env:
TEST_DATABASE_URL: mysql2://root:[email protected]:3306/test-db
RAILS_ENV: test
steps:
- uses: actions/checkout@v3
with:
repository: alphagov/whitehall
ref: ${{ inputs.ref }}
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec rails db:setup
- if: inputs.pact_artifact == ''
run: bundle exec rake pact:verify
env:
PACT_CONSUMER_VERSION: ${{ inputs.pact_consumer_version }}
- if: inputs.pact_artifact != ''
uses: actions/download-artifact@v3
with:
name: ${{ inputs.pact_artifact }}
path: tmp/pacts
- if: inputs.pact_artifact != ''
run: bundle exec rake pact:verify:at[tmp/pacts/${{ inputs.pact_artifact_file_to_verify }}]