Skip to content

Commit 66d5415

Browse files
author
github-actions
committed
update with project-syncing action
1 parent 3193fe7 commit 66d5415

File tree

6 files changed

+60
-8
lines changed

6 files changed

+60
-8
lines changed

Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,4 @@ group :test do
9696
gem "webmock"
9797
gem "capybara"
9898
gem "selenium-webdriver", "~> 4.11.0"
99-
gem "webdrivers"
10099
end

Gemfile.lock

-5
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,6 @@ GEM
518518
activemodel (>= 6.0.0)
519519
bindex (>= 0.4.0)
520520
railties (>= 6.0.0)
521-
webdrivers (5.2.0)
522-
nokogiri (~> 1.6)
523-
rubyzip (>= 1.3.0)
524-
selenium-webdriver (~> 4.0)
525521
webmock (3.25.1)
526522
addressable (>= 2.8.0)
527523
crack (>= 0.3.2)
@@ -598,7 +594,6 @@ DEPENDENCIES
598594
tzinfo-data
599595
validate_url
600596
web-console
601-
webdrivers
602597
webmock
603598

604599
BUNDLED WITH

bin/chromedriver_check

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env ruby
2+
# This script checks if any tests in the project need chromedriver
3+
# and runs the install script if needed
4+
5+
require "pathname"
6+
7+
APP_ROOT = File.expand_path("..", __dir__)
8+
9+
def check_for_js_tests
10+
js_test_present = false
11+
12+
Dir.glob("#{APP_ROOT}/spec/**/*_spec.rb").each do |file|
13+
content = File.read(file)
14+
if content.match(/js:\s*true/)
15+
js_test_present = true
16+
break
17+
end
18+
end
19+
20+
js_test_present
21+
end
22+
23+
def chromedriver_installed?
24+
system("which chromedriver > /dev/null 2>&1")
25+
end
26+
27+
# First, check if we need chromedriver for our tests
28+
if check_for_js_tests
29+
# Next, check if chromedriver is already installed
30+
if chromedriver_installed?
31+
puts "\n== JavaScript tests found, but chromedriver is already installed. Skipping installation. =="
32+
else
33+
puts "\n== JavaScript tests found and chromedriver not detected. Running installation... =="
34+
system "bin/chromedriver_install"
35+
end
36+
else
37+
puts "\n== No JavaScript tests found, skipping chromedriver installation =="
38+
end

bin/chromedriver_install

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
# Script to install Chrome and matching chromedriver at the system level for Linux
3+
# This script is called by chromedriver_check when JS tests are detected
4+
5+
set -euo pipefail
6+
7+
sudo apt-get update -y
8+
9+
CHROME_DRIVER_VERSION=128.0.6613.137
10+
CHROME_PATH="/usr/local/chrome"
11+
CHROMEDRIVER_PATH="/usr/local/chromedriver"
12+
sudo mkdir -p "$CHROME_PATH" "$CHROMEDRIVER_PATH"
13+
14+
# Install Chrome and Chromedriver
15+
echo "y" | sudo npx @puppeteer/browsers install chrome@${CHROME_DRIVER_VERSION} --install-deps --path="$CHROME_PATH"
16+
echo "y" | sudo npx @puppeteer/browsers install chromedriver@${CHROME_DRIVER_VERSION} --path="$CHROMEDRIVER_PATH"
17+
18+
sudo ln -sf ${CHROME_PATH}/linux-${CHROME_DRIVER_VERSION}/chrome-linux64/chrome /usr/local/bin/google-chrome
19+
sudo ln -sf ${CHROMEDRIVER_PATH}/linux-${CHROME_DRIVER_VERSION}/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver

bin/setup

+3
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ FileUtils.chdir APP_ROOT do
3030

3131
puts "\n== Removing old logs and tempfiles =="
3232
system! "bin/rails log:clear tmp:clear"
33+
34+
puts "\n== Checking for JavaScript tests and installing chromedriver if needed =="
35+
system! "bin/chromedriver_check"
3336
end

spec/support/headless_chrome.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require "webdrivers/chromedriver"
2-
31
Capybara.register_driver :headless_chrome do |app|
42
options = Selenium::WebDriver::Chrome::Options.new
53
options.add_argument("--headless")

0 commit comments

Comments
 (0)