-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #967 from alphagov/add-verfiy-pact-tests-ga
Add GitHub Action workflow for verifying pact tests
- Loading branch information
Showing
3 changed files
with
78 additions
and
7 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
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,71 @@ | ||
# 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 | ||
# Support 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-support_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: | ||
postgres: | ||
image: postgres:13 | ||
ports: ["5432:5432"] | ||
env: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
env: | ||
TEST_DATABASE_URL: postgresql://postgres@localhost/test-db | ||
RAILS_ENV: test | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: alphagov/support-api | ||
ref: ${{ inputs.ref }} | ||
- name: Setup Ruby | ||
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@v4 | ||
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 }} |
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