From c90878b160afca5c739f43b8d565b781f9120f7a Mon Sep 17 00:00:00 2001 From: YusukeIwaki Date: Mon, 19 Feb 2024 09:51:38 +0900 Subject: [PATCH 1/4] Update test environments --- .github/workflows/deploy.yml | 40 ++++++++++++++--------------- .github/workflows/rspec.yml | 50 ++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d515b28..fb02bd9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,29 +3,29 @@ name: Deploy on: push: tags: - - '[0-9]+.[0-9]+.[0-9]+' + - "[0-9]+.[0-9]+.[0-9]+" jobs: push_to_rubygems: name: Push to RubyGems runs-on: ubuntu-latest steps: - - name: Set RELEASE_TAG - run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - uses: actions/checkout@v2 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.1 - bundler-cache: true - - name: Check Capybara::Playwright::VERSION - run: bundle exec ruby -e 'raise "invalid Capybara::Playwright::VERSION" unless Capybara::Playwright::VERSION == ENV["RELEASE_TAG"]' - - run: rake build - - name: setup API key - run: | - mkdir -p ~/.gem/ - echo "---" > ~/.gem/credentials - echo ":rubygems_api_key: $RUBYGEMS_API_KEY" >> ~/.gem/credentials - chmod 600 ~/.gem/credentials - env: - RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}} - - run: gem push pkg/capybara-playwright-driver-$RELEASE_TAG.gem + - name: Set RELEASE_TAG + run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + bundler-cache: true + - name: Check Capybara::Playwright::VERSION + run: bundle exec ruby -e 'raise "invalid Capybara::Playwright::VERSION" unless Capybara::Playwright::VERSION == ENV["RELEASE_TAG"]' + - run: rake build + - name: setup API key + run: | + mkdir -p ~/.gem/ + echo "---" > ~/.gem/credentials + echo ":rubygems_api_key: $RUBYGEMS_API_KEY" >> ~/.gem/credentials + chmod 600 ~/.gem/credentials + env: + RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}} + - run: gem push pkg/capybara-playwright-driver-$RELEASE_TAG.gem diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 21d2367..d931904 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -1,7 +1,7 @@ name: RSpec on: [pull_request] jobs: - example_spec: + example_spec_legacy: strategy: fail-fast: false matrix: @@ -9,9 +9,7 @@ jobs: - 2.4.10 - 2.5.9 - 2.6.10 - - '2.7' - - '3.0' - - '3.1' + - 2.7.8 name: (${{ matrix.ruby_version }}) Example runs-on: ubuntu-latest steps: @@ -35,6 +33,38 @@ jobs: PLAYWRIGHT_CLI_EXECUTABLE_PATH: ./node_modules/.bin/playwright timeout-minutes: 3 + example_spec: + strategy: + fail-fast: false + matrix: + ruby_version: + - "3.0" + - "3.1" + - "3.2" + - "3.3" + name: (${{ matrix.ruby_version }}) Example + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true + - uses: actions/setup-node@v1 + with: + node-version: 20 + - uses: microsoft/playwright-github-action@v1 + - name: setup playwright via npm install + run: | + export PLAYWRIGHT_CLI_VERSION=$(bundle exec ruby -e 'require "playwright"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip') + npm install playwright@${PLAYWRIGHT_CLI_VERSION} || npm install playwright@next + ./node_modules/.bin/playwright install + - run: bundle exec rspec spec/feature/ + env: + PLAYWRIGHT_CLI_EXECUTABLE_PATH: ./node_modules/.bin/playwright + timeout-minutes: 3 + playwright_driver_spec: needs: example_spec strategy: @@ -45,14 +75,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1 + ruby-version: 3.3 bundler-cache: true - uses: actions/setup-node@v1 with: - node-version: 16 + node-version: 20 - uses: microsoft/playwright-github-action@v1 - name: setup playwright via npm install run: | @@ -71,7 +101,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: setup Allure run: | wget https://github.com/allure-framework/allure2/releases/download/2.14.0/allure_2.14.0-1_all.deb @@ -79,11 +109,11 @@ jobs: rm allure_2.14.0-1_all.deb - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1 + ruby-version: 3.3 bundler-cache: true - uses: actions/setup-node@v1 with: - node-version: 16 + node-version: 20 - uses: microsoft/playwright-github-action@v1 - name: setup playwright via npm install run: | From f1c0390fc757c72de72fdcf805889bc612134422 Mon Sep 17 00:00:00 2001 From: YusukeIwaki Date: Mon, 19 Feb 2024 10:47:42 +0900 Subject: [PATCH 2/4] Update spec for scraping GitHub --- spec/feature/example_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/feature/example_spec.rb b/spec/feature/example_spec.rb index 21c1557..32ce4fe 100644 --- a/spec/feature/example_spec.rb +++ b/spec/feature/example_spec.rb @@ -49,7 +49,7 @@ visit '/YusukeIwaki/capybara-playwright-driver' page.driver.with_playwright_page do |page| - page.query_selector('get-repo').click + page.locator('button', hasText: 'Code').click download = page.expect_download do page.click('text=Download ZIP') end From 82e1db5ebf5569acad2fd627fa0e5aa7deaee68f Mon Sep 17 00:00:00 2001 From: YusukeIwaki Date: Mon, 19 Feb 2024 22:31:11 +0900 Subject: [PATCH 3/4] Prevent tracing on specs except for example_spec --- .github/workflows/rspec.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index d931904..9a9c027 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -28,7 +28,11 @@ jobs: export PLAYWRIGHT_CLI_VERSION=$(bundle exec ruby -e 'require "playwright"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip') npm install playwright@${PLAYWRIGHT_CLI_VERSION} || npm install playwright@next ./node_modules/.bin/playwright install - - run: bundle exec rspec spec/feature/ + - run: bundle exec rspec spec/feature/example_spec.rb + env: + PLAYWRIGHT_CLI_EXECUTABLE_PATH: ./node_modules/.bin/playwright + timeout-minutes: 3 + - run: bundle exec rspec spec/feature/ --exclude-pattern "spec/feature/example_spec.rb" env: PLAYWRIGHT_CLI_EXECUTABLE_PATH: ./node_modules/.bin/playwright timeout-minutes: 3 @@ -60,7 +64,11 @@ jobs: export PLAYWRIGHT_CLI_VERSION=$(bundle exec ruby -e 'require "playwright"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip') npm install playwright@${PLAYWRIGHT_CLI_VERSION} || npm install playwright@next ./node_modules/.bin/playwright install - - run: bundle exec rspec spec/feature/ + - run: bundle exec rspec spec/feature/example_spec.rb + env: + PLAYWRIGHT_CLI_EXECUTABLE_PATH: ./node_modules/.bin/playwright + timeout-minutes: 3 + - run: bundle exec rspec spec/feature/ --exclude-pattern "spec/feature/example_spec.rb" env: PLAYWRIGHT_CLI_EXECUTABLE_PATH: ./node_modules/.bin/playwright timeout-minutes: 3 From 014d2aa4debff0439310a44a7d004f17e63925a3 Mon Sep 17 00:00:00 2001 From: YusukeIwaki Date: Tue, 20 Feb 2024 00:13:36 +0900 Subject: [PATCH 4/4] Mark wrong spec as pending --- spec/capybara/playwright_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/capybara/playwright_spec.rb b/spec/capybara/playwright_spec.rb index 85346ed..6540f8c 100644 --- a/spec/capybara/playwright_spec.rb +++ b/spec/capybara/playwright_spec.rb @@ -42,6 +42,8 @@ module TestSessions when /fill_in should handle carriage returns with line feeds in a textarea correctly/ # https://github.com/teamcapybara/capybara/commit/a9dd889b640759925bd04c4991de086160242fae#diff-b62b86ae4de5582bd37146266622e3debbdcab6bab6e95f522185c6a4269067dR82 pending "Not sure what firefox is doing here" if ENV['BROWSER'] == 'firefox' + when /#has_element\? should be true if the given element is on the page/ + pending 'https://github.com/teamcapybara/capybara/pull/2751' end Capybara::SpecHelper.reset!