From 1e3bb339cb2ed7e05b071ef7d044c668bdc2da31 Mon Sep 17 00:00:00 2001 From: Dante Soares Date: Fri, 18 Oct 2024 18:44:21 -0500 Subject: [PATCH] Updated GH actions OS versions, install Playwright in CI --- .github/workflows/assets.yml | 6 ++---- .github/workflows/migrations.yml | 4 ++-- .github/workflows/tests.yml | 25 ++++++++++++++++++++----- package.json | 2 +- yarn.lock | 2 +- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.github/workflows/assets.yml b/.github/workflows/assets.yml index b4e73cae9..93b949235 100644 --- a/.github/workflows/assets.yml +++ b/.github/workflows/assets.yml @@ -11,7 +11,7 @@ on: jobs: assets: timeout-minutes: 30 - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -19,6 +19,4 @@ jobs: with: bundler-cache: true - name: Build assets - run: | - bundle install --jobs 4 --retry 3 - bundle exec rake assets:precompile + run: bin/rails assets:precompile diff --git a/.github/workflows/migrations.yml b/.github/workflows/migrations.yml index e7ee948fe..dbe430b98 100644 --- a/.github/workflows/migrations.yml +++ b/.github/workflows/migrations.yml @@ -11,10 +11,10 @@ on: jobs: migrations: timeout-minutes: 30 - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 services: postgres: - image: postgres:11 + image: postgres:14 ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7939cc7a1..b3dea4ecd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,10 +18,10 @@ on: jobs: tests: timeout-minutes: 30 - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 services: postgres: - image: postgres:11 + image: postgres:14 ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 @@ -35,10 +35,25 @@ jobs: - uses: ruby/setup-ruby@v1 with: bundler-cache: true - - name: Playwright + - run: yarn + - name: Ensure playwright gem and package.json versions match run: | - yarn - yarn playwright install + ruby_playwright=$(bundle exec ruby -e 'require "playwright"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip') + package_json_playwright=$(yarn list --pattern @playwright/test --json | jq '.data.trees[].name | .[17:]' -r) + [[ $ruby_playwright = $package_json_playwright ]] + # 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 diff --git a/package.json b/package.json index c02063058..4afd3076a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "author": "OpenStax", "license": "AGPL-3.0-or-later", "devDependencies": { - "@playwright/test": "^1.48.1", + "@playwright/test": "1.48.1", "@types/node": "^22.7.6" }, "scripts": {} diff --git a/yarn.lock b/yarn.lock index 0cf7144da..3d8a731e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -"@playwright/test@^1.48.1": +"@playwright/test@1.48.1": version "1.48.1" resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.48.1.tgz#343e710fcf2e559529e3ec8d7782e09f325b9396" integrity sha512-s9RtWoxkOLmRJdw3oFvhFbs9OJS0BzrLUc8Hf6l2UdCNd1rqeEyD4BhCJkvzeEoD1FsK4mirsWwGerhVmYKtZg==