【发布时间】:2021-03-30 21:40:22
【问题描述】:
我正在设置一个 Github Actions 工作流来运行 Rails Web 应用程序的整个测试套件,但在使用 Capybara 和 Selenium 的测试时遇到了一些问题(遗憾的是,我几乎没有使用这些工具的经验!)。
这是来自 Github Actions 的错误消息:
22) Participant authentication Participant signs out
Failure/Error: visit '/'
Selenium::WebDriver::Error::UnknownError:
Reached error page: about:neterror?e=dnsNotFound&u=http%3A//project.example.com%3A31337/&c=UTF-8&d=We%20can%E2%80%99t%20connect%20to%20the%20server%20at%20project.example.com.
# WebDriverError@chrome://marionette/content/error.js:181:5
# UnknownError@chrome://marionette/content/error.js:488:5
# checkReadyState@chrome://marionette/content/navigate.js:63:24
# onNavigation@chrome://marionette/content/navigate.js:317:39
# emit@resource://gre/modules/EventEmitter.jsm:160:20
# receiveMessage@chrome://marionette/content/actors/MarionetteEventsParent.jsm:40:25
# ./spec/features/public/registration_and_authentication_spec.rb:131:in `block (2 levels) in <main>'
这是工作流 yml 文件:
name: Continuous Integration
on:
push:
branches: [ setup-github-actions-2 ]
pull_request:
branches: [ setup-github-actions-2 ]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Set Timezone
run: |
sudo timedatectl set-timezone Europe/Paris
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup chrome driver (for Selenium)
uses: nanasess/setup-chromedriver@master
# with:
# Optional: do not specify to match Chrome's version
# chromedriver-version: '88.0.4324.96'
- run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Install node modules
uses: borales/actions-yarn@v2.0.0
with:
cmd: install
- name: Install dependent libraries
run: sudo apt-get install libpq-dev
- name: Bundle install
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup Database
run: |
cp config/database.yml.example config/database.yml
bundle exec rake db:create
bundle exec rake db:schema:load
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run RSpec on helpers
if: always() # make sure to not stop the workflow if one test fails
run: bundle exec rspec spec/helpers
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run RSpec on jobs
if: always()
run: bundle exec rspec spec/jobs
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run RSpec on lib
if: always()
run: bundle exec rspec spec/lib
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run RSpec on mailers
if: always()
run: bundle exec rspec spec/mailers
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run RSpec on models
if: always()
run: bundle exec rspec spec/models
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run RSpec on controllers
if: always()
run: bundle exec rspec spec/controllers
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run RSpec on requests
if: always()
run: bundle exec rspec spec/requests
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# 28 examples, 25 failures => Selenium error
- name: Run RSpec on features
if: always()
run: bundle exec rspec spec/features
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run Jest test suite
if: always()
run: bundle exec yarn test
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
需要注意的是,测试在本地运行良好。
关于我在这里缺少什么的任何线索?
【问题讨论】:
标签: ruby-on-rails selenium capybara github-actions