From 3842ecdc136a4cc682e7c84c085f3ad7d3a8a8b2 Mon Sep 17 00:00:00 2001 From: Sean Rankine Date: Wed, 11 Jan 2023 11:03:13 +0000 Subject: [PATCH] Make ruby tests a reusable workflow This application depends on the Content Schemas. Making the tests reusable allows Publishing API to run the tests when the Content Schemas are updated. --- .github/workflows/ci.yml | 29 +------------------- .github/workflows/minitest.yml | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/minitest.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1387364a..d6b6e23ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,32 +39,5 @@ jobs: test-ruby: name: Test Ruby - runs-on: ubuntu-latest - steps: - - name: Checkout repository - 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 - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Setup Node - uses: alphagov/govuk-infrastructure/.github/actions/setup-node@main - - - name: Precompile assets - uses: alphagov/govuk-infrastructure/.github/actions/precompile-rails-assets@main - - - name: Run Minitest - env: - RAILS_ENV: test - GOVUK_CONTENT_SCHEMAS_PATH: vendor/publishing-api/content_schemas - run: bundle exec rake test + uses: ./.github/workflows/minitest.yml diff --git a/.github/workflows/minitest.yml b/.github/workflows/minitest.yml new file mode 100644 index 000000000..cc3dcea7e --- /dev/null +++ b/.github/workflows/minitest.yml @@ -0,0 +1,49 @@ +name: Run Minitest + +on: + workflow_call: + inputs: + ref: + description: 'The branch, tag or SHA to checkout' + required: false + type: string + publishingApiRef: + description: 'The branch, tag or SHA to checkout Publishing API' + required: false + default: 'deployed-to-production' + type: string + +jobs: + run-minitest: + name: Run Minitest + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + repository: alphagov/government-frontend + ref: ${{ inputs.ref || github.ref }} + + - name: Checkout Publishing API (for Content Schemas) + uses: actions/checkout@v3 + with: + repository: alphagov/publishing-api + ref: ${{ inputs.publishingApiRef }} + path: vendor/publishing-api + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Setup Node + uses: alphagov/govuk-infrastructure/.github/actions/setup-node@main + + - name: Precompile assets + uses: alphagov/govuk-infrastructure/.github/actions/precompile-rails-assets@main + + - name: Run Minitest + env: + RAILS_ENV: test + GOVUK_CONTENT_SCHEMAS_PATH: vendor/publishing-api/content_schemas + run: bundle exec rake test