Skip to content

Commit 4121cf7

Browse files
authored
Merge pull request #2 from kmuto/takahashim-fix-timeout
fix: add timeout parameter
2 parents 4ee4574 + afa516f commit 4121cf7

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v5
1010
- name: Set up Ruby
1111
uses: ruby/setup-ruby@v1
1212
with:
13-
ruby-version: 2.7.4
13+
ruby-version: 3.4
1414
- name: Run the default task
1515
run: |
16-
gem install bundler -v 2.2.5
1716
bundle install
1817
bundle exec rake

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ source 'https://rubygems.org'
44

55
gemspec
66

7+
gem 'base64'
78
gem 'rake', '~> 13.0'
8-
gem 'rubocop', '~> 1.45.1'
9+
gem 'rubocop', '~> 1.80.1'
910
gem 'rubocop-performance'
1011
gem 'rubocop-rake'
1112
gem 'simplecov'

lib/playwrightrunner.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ def default_config(config)
2020
config
2121
end
2222

23-
def mermaids_to_images(passed_config, src: '.', dest: '.', type: 'pdf')
23+
def mermaids_to_images(passed_config, src: '.', dest: '.', type: 'pdf', timeout: 10_000)
2424
config = default_config(passed_config)
2525
Playwright.create(playwright_cli_executable_path: config[:playwright_path]) do |playwright|
26-
playwright.chromium.launch(headless: true) do |browser|
26+
playwright.chromium.launch(headless: true, timeout: timeout) do |browser|
2727
page = browser.new_page
2828
Dir.glob(File.join(src, '*.html')).each do |entry|
2929
id = File.basename(entry).sub('.html', '')
30-
page.goto("file:///#{File.absolute_path(entry)}")
31-
page.locator('svg').wait_for(state: 'visible')
30+
page.goto("file:///#{File.absolute_path(entry)}", timeout: timeout)
31+
page.locator('svg').wait_for(state: 'visible', timeout: timeout)
3232
sleep(1)
3333
1.upto(4) do
3434
bounds = page.locator('svg').bounding_box
@@ -46,7 +46,8 @@ def mermaids_to_images(passed_config, src: '.', dest: '.', type: 'pdf')
4646
page.set_viewport_size({ width: x + width, height: y + height })
4747

4848
if type == 'png'
49-
page.screenshot(path: File.join(dest, "#{id}.png"), clip: { x: x, y: y, width: width, height: height })
49+
page.screenshot(path: File.join(dest, "#{id}.png"), clip: { x: x, y: y, width: width, height: height },
50+
timeout: timeout)
5051
break
5152
end
5253

playwright-runner.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
2828
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
2929
spec.require_paths = ['lib']
3030

31-
spec.add_dependency 'playwright-ruby-client', '~> 1.0'
31+
spec.add_dependency 'playwright-ruby-client', '>= 1.28.0'
3232
end

test/test_mermaid.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class PlaywrightRunnerMermaidTest < Test::Unit::TestCase
77
def setup
88
system('npm install playwright') unless File.exist?('./node_modules/.bin/playwright')
9+
system('npx playwright install chromium')
910
FileUtils.rm_rf('test/assets/dest')
1011
FileUtils.mkdir('test/assets/dest')
1112
end

0 commit comments

Comments
 (0)