Skip to content

Fix feature test #31421

Fix feature test

Fix feature test #31421

Workflow file for this run

name: Test
on:
push:
branches:
- '**'
jobs:
backend-tests:
name: Run RSpec Tests in parallel
runs-on: ubuntu-latest
strategy:
fail-fast: false
env:
DATABASE_URL: postgis://postgres:postgres@localhost:5432
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
services:
postgres:
image: postgis/postgis:14-3.5-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
# Need depth 0 for undercover to work properly. Yes, we tried otherwise.
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Prepare application environment
uses: ./.github/actions/prepare-app-env
- name: Set up test database
run: bundle exec rake db:create db:schema:load parallel:create parallel:load_schema
- name: Cache Swagger docs
uses: actions/cache@v5
id: swagger-cache
with:
path: swagger
key: ${{ runner.os }}-swagger-${{ hashFiles('spec/swagger_helper.rb', 'spec/requests/publishers/ats_api/v1/**', 'app/controllers/publishers/ats_api/v1/**') }}
restore-keys: |
${{ runner.os }}-swagger-
- name: Generate Swagger (OpenAPI) docs
if: steps.swagger-cache.outputs.cache-hit != 'true'
run: bundle exec rake rswag:specs:swaggerize
- name: Cache precompiled assets
uses: actions/cache@v5
id: assets-cache
with:
path: |
public/assets
tmp/cache/assets
key: ${{ runner.os }}-assets-${{ hashFiles('app/assets/stylesheets/**/*', 'app/assets/javascript/**/*', 'app/assets/images/**/*', 'app/components/**/*.scss', 'config/initializers/assets.rb', 'esbuild.config.js', 'yarn.lock') }}
restore-keys: |
${{ runner.os }}-assets-
- name: Precompile assets
if: steps.assets-cache.outputs.cache-hit != 'true'
run: bin/rails assets:precompile
- name: Cache Test Runtimes
uses: actions/cache@v5
with:
path: "tmp/parallel_runtime_rspec.log"
key: ${{ runner.os }}-spec-${{ hashFiles('spec/**/*spec.rb') }}
restore-keys: |
${{ runner.os }}-spec-
- name: Run tests in parallel
env:
PARALLEL_TEST_PROCESSORS: 4 # Match GitHub Action runner CPU count
PARALLEL_TEST_FIRST_IS_1: true
COVERAGE: 1
run: bundle exec rake parallel:spec
# Tests may fail due to lack of coverage, so always run coverage upload and checks
# to help diagnose issues
- name: Upload Coverage report
uses: actions/upload-artifact@v6
if: always()
with:
name: coverage report
path: coverage
- name: Check coverage
if: always()
run: bundle exec undercover -c origin/main
- name: Upload Capybara failures screenshots
if: failure()
uses: actions/upload-artifact@v6
with:
name: capybara-screenshots
path: /home/runner/work/teaching-vacancies/teaching-vacancies/tmp/capybara/*.png
if-no-files-found: ignore # If only non-capybara tests fail there will be no screenshots
frontend-tests:
name: Run frontend JS unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Prepare application environment
uses: ./.github/actions/prepare-app-env
with:
skip-ruby: true
- name: run frontend tests and linting
run: yarn run js:test