Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action workflow for verifying pact tests #544

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/pact-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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.
on:
pull_request:
push:
workflow_call:
inputs:
# what branch or Git SHA to clone this app with, only applies when
# called as a workflow, so current commit applies to push/pull requests
commitish:
required: false
type: string
default: main
pact_consumer_version:
required: true
type: string

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
redis:
image: redis
ports: ["6379:6379"]
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
env:
PACT_CONSUMER_VERSION: ${{ inputs.pact_consumer_version || 'branch-main' }}
TEST_DATABASE_URL: postgresql://postgres@localhost/test-db
RAILS_ENV: test
steps:
- uses: actions/checkout@v3
with:
repository: alphagov/account-api
ref: ${{ inputs.commitish || github.sha }}
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec rails db:setup
- run: bundle exec rake pact:verify
4 changes: 3 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ library("govuk")

node {
govuk.setEnvar("TEST_DATABASE_URL", "postgresql://postgres@127.0.0.1:54313/account-api-test")
govuk.buildProject()
govuk.buildProject(
overrideTestTask: { sh("bundle exec rake lint spec") }
)
}