itamae-plugin-recipe-selenium 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e0ed51d2ed85d10d47bde47d097d4d01adae56aaa5ad071e79b8e2bbf21bbfa
4
- data.tar.gz: 4070d4793665cf51df9c5c4c97c84a04900709ee359b0f00bee62c8dc9ed61ab
3
+ metadata.gz: 48749a65c9241e3fc07de50a54b06abe87eb93bc5e9059965ed8ee9a0f289991
4
+ data.tar.gz: f746a1eb77de312b592586ba50e393da4b810398150cdcd8be1d1fcb3be86fd4
5
5
  SHA512:
6
- metadata.gz: bf8b735832402e847a701f0762d38c52a21b47d3a6c11e6adebc170775277224ec433f0669c2ba640a2841f8c523ddafb80429dd7995f6025a367d9026595df8
7
- data.tar.gz: 65f7af5ec428d12156d78256cedee7f965d59ab3ff09c1f2861a9ef45b88d5195b4e3349cd2dc68ef98ccf355f6827814f1c185931cff6821687aea029f39b10
6
+ metadata.gz: cee029419f266c394096b5d7469318015ad90d5126f66d63d709de47b55b99e526328855bbb5e53239f895b50e35c61059fcc5d96953c7d4d9f6965c027f95d6
7
+ data.tar.gz: b02cc7d086c7c900b557a84c382b2398100d01aca0c7d1a1e0685b47c4a825170c7316d6d7b32bd451e994295b24fdb0935dd9e8a7f64bba2b524415e2eb60af
@@ -7,8 +7,11 @@ template '/etc/yum.repos.d/google-chrome.repo' do
7
7
  end
8
8
 
9
9
  if ENV['CHROME_VERSION'].to_s.empty?
10
- package 'google-chrome-stable' do
10
+ ENV['CHROME_VERSION'] = '117.0.5938.92'
11
+
12
+ execute "yum install -y https://dl.google.com/linux/chrome/rpm/stable/x86_64/google-chrome-stable-#{ENV['CHROME_VERSION']}-1.x86_64.rpm" do
11
13
  user 'root'
14
+ not_if "which google-chrome-stable && google-chrome-stable --version | egrep 'Google Chrome (113|114|115|116|117)\.'"
12
15
  end
13
16
  else
14
17
  execute "yum install -y https://dl.google.com/linux/chrome/rpm/stable/x86_64/google-chrome-stable-#{ENV['CHROME_VERSION']}-1.x86_64.rpm" do
@@ -16,8 +19,3 @@ else
16
19
  not_if "which google-chrome-stable && google-chrome-stable --version | cut -d ' ' -f 3 | egrep \"^#{ENV['CHROME_VERSION']}$\""
17
20
  end
18
21
  end
19
-
20
- execute 'yum update -y google-chrome-stable' do
21
- user 'root'
22
- not_if "which google-chrome-stable && google-chrome-stable --version | egrep 'Google Chrome (110|111|112|113|114)\.'"
23
- end
@@ -2,7 +2,7 @@ module Itamae
2
2
  module Plugin
3
3
  module Recipe
4
4
  module Selenium
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.2'
6
6
  end
7
7
  end
8
8
  end
@@ -1,4 +1,6 @@
1
- require 'net/http'
1
+ require 'json'
2
+ require 'net/https'
3
+ require 'uri'
2
4
 
3
5
  module Itamae
4
6
  module Plugin
@@ -32,41 +34,35 @@ module Itamae
32
34
  private
33
35
 
34
36
  def run_setup_chromedriver
35
- host = 'chromedriver.storage.googleapis.com'
36
- base_url = 'https://' + host
37
37
  browser_version = run_command('sudo yum list | grep google-chrome-stable').stdout.split[1]
38
38
  browser_version = Gem::Version.new(browser_version.to_s).segments[0..2].join('.')
39
39
 
40
- driver_version_url = base_url + "/LATEST_RELEASE_#{browser_version}"
41
- driver_version = Net::HTTP.get_response(URI(driver_version_url)).body
42
-
43
- # see https://stackoverflow.com/questions/70967207/selenium-chromedriver-cannot-construct-keyevent-from-non-typeable-key/70968668
44
- driver_version = '97.0.4692.71' if driver_version.start_with?('98.')
45
-
46
- download_url = base_url + "/#{driver_version}/chromedriver_linux64.zip"
47
- header = Net::HTTP.start(host) { |http| http.head("/#{driver_version}/chromedriver_linux64.zip") }
48
- etag = header['etag'][1...-1]
40
+ driver_version_url = 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json'
41
+ driver_versions = JSON.parse(Net::HTTP.get_response(URI(driver_version_url)).body)
42
+ driver_version_info = driver_versions['versions'].select{|hash| hash['version'].start_with?(browser_version) }.sort{|a, b| a['revision'] <=> b['revision'] }.last
43
+ driver_version = driver_version_info['version']
44
+ driver_download_url = driver_version_info['downloads']['chromedriver'].find{|hash| hash['platform'] == 'linux64' }&.[]('url')
49
45
 
50
46
  Itamae.logger.info "browser version: #{browser_version}"
51
47
  Itamae.logger.info "driver version: #{driver_version}"
52
- Itamae.logger.debug "download url: #{download_url}"
53
- Itamae.logger.debug "etag: #{etag}"
48
+ Itamae.logger.info "driver download url: #{driver_download_url}"
54
49
 
55
50
  run_command_if_not(
56
51
  'download chromedriver',
57
- "echo '#{etag} chromedriver_linux64-#{driver_version}.zip' | md5sum -c -",
52
+ "#{attributes.install_dir}chromedriver -v | grep 'ChromeDriver #{driver_version} '",
58
53
  <<-COMMANDS
59
- rm -Rf chromedriver_linux64-#{driver_version}*
60
- curl -o chromedriver_linux64-#{driver_version}.zip #{download_url}
54
+ rm -f chromedriver-linux64.zip
55
+ curl -o chromedriver-linux64.zip #{driver_download_url}
61
56
  COMMANDS
62
57
  )
63
58
 
64
59
  run_command_if_not(
65
60
  'install chromedriver',
66
- "#{attributes.install_dir}chromedriver -v | grep 'ChromeDriver #{driver_version}'",
61
+ "#{attributes.install_dir}chromedriver -v | grep 'ChromeDriver #{driver_version} '",
67
62
  <<-COMMANDS
68
- unzip chromedriver_linux64-#{driver_version}.zip
69
- sudo mv -f chromedriver #{attributes.install_dir}
63
+ rm -Rf chromedriver-linux64/
64
+ unzip chromedriver-linux64.zip
65
+ sudo mv -f chromedriver-linux64/chromedriver #{attributes.install_dir}
70
66
  COMMANDS
71
67
  )
72
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae-plugin-recipe-selenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - y-matsuda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-31 00:00:00.000000000 Z
11
+ date: 2023-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: itamae
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.3.16
118
+ rubygems_version: 3.3.26
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: itamae recipe for god process monitoring framework