Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/sdk-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ jobs:
ruby:
name: Ruby SDK
runs-on: ubuntu-latest
timeout-minutes: 8
timeout-minutes: 10

steps:
- uses: actions/checkout@v4
Expand All @@ -323,21 +323,26 @@ jobs:
with:
ruby-version: '3.3'

- name: Set up Chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable

- name: Install Ruby dependencies
working-directory: ./clients/ruby
run: |
gem install bundler
bundle install

- name: Run integration tests (TDD mode)
- name: Run E2E tests (TDD mode)
working-directory: ./clients/ruby
run: ../../bin/vizzly.js tdd run "VIZZLY_INTEGRATION=1 ruby -I lib test/integration_test.rb"
run: ../../bin/vizzly.js tdd run "VIZZLY_E2E=1 ruby -Ilib:test test/e2e_test.rb"
env:
CI: true

- name: Run integration tests (Cloud mode)
- name: Run E2E tests (Cloud mode)
working-directory: ./clients/ruby
run: ../../bin/vizzly.js run "VIZZLY_INTEGRATION=1 ruby -I lib test/integration_test.rb"
run: ../../bin/vizzly.js run "VIZZLY_E2E=1 ruby -Ilib:test test/e2e_test.rb"
env:
CI: true
VIZZLY_TOKEN: ${{ secrets.VIZZLY_RUBY_CLIENT_TOKEN }}
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/sdk-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,7 @@ jobs:

- name: Run Ruby unit tests
working-directory: ./clients/ruby
run: ruby -I lib test/vizzly_test.rb

- name: Run Ruby integration tests
working-directory: ./clients/ruby
run: VIZZLY_INTEGRATION=1 ruby -I lib test/integration_test.rb
env:
CI: true
run: ruby -Ilib:test test/vizzly_test.rb

# Storybook SDK - runs on multiple Node versions
storybook:
Expand Down
2 changes: 2 additions & 0 deletions clients/ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ group :development, :test do
gem 'minitest', '~> 5.0'
gem 'rake', '~> 13.0'
gem 'rubocop', '~> 1.60'
gem 'selenium-webdriver', '~> 4.0'
gem 'webrick', '~> 1.8' # Required for Ruby 3.0+ (removed from stdlib)
end
16 changes: 15 additions & 1 deletion clients/ruby/lib/vizzly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def initialize(server_url: nil)
# properties: { browser: 'chrome', viewport: { width: 1920, height: 1080 } },
# threshold: 5
# )
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def screenshot(name, image_data, options = {})
return nil if disabled?

Expand All @@ -65,7 +66,7 @@ def screenshot(name, image_data, options = {})
uri = URI("#{@server_url}/screenshot")

begin
response = Net::HTTP.start(uri.host, uri.port, read_timeout: 30) do |http|
response = Net::HTTP.start(uri.host, uri.port, open_timeout: 10, read_timeout: 30) do |http|
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request.body = JSON.generate(payload)
Expand Down Expand Up @@ -125,13 +126,26 @@ def screenshot(name, image_data, options = {})
# Disable the SDK after first failure to prevent spam
disable!('failure')

nil
rescue Net::OpenTimeout
warn "Vizzly connection timed out for #{name}: couldn't connect within 10s"
warn "Server URL: #{@server_url}/screenshot"
warn 'This usually means the server is unreachable (firewall, network issue, or wrong host)'
disable!('failure')
nil
rescue Net::ReadTimeout
warn "Vizzly request timed out for #{name}: no response within 30s"
warn "Server URL: #{@server_url}/screenshot"
warn 'The server may be overloaded or processing is taking too long'
disable!('failure')
nil
rescue StandardError => e
warn "Vizzly screenshot failed for #{name}: #{e.message}"
disable!('failure')
nil
end
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength

# Wait for all queued screenshots to be processed
# (Simple client doesn't need explicit flushing)
Expand Down
Loading