Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 2
Message 1 of 5

Problem to run system tests on Rails

Solved! Go to Solution.

My setup file look slike this:

name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      db:
        image: postgres:11
        ports: ['5432:5432']
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    steps:
      - uses: actions/checkout@v1
      - name: Setup Ruby
        uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.6.x
      - uses: borales/actions-yarn@v2.0.0
        with:
          cmd: install
      - name: Build
        env:
          RAILS_ENV: test
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: |
          sudo apt-get -yqq install libpq-dev
          cp config/options.demo.yml config/options.yml
          cp config/database.demo.yml config/database.yml
          gem install bundler
          bundle install --jobs 4 --retry 3
      - name: Setup DB
        env:
          DATABASE_URL: postgres://postgres:@localhost:5432/test
          RAILS_ENV: test
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: |
          bundle exec rails db:create db:migrate
      - name: Run tests
        env:
          DATABASE_URL: postgres://postgres:@localhost:5432/test
          RAILS_ENV: test
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: |
          bundle exec rails test
          bundle exec rake test:system

it fails with message as:

==============ERROR["test_showing_a_Page_element", #<Minitest::Reporters::Suite:0x00005564e192b788 @name="PageElementsTest">, 3.878157251999994]

 test_showing_a_Page_element#PageElementsTest (3.88s)

Selenium::WebDriver::Error::UnknownError:         Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally

          (unknown error: DevToolsActivePort file doesn't exist)

          (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

            test/application_system_test_case.rb:7:in `log_as_admin'
            test/system/page_elements_test.rb:6:in `block in <class:PageElementsTest>'

==============|

Trying to add chromium-chromedriver failed with:

sudo apt-get -yqq install libpq-dev chromium-chromedriver
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_77.0.3865.90-0ubuntu0.18.04.1_amd64.deb  404  Not Found [IP: 52.177.174.250 80]

But without systemtest are GH Actions unusable for Rails dev. :(

Any suggestins / soluttions ?

 

--------------

* Also there is some kind of caching missing to speedup gems installation (it takes several minutes each run) - but it is for another post ... :/ 

4 Replies
Highlighted
Solution
GitHub Partner
Message 2 of 5

Re: Problem to run system tests on Rails

Hi @Pepan ,

 

Please download the latest chrome drive from here: https://sites.google.com/a/chromium.org/chromedriver/downloads .
And then try this:

chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-dev-shm-usage')
d = webdriver.Chrome('/home/PycharmProjects/chromedriver',chrome_options=chrome_options)
d.get('https://www.google.nl/')
Highlighted
Ground Controller Lvl 1
Message 3 of 5

Re: Problem to run system tests on Rails

Would you be willing to explain what I do after downloading the latest Chromedriver?

 

I tried adding it to my steps:

- name: Install Chromedriver
  run: |
    # Install Chromedriver
    CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE`
    sudo wget -N https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/
    unzip ~/chromedriver_linux64.zip -d ~/
    sudo mv -f ~/chromedriver /usr/local/bin/chromedriver
    sudo chown root:root /usr/local/bin/chromedriver
    sudo chmod 0755 /usr/local/bin/chromedriver

 

Adding all of this, plus adding your recommended configurations didn't solve the problem.

Highlighted
Copilot Lvl 2
Message 4 of 5

Re: Problem to run system tests on Rails

Was this ever solved? I'm getting some Chrome Driver errors and would like to know if you had any success with running your specs.

Highlighted
Copilot Lvl 2
Message 5 of 5

Re: Problem to run system tests on Rails

I tweaked my selenium settings in the ruby helper, but you should be able to do the same in most languages I'd guess. 

driven_by :selenium, using: :chrome, options: { args: ["headless", "disable-gpu", "no-sandbox", "disable-dev-shm-usage"] }