Home > OS >  GitHub Actions Failing : Ignore Local Host Error
GitHub Actions Failing : Ignore Local Host Error

Time:10-17

I am having an odd issue with running specs only on github actions, and it is not respecting the ignore local hosts setting. Is there something we need to add to the config to make our settings work with GitHub Actions?

Error

Run bundle exec rspec --tag type:feature
  
Run options: include {:type=>"feature"}
Capybara starting Puma...
* Version 4.3.12 , codename: Mysterious Traveller
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:38[9](https://github.com/TinyMission/ami-experience/actions/runs/3258283316/jobs/5350246640#step:12:9)[9](https://github.com/TinyMission/ami-experience/actions/runs/3258283316/jobs/5350246640#step:12:10)5
......................F

Failures:

  1) Log In can log into the application 
     Got 0 failures and 2 other errors:

     1.1) Failure/Error: visit new_user_session_path

          VCR::Errors::UnhandledHTTPRequestError:


            ================================================================================
            An HTTP request has been made that VCR does not know how to handle:
              GET https://chromedriver.storage.googleapis.com/LATEST_RELEASE_[10](https://github.com/TinyMission/ami-experience/actions/runs/3258283316/jobs/5350246640#step:12:11)6.0.5249

            There is currently no cassette in use. There are a few ways
            you can configure VCR to handle this request:

              * If you're surprised VCR is raising this error
                and want insight about how VCR attempted to handle the request,
                you can use the debug_logger configuration option to log more details [1].
              * If you want VCR to record this request and play it back during future test
                runs, you should wrap your test (or this portion of your test) in a
                `VCR.use_cassette` block [2].
              * If you only want VCR to handle requests made while a cassette is in use,
                configure `allow_http_connections_when_no_cassette = true`. VCR will
                ignore this request since it is made when there is no cassette [3].
              * If you want VCR to ignore this request (and others like it), you can
                set an `ignore_request` callback [4].

            [1] https://www.relishapp.com/vcr/vcr/v/6-1-0/docs/configuration/debug-logging
            [2] https://www.relishapp.com/vcr/vcr/v/6-1-0/docs/getting-started
            [3] https://www.relishapp.com/vcr/vcr/v/6-1-0/docs/configuration/allow-http-connections-when-no-cassette
            [4] https://www.relishapp.com/vcr/vcr/v/6-1-0/docs/configuration/ignore-request
            ================================================================================
          # ./spec/features/login_spec.rb:9:in `block (2 levels) in <top (required)>'
          # ./spec/rails_helper.rb:69:in `block (2 levels) in <top (required)>'
          # ./spec/support/configs/config_vcr.rb:38:in `block (2 levels) in <top (required)>'

     1.2) Failure/Error: example.run

          VCR::Errors::UnhandledHTTPRequestError:


            ================================================================================
            An HTTP request has been made that VCR does not know how to handle:
              GET https://chromedriver.storage.googleapis.com/LATEST_RELEASE_106.0.5249

            There is currently no cassette in use. There are a few ways
            you can configure VCR to handle this request:

              * If you're surprised VCR is raising this error
                and want insight about how VCR attempted to handle the request,
                you can use the debug_logger configuration option to log more details [1].
              * If you want VCR to record this request and play it back during future test
                runs, you should wrap your test (or this portion of your test) in a
                `VCR.use_cassette` block [2].
              * If you only want VCR to handle requests made while a cassette is in use,
                configure `allow_http_connections_when_no_cassette = true`. VCR will
                ignore this request since it is made when there is no cassette [3].
              * If you want VCR to ignore this request (and others like it), you can
                set an `ignore_request` callback [4].

            [1] https://www.relishapp.com/vcr/vcr/v/6-1-0/docs/configuration/debug-logging
            [2] https://www.relishapp.com/vcr/vcr/v/6-1-0/docs/getting-started
            [3] https://www.relishapp.com/vcr/vcr/v/6-1-0/docs/configuration/allow-http-connections-when-no-cassette
            [4] https://www.relishapp.com/vcr/vcr/v/6-1-0/docs/configuration/ignore-request
            ================================================================================
          # ./spec/rails_helper.rb:69:in `block (2 levels) in <top (required)>'
          # ./spec/support/configs/config_vcr.rb:38:in `block (2 levels) in <top (required)>'

Finished in 1.36 seconds (files took 1.62 seconds to load)
23 examples, 1 failure

Failed examples:

rspec ./spec/features/login_spec.rb:17 # Log In can log into the application 

Stopped processing SimpleCov as a previous error not related to SimpleCov has been detected
Coverage report generated for RSpec to /home/runner/work/ami-experience/ami-experience/tmp/coverage. 2[13](https://github.com/TinyMission/ami-experience/actions/runs/3258283316/jobs/5350246640#step:12:14) / 327 LOC (65.[14](https://github.com/TinyMission/ami-experience/actions/runs/3258283316/jobs/5350246640#step:12:15)%) covered.
Error: Process completed with exit code 1.

Spec...

# frozen_string_literal: true

require('rails_helper')

RSpec.describe 'Log In', type: :feature do
  let(:user) { create(:admin_user) }

  before do
    visit new_user_session_path
    expect(page).to have_button('Access')
    fill_in 'user_email', with: user.email, wait: 10
    fill_in 'user_password', with: user.password, wait: 10
    click_button 'Access'
  end

  context 'can log into the application' do
    it { expect(page).to have_content('Success!') }
  end
end

VCR Config

# frozen_string_literal: true

VCR.configure do |c|
  c.ignore_localhost = true
  c.cassette_library_dir = 'spec/fixtures/vcr'
  c.hook_into(:webmock)
  c.default_cassette_options = { record: :new_episodes }
  c.allow_http_connections_when_no_cassette = false
end

CodePudding user response:

I found the issue, I had to ignore google chrome

VCR.configure do |c|
  c.configure_rspec_metadata!
  c.ignore_localhost = true
  c.allow_http_connections_when_no_cassette = false
  c.ignore_hosts('127.0.0.1', 'localhost', '0.0.0.0', 'chromedriver.storage.googleapis.com')
  c.cassette_library_dir = 'spec/fixtures/vcr'
  c.hook_into(:webmock)

  record_mode = ENV['VCR'] ? ENV['VCR'].to_sym : :once

  c.default_cassette_options = { record: record_mode }
end```

CodePudding user response:

The request isn't being made to localhost, so the ignore_localhost setting is irrelevant. You can see from the error message that the request is to https://chromedriver.storage.googleapis.com/LATEST_RELEASE_[10] which is likely being made by the webdrivers gem to get an updated version of chromedriver. It's related to https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock and the solution there would be to allow the connections for this in your VCR config

  VCR.configure do |c|
    ...
    c.ignore_hosts('chromedriver.storage.googleapis.com') }
    ...
  end
  • Related