Skip to content

Commit

Permalink
Merge pull request #2421 from DFE-Digital/AQTS-592-update-github-acti…
Browse files Browse the repository at this point in the history
…ons-rspec-parallel

Update GitHub Actions workflow to run RSpec system and other tests in…
  • Loading branch information
Hassanmir92 authored Oct 1, 2024
2 parents 64daecd + f3be113 commit 43984a3
Showing 1 changed file with 59 additions and 7 deletions.
66 changes: 59 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
snyk-token: ${{ steps.key-vault-secrets.outputs.SNYK-TOKEN }}

rspec:
name: Rspec
rspec_system:
name: Rspec System
runs-on: ubuntu-latest

services:
Expand Down Expand Up @@ -111,12 +111,64 @@ jobs:
run: bin/bundle exec rails dfe:analytics:check

- name: Run tests
run: bin/test
run: bundle exec rspec spec/system --format documentation --tag ~smoke_test

rspec_other:
name: Rspec Other
runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-retries 5
--health-timeout 5s
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/apply_for_qts_test
RAILS_ENV: test
REDIS_URL: redis://localhost:6379/0

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare application environment
uses: ./.github/actions/prepare-app-env

- name: Build frontend
run: yarn build && yarn build:css

- name: Setup DB
run: bin/rails db:test:prepare

- name: Run DfE Analytics
run: bin/bundle exec rails dfe:analytics:check

- name: Run tests
run: bundle exec rspec spec/lib spec/forms spec/models spec/view_objects spec/components spec/controllers spec/policies spec/helpers spec/validators spec/jobs spec/mailers spec/views spec/requests spec/services --format documentation

deploy_review:
name: Deploy to review environment
concurrency: deploy_review_${{ github.event.pull_request.number }}
needs: [docker, rspec]
needs: [docker, rspec_system, rspec_other]
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'deploy')
environment: review
Expand All @@ -141,7 +193,7 @@ jobs:
deploy_non_production:
name: Deploy to ${{ matrix.environment }} environment
runs-on: ubuntu-latest
needs: [docker, rspec]
needs: [docker, rspec_system, rspec_other]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
concurrency: deploy_${{ matrix.environment }}
strategy:
Expand All @@ -166,7 +218,7 @@ jobs:

deploy_production:
name: Deploy to production environment
needs: [docker, rspec, deploy_non_production]
needs: [docker, rspec_system, rspec_other, deploy_non_production]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
environment:
Expand All @@ -191,7 +243,7 @@ jobs:
environment: development

if: ${{ failure() && github.ref == 'refs/heads/main' && github.event_name == 'push' }}
needs: [docker, rspec, deploy_non_production]
needs: [docker, rspec_system, rspec_other, deploy_non_production]

steps:
- uses: actions/checkout@v4
Expand Down

0 comments on commit 43984a3

Please sign in to comment.