mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 10:33:51 +08:00
DEV: Add early support for aarch64 dev env
This patch allows running system specs on an aarch64 Linux system (typically our `discourse_dev` docker image). As Chrome isn’t available for the aarch64 architecture (yet), we have to rely on Firefox instead. This has some drawbacks like not being able to access the browser logs like we do with the Chrome webdriver.
This commit is contained in:
parent
429a7d09e2
commit
484954ec4c
|
@ -89,7 +89,15 @@ done
|
|||
# 9292 unicorn
|
||||
# 9405 prometheus exporter
|
||||
|
||||
docker pull discourse/discourse_dev:release
|
||||
if [ "$(uname -m)" == "aarch64" ]; then
|
||||
# NOTE: we currently (2024-01-17) don’t build an aarch64 image, so one must be pre-built locally.
|
||||
# Avoiding `docker pull` so we don't override that local image.
|
||||
ENV_ARGS+=" -e SE_MANAGER_PATH=/usr/local/bin/selenium-manager "
|
||||
else
|
||||
# x86_64 environment - pull the latest image from dockerhub
|
||||
docker pull discourse/discourse_dev:release
|
||||
fi
|
||||
|
||||
docker run -d \
|
||||
-p $local_publish:8025:8025 \
|
||||
-p $local_publish:3000:3000 \
|
||||
|
|
|
@ -421,6 +421,23 @@ RSpec.configure do |config|
|
|||
Capybara::Selenium::Driver.new(app, **mobile_driver_options)
|
||||
end
|
||||
|
||||
Capybara.register_driver :selenium_firefox_headless do |app|
|
||||
options =
|
||||
Selenium::WebDriver::Firefox::Options.new(
|
||||
args: %w[--window-size=1400,1400 --headless],
|
||||
prefs: {
|
||||
"browser.download.dir": Downloads::FOLDER,
|
||||
},
|
||||
log_level: ENV["SELENIUM_BROWSER_LOG_LEVEL"] || :warn,
|
||||
)
|
||||
Capybara::Selenium::Driver.new(
|
||||
app,
|
||||
browser: :firefox,
|
||||
timeout: BROWSER_READ_TIMEOUT,
|
||||
options: options,
|
||||
)
|
||||
end
|
||||
|
||||
if ENV["ELEVATED_UPLOADS_ID"]
|
||||
DB.exec "SELECT setval('uploads_id_seq', 10000)"
|
||||
else
|
||||
|
@ -555,7 +572,7 @@ RSpec.configure do |config|
|
|||
#
|
||||
# The long term fix here is to get `selenium-manager` to download the `chromedriver` binary to a unique path for each
|
||||
# process but the `--cache-path` option for `selenium-manager` is currently not supported in `selenium-webdriver`.
|
||||
if !File.directory?("~/.cache/selenium")
|
||||
if !File.directory?(File.expand_path("~/.cache/selenium"))
|
||||
File.open("#{Rails.root}/tmp/chrome_driver_flock", "w") do |file|
|
||||
file.flock(File::LOCK_EX)
|
||||
`#{Selenium::WebDriver::SeleniumManager.send(:binary)} --browser chrome`
|
||||
|
@ -576,8 +593,15 @@ RSpec.configure do |config|
|
|||
|
||||
driver = [:selenium]
|
||||
driver << :mobile if example.metadata[:mobile]
|
||||
driver << :chrome
|
||||
driver << (aarch64? ? :firefox : :chrome)
|
||||
driver << :headless unless ENV["SELENIUM_HEADLESS"] == "0"
|
||||
|
||||
if driver.include?(:firefox)
|
||||
STDERR.puts(
|
||||
"WARNING: Running system specs using the Firefox driver is not officially supported. Some tests will fail.",
|
||||
)
|
||||
end
|
||||
|
||||
driven_by driver.join("_").to_sym
|
||||
|
||||
setup_system_test
|
||||
|
@ -595,7 +619,8 @@ RSpec.configure do |config|
|
|||
lines << "~~~~~ END DRIVER LOGS ~~~~~"
|
||||
end
|
||||
|
||||
js_logs = page.driver.browser.logs.get(:browser)
|
||||
# The logs API isn’t available (yet?) with the Firefox driver
|
||||
js_logs = aarch64? ? [] : page.driver.browser.logs.get(:browser)
|
||||
|
||||
# Recommended that this is not disabled, since it makes debugging
|
||||
# failed system tests a lot trickier.
|
||||
|
@ -897,6 +922,10 @@ def apply_base_chrome_options(options)
|
|||
end
|
||||
end
|
||||
|
||||
def aarch64?
|
||||
RUBY_PLATFORM == "aarch64-linux"
|
||||
end
|
||||
|
||||
class SpecSecureRandom
|
||||
class << self
|
||||
attr_accessor :value
|
||||
|
|
Loading…
Reference in New Issue
Block a user