gpt4 book ai didi

ruby - 使用 CI 在 Docker 中运行 apparition 的要求?

转载 作者:太空宇宙 更新时间:2023-11-03 17:42:16 25 4
gpt4 key购买 nike

我正在尝试在我的 CI 中的 docker 中使用 capybara 和幻影运行 rspec 测试。我已经安装了 google-chrome-stable,但收到疯狂的错误。

如果我只是运行我的 rspec,它会启动 puma 来执行测试,然后只需要 10 多分钟。

疯狂的是,如果我添加 rspec 过滤器或排除模式,我的所有测试规范都会失败,并出现下面提供的错误。

我正在运行 rails 6.0.0rc2 和最新版本的所有东西(rspec-rails、capybara、apparition)

如果我在 CI 上运行测试而不使用 apparition 进行完整测试,一切正常。

我在谷歌上搜索了这个Could not load native IDN implementation. 并尝试清除我的 CI worker 的缓存,但它没有帮助。

我用这个 docker 文件构建我的镜像

FROM ruby:2.6-stretch

ENV LANG C.UTF-8

ARG PG_MAJOR=11
ARG NODE_MAJOR=10
ARG BUNDLER_VERSION=2.0.2
ARG YARN_VERSION=1.17.3

# Add PostgreSQL to sources list
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list

# Add NodeJS to sources list
RUN curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR.x | bash -

# Add Yarn to the sources list
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo 'deb http://dl.yarnpkg.com/debian/ stable main' > /etc/apt/sources.list.d/yarn.list

# Add chrome keys
RUN curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list

RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
build-essential \
ca-certificates \
curl \
gnupg \
gnupg1 \
patch \
google-chrome-stable \
postgresql-client-$PG_MAJOR \
nodejs \
xz-utils \
yarn=$YARN_VERSION-1 \
zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
truncate -s 0 /var/log/*log && \
gem update --system && \
groupadd --gid 1000 node && \
useradd --uid 1000 --gid node --shell /bin/bash --create-home node

RUN gem update --system && \
gem install bundler:$BUNDLER_VERSION

RUN mkdir -p /app

WORKDIR /app

这是我的 CI 的日志

bundle exec rspec --color --tty --tag "~js" .[0;m
Could not load native IDN implementation.

An error occurred while loading ./vendor/ruby/2.6.0/gems/addressable-2.6.0/spec/addressable/rack_mount_compat_spec.rb.
[31mFailure/Error: raise(Bootsnap::LoadPathCache::CoreExt.make_load_error(path))[0m
[31m[0m
[31mLoadError:[0m
[31m cannot load such file -- rack/mount[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:33:in `require'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/zeitwerk-2.1.9/lib/zeitwerk/kernel.rb:23:in `require'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/addressable-2.6.0/spec/addressable/rack_mount_compat_spec.rb:23:in `<main>'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/configuration.rb:2053:in `load_file_handling_errors'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/configuration.rb:1560:in `block in load_spec_files'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/configuration.rb:1558:in `each'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/configuration.rb:1558:in `load_spec_files'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/runner.rb:98:in `setup'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/runner.rb:86:in `run'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/runner.rb:71:in `run'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/runner.rb:45:in `invoke'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/exe/rspec:4:in `<top (required)>'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/bin/rspec:23:in `load'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/bin/rspec:23:in `<top (required)>'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli/exec.rb:74:in `load'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli/exec.rb:74:in `kernel_load'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli/exec.rb:28:in `run'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:463:in `exec'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:27:in `dispatch'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:18:in `start'[0m
[36m# /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'[0m
[36m# /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'[0m
[36m# /usr/local/bundle/bin/bundle:23:in `load'[0m
[36m# /usr/local/bundle/bin/bundle:23:in `<main>'[0m
[36m# [0m
[36m# Showing full backtrace because every line was filtered out.[0m
[36m# See docs for RSpec::Configuration#backtrace_exclusion_patterns and[0m
[36m# RSpec::Configuration#backtrace_inclusion_patterns for more information.[0m

这是我的 CI 的日志

bundle exec rspec --color --tty --tag "~js" .[0;m
Could not load native IDN implementation.

An error occurred while loading ./vendor/ruby/2.6.0/gems/addressable-2.6.0/spec/addressable/rack_mount_compat_spec.rb.
[31mFailure/Error: raise(Bootsnap::LoadPathCache::CoreExt.make_load_error(path))[0m
[31m[0m
[31mLoadError:[0m
[31m cannot load such file -- rack/mount[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:33:in `require'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/zeitwerk-2.1.9/lib/zeitwerk/kernel.rb:23:in `require'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/addressable-2.6.0/spec/addressable/rack_mount_compat_spec.rb:23:in `<main>'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/configuration.rb:2053:in `load_file_handling_errors'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/configuration.rb:1560:in `block in load_spec_files'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/configuration.rb:1558:in `each'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/configuration.rb:1558:in `load_spec_files'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/runner.rb:98:in `setup'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/runner.rb:86:in `run'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/runner.rb:71:in `run'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/runner.rb:45:in `invoke'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/gems/rspec-core-3.8.2/exe/rspec:4:in `<top (required)>'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/bin/rspec:23:in `load'[0m
[36m# /builds/prj/prj/vendor/ruby/2.6.0/bin/rspec:23:in `<top (required)>'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli/exec.rb:74:in `load'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli/exec.rb:74:in `kernel_load'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli/exec.rb:28:in `run'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:463:in `exec'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:27:in `dispatch'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:18:in `start'[0m
[36m# /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'[0m
[36m# /usr/local/lib/ruby/site_ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'[0m
[36m# /usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'[0m
[36m# /usr/local/bundle/bin/bundle:23:in `load'[0m
[36m# /usr/local/bundle/bin/bundle:23:in `<main>'[0m
[36m# [0m
[36m# Showing full backtrace because every line was filtered out.[0m
[36m# See docs for RSpec::Configuration#backtrace_exclusion_patterns and[0m
[36m# RSpec::Configuration#backtrace_inclusion_patterns for more information.[0m
...
Run options: exclude {:js=>true}

Randomized with seed 1270


Finished in 6.04 seconds (files took 5.89 seconds to load)
0 examples, 0 failures, 188 errors occurred outside of examples

问题是我只有 5 个测试示例,所以看起来这个失败的测试来自内部

有什么想法可以找出为什么我会收到所有这些疯狂的错误吗?

最佳答案

为 apparition 驱动程序添加 browser_options 后问题已解决。如果没有 --no-sandbox 选项,Chrome 将不会以 root 用户运行。要添加它,只需像这样初始化您的驱动程序

Capybara.register_driver :apparition do |app|
opts = {
headless: true,
browser_options: [
:no_sandbox,
{ disable_features: 'VizDisplayCompositor' },
:disable_gpu
]
}
Capybara::Apparition::Driver.new(app, opts)
end

关于ruby - 使用 CI 在 Docker 中运行 apparition 的要求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57508007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com