Skip to content

Commit

Permalink
Merge pull request #1175 from alphagov/switch-to-github-actions
Browse files Browse the repository at this point in the history
CI Approach with GitHub Actions
  • Loading branch information
kevindew authored Nov 30, 2022
2 parents 2f003aa + 48a37fe commit e8f8f2c
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 110 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
on: [push, pull_request]

jobs:
# This matrix job runs the test suite against multiple Ruby versions
test_matrix:
strategy:
fail-fast: false
matrix:
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: [2.7, '3.0', 3.1]
runs-on: ubuntu-latest
env:
GOVUK_CONTENT_SCHEMAS_PATH: vendor/publishing-api/content_schemas
steps:
- uses: actions/checkout@v3
- name: Checkout Publishing API for content schemas
uses: actions/checkout@v3
with:
repository: alphagov/publishing-api
ref: deployed-to-production
path: vendor/publishing-api
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake

# This job is needed to work around the fact that matrix jobs spawn multiple status checks – i.e. one job per variant.
# The branch protection rules depend on this as a composite job to ensure that all preceding test_matrix checks passed.
# Solution taken from: https://github.saobby.my.eu.orgmunity/t/status-check-for-a-matrix-jobs/127354/3
test:
needs: test_matrix
runs-on: ubuntu-latest
steps:
- run: echo "All matrix tests have passed 🚀"

generate_and_publish_pacts:
needs: test
runs-on: ubuntu-latest
env:
PACT_TARGET_BRANCH: branch-${{ github.ref_name }}
PACT_BROKER_BASE_URL: https://pact-broker.cloudapps.digital
PACT_BROKER_USERNAME: ${{ secrets.GOVUK_PACT_BROKER_USERNAME }}
PACT_BROKER_PASSWORD: ${{ secrets.GOVUK_PACT_BROKER_PASSWORD }}
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec rake pact_test
- run: bundle exec rake pact:publish:branch

account_api_pact:
needs: generate_and_publish_pacts
uses: alphagov/account-api/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

asset_manager_pact:
needs: generate_and_publish_pacts
uses: alphagov/asset-manager/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

collections_pact:
needs: generate_and_publish_pacts
uses: alphagov/collections/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

email_alert_api_pact:
needs: generate_and_publish_pacts
uses: alphagov/email-alert-api/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

imminence_pact:
needs: generate_and_publish_pacts
uses: alphagov/imminence/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

link_checker_api_pact:
needs: generate_and_publish_pacts
uses: alphagov/link-checker-api/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

locations_api_pact:
needs: generate_and_publish_pacts
uses: alphagov/locations-api/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

publishing_api_pact:
needs: generate_and_publish_pacts
uses: alphagov/publishing-api/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

whitehall_pact:
needs: generate_and_publish_pacts
uses: alphagov/whitehall/.github/workflows/pact-verify.yml@main
with:
pact_consumer_version: branch-${{ github.ref_name }}

publish_gem:
needs:
- account_api_pact
- asset_manager_pact
- collections_pact
- email_alert_api_pact
- imminence_pact
- link_checker_api_pact
- locations_api_pact
- publishing_api_pact
- whitehall_pact
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
contents: write
uses: alphagov/govuk-infrastructure/.github/workflows/publish-rubygem.yaml@main
secrets:
GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }}
110 changes: 0 additions & 110 deletions Jenkinsfile

This file was deleted.

6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Rake::TestTask.new("test") do |t|
t.warning = false
end

Rake::TestTask.new("pact_test") do |t|
t.libs << "test"
t.test_files = FileList["test/pacts/**/*_test.rb"]
t.warning = false
end

task default: %i[lint test]

require "pact_broker/client/tasks"
Expand Down

0 comments on commit e8f8f2c

Please sign in to comment.