From 4e4e81ef582725b115dd727a98ca9172ea89001a Mon Sep 17 00:00:00 2001 From: Shujat Khalid Date: Mon, 30 Sep 2024 10:08:07 +0100 Subject: [PATCH 1/3] Update GitHub Actions workflow to run RSpec system and other tests in parallel --- .github/workflows/deploy.yml | 64 ++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3f64db5599..9f8af19c3a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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: @@ -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_others: + name: Rspec Others + 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_others] runs-on: ubuntu-latest if: contains(github.event.pull_request.labels.*.name, 'deploy') environment: review @@ -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_others] if: github.ref == 'refs/heads/main' && github.event_name == 'push' concurrency: deploy_${{ matrix.environment }} strategy: @@ -166,7 +218,7 @@ jobs: deploy_production: name: Deploy to production environment - needs: [docker, rspec, deploy_non_production] + needs: [docker, rspec_system, rspec_others, deploy_non_production] runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' && github.event_name == 'push' environment: From b92bccaf9bdeffb54823ed6ce7a199361fe37736 Mon Sep 17 00:00:00 2001 From: Shujat Khalid Date: Mon, 30 Sep 2024 10:17:45 +0100 Subject: [PATCH 2/3] run notify_slack_of_failures after both rspec jobs --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9f8af19c3a..a36a7f2682 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -243,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_others, deploy_non_production] steps: - uses: actions/checkout@v4 From f3be1135b2937b30363d1b45a36730674ca74134 Mon Sep 17 00:00:00 2001 From: Shujat Khalid Date: Mon, 30 Sep 2024 10:46:51 +0100 Subject: [PATCH 3/3] slight change to test name --- .github/workflows/deploy.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a36a7f2682..bde4564848 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -113,8 +113,8 @@ jobs: - name: Run tests run: bundle exec rspec spec/system --format documentation --tag ~smoke_test - rspec_others: - name: Rspec Others + rspec_other: + name: Rspec Other runs-on: ubuntu-latest services: @@ -168,7 +168,7 @@ jobs: deploy_review: name: Deploy to review environment concurrency: deploy_review_${{ github.event.pull_request.number }} - needs: [docker, rspec_system, rspec_others] + needs: [docker, rspec_system, rspec_other] runs-on: ubuntu-latest if: contains(github.event.pull_request.labels.*.name, 'deploy') environment: review @@ -193,7 +193,7 @@ jobs: deploy_non_production: name: Deploy to ${{ matrix.environment }} environment runs-on: ubuntu-latest - needs: [docker, rspec_system, rspec_others] + needs: [docker, rspec_system, rspec_other] if: github.ref == 'refs/heads/main' && github.event_name == 'push' concurrency: deploy_${{ matrix.environment }} strategy: @@ -218,7 +218,7 @@ jobs: deploy_production: name: Deploy to production environment - needs: [docker, rspec_system, rspec_others, 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: @@ -243,7 +243,7 @@ jobs: environment: development if: ${{ failure() && github.ref == 'refs/heads/main' && github.event_name == 'push' }} - needs: [docker, rspec_system, rspec_others, deploy_non_production] + needs: [docker, rspec_system, rspec_other, deploy_non_production] steps: - uses: actions/checkout@v4