Skip to content

Playwright

Playwright #1851

Workflow file for this run

name: Tests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
OXA_DB_USER: accounts
OXA_DB_PASS: accounts
OXA_TEST_DB: ci_test
RAILS_ENV: test
HEADLESS: true
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '0 0 * * 0' # weekly
jobs:
tests:
timeout-minutes: 30
runs-on: ubuntu-24.04
services:
postgres:
image: postgres:14
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
POSTGRES_USER: ${{ env.OXA_DB_USER }}
POSTGRES_DB: ${{ env.OXA_TEST_DB }}
POSTGRES_PASSWORD: ${{ env.OXA_DB_PASS }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: yarn
- name: Ensure playwright gem and package.json versions match
run: |
capybara_playwright_version=$(
bundle exec ruby -e 'require "playwright"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip'
)
echo "Playwright version compatible with capybara-playwright-driver: $capybara_playwright_version"
package_json_playwright=$(yarn list --pattern @playwright/test --json | jq '.data.trees[].name | .[17:]' -r)
echo "Playwright version in package.json: $package_json_playwright"
if [[ $ruby_gem_playwright = $package_json_playwright ]]; then
echo 'Versions match'
else
echo "Versions don't match"
exit 1
fi
# https://justin.searls.co/posts/running-rails-system-tests-with-playwright-instead-of-selenium/
- name: Cache Playwright Chromium browser
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Chromium browser (with deps)
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: yarn playwright install --with-deps chromium
- name: Install Playwright Chromium browser deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: yarn playwright install-deps chromium
- name: Test
env:
WORKERS: 4
run: |
bin/rake parallel:setup
bin/rake parallel:spec