use playwright instead of selenium #1609
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Ruby on Rails CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }}-test | |
cancel-in-progress: true | |
timeout-minutes: 2 | |
services: | |
postgres: | |
image: postgres:16.1 | |
ports: | |
- "5432:5432" | |
env: | |
POSTGRES_DB: hostedgpt_test | |
POSTGRES_USER: rails | |
POSTGRES_PASSWORD: password | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
env: | |
RAILS_ENV: test | |
DATABASE_URL: "postgres://rails:password@localhost:5432/hostedgpt_test" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Set up database schema | |
run: bin/rails db:prepare | |
- name: Build CSS | |
run: bin/rails tailwindcss:build | |
- name: Run tests | |
run: bin/rails test | |
system_tests: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }}-system | |
cancel-in-progress: true | |
services: | |
postgres: | |
image: postgres:16.1 | |
ports: | |
- "5432:5432" | |
env: | |
POSTGRES_DB: hostedgpt_test | |
POSTGRES_USER: rails | |
POSTGRES_PASSWORD: password | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
env: | |
RAILS_ENV: test | |
DATABASE_URL: "postgres://rails:password@localhost:5432/hostedgpt_test" | |
DISPLAY: "=:99" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Set Playwright version env var | |
run: | | |
PLAYWRIGHT_CLI_VERSION=$(bundle exec ruby -e 'require "playwright"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip') | |
echo "PLAYWRIGHT_CLI_VERSION=$PLAYWRIGHT_CLI_VERSION" >> $GITHUB_ENV | |
- name: Print Playwright version (DEBUG) | |
run: echo 'playwright version:'; echo $PLAYWRIGHT_CLI_VERSION | |
- name: Install playwright | |
run: npx playwright@${{ env.PLAYWRIGHT_CLI_VERSION }} install | |
- name: Cache Playwright Chromium browser | |
id: playwright-cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/ms-playwright | |
key: playwright-browsers-${{ runner.os }}-${{ env.PLAYWRIGHT_CLI_VERSION }} | |
- name: Install Playwright Chromium browser (with deps) | |
if: steps.playwright-cache.outputs.cache-hit != 'true' | |
run: npx playwright@${{ env.PLAYWRIGHT_CLI_VERSION }} install --with-deps chromium | |
- name: Install Playwright Chromium browser deps | |
if: steps.playwright-cache.outputs.cache-hit == 'true' | |
run: npx playwright@${{ env.PLAYWRIGHT_CLI_VERSION }} install-deps chromium | |
- name: Set up database schema | |
run: bin/rails db:prepare | |
- name: Build CSS | |
run: bin/rails tailwindcss:build | |
- name: Run system tests | |
run: | | |
echo -e "###\n###\n###\n### NOTICE: If these tests fail because of Net::ReadTimeout then re-run the test suite. I can't figure out this sporadic failure.\n###\n###\n###" | |
sed -i 's/hoverOnlyWhenSupported: true/hoverOnlyWhenSupported: false/' config/tailwind.config.js | |
bin/rails test:system | |
- name: Upload screenshots | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: System Test Screenshots | |
path: tmp/screenshots/ | |
if-no-files-found: ignore | |
lint: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }}-lint | |
cancel-in-progress: true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Lint Ruby files | |
run: bin/rubocop |