質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Circle CI

Circle CIは、クラウド上に簡単にCI環境を構築できるWebサービスです。GitHubと連携させ、CIしたいリポジトリーを選択しビルド・テストを行います。チャット等を利用して結果を確認することが可能です。

Q&A

1回答

1616閲覧

ci上でChromeインストール失敗でRedisにつながらない

JuniorSirius

総合スコア38

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Circle CI

Circle CIは、クラウド上に簡単にCI環境を構築できるWebサービスです。GitHubと連携させ、CIしたいリポジトリーを選択しビルド・テストを行います。チャット等を利用して結果を確認することが可能です。

0グッド

0クリップ

投稿2022/01/03 08:49

編集2022/01/03 08:53

開発環境がDockerで、ローカルでパスするRSpecスペックを形成し、circleciでビルドを試みています。
しかし、ci上ではchromeのドライバーがまずうまくインストールされず、エラーが起きて半分程度のスペックが失敗し、原因としてRedis::CannotConnectError: Error connecting to Redis on redis:6379 (SocketError)となります。

ローカル(Docker)ではdocker-composeでコンテナ内でスペックは全てパスしましたが、ciでビルドができないとなるとこれは.circleci/config.ymlの書き方が問題だと思いますが調べ尽くしてもわかりません。
ご指摘いただけたら幸いです。

.circleci/config.yml

yml

1version: 2 2jobs: 3 build: 4 parallelism: 1 5 docker: 6 - image: circleci/ruby:2.6.4-node-browsers #このイメージをstepsの実行時のプライマリコンテナとして使用 7 auth: 8 username: siriusjunior 9 password: $DOCKERHUB_PASSWORD 10 environment: #コンテナの環境変数設定 11 BUNDLE_JOBS: 3 12 BUNDLE_RETRY: 3 13 BUNDLE_PATH: vendor/bundle #vendor/bundle 依存関係のファイルはbundle_installを後でrun 14 RAILS_ENV: test 15 REDIS_HOST: 127.0.0.1 16 - image: redis:latest 17 auth: 18 username: siriusjunior 19 password: $DOCKERHUB_PASSWORD 20 - image: circleci/mysql:5.7 #MySQLのバージョンを確認、データベースイメージ指定 21 environment: #データベースの環境変数設定 22 MYSQL_ALLOW_EMPTY_PASSWORD: yes #[MYSQL_ROOT_PASSWORD]のnull_valueの有効化 23 MYSQL_ROOT_PASSWORD: '' #null_valueで設定 24 steps: #CIで動作するコマンドを設定する必須キー 25 - run: 26 name: Chrome Driver Install 27 command: | 28 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - 29 echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list 30 sudo apt-get update && sudo apt-get install -y unzip 31 wget -N http://chromedriver.storage.googleapis.com/87.0.4280.88/chromedriver_linux64.zip -P ~/ 32 unzip ~/chromedriver_linux64.zip -d ~/ 33 rm ~/chromedriver_linux64.zip 34 sudo chown root:root ~/chromedriver 35 sudo chmod 755 ~/chromedriver 36 sudo mv ~/chromedriver /usr/bin/chromedriver 37 sh -c 'wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -' 38 sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' 39 sudo apt-get update && sudo apt-get install -y google-chrome-stable 40 background: true 41 - checkout #作業ディレクトリにGitリポジトリをコピー 42 - run: #コマンド実行 43 name: setup bundler #任意のrunの名前 44 command: | 45 gem install bundler:2.2.24 46 bundle -v 47 - restore_cache: #キャッシュがsave_cacheで存在していればリストアして、ビルドタイムを向上させる 48 keys: #キャッシュの複数指定 49 - rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }} 50 - rails-demo-bundle-v2- 51 - run: 52 name: bundle install 53 command: | #パスの指定とインストール実行 54 bundle config set --local path 'vendor/bundle' 55 bundle install 56 - save_cache: #キャッシュの保存 57 key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }} 58 paths: 59 - vendor/bundle 60 - restore_cache: #キャッシュがsave_cacheで存在していればリストアして、ビルドタイムを向上させる 61 keys: #キャッシュの複数指定 62 - rails-demo-yarn-{{ checksum "yarn.lock" }} 63 - rails-demo-yarn- 64 - run: 65 name: yarn install #Yarnパッケージのキャッシュ化 66 command: yarn install --cache-folder ~/.cache/yarn 67 - save_cache: #Yarnキャッシュの保存 68 key: rails-demo-yarn-{{ checksum "yarn.lock" }} 69 paths: 70 - ~/.cache/yarn 71 - run: 72 name: wait database #依存関係の待機(MySQLの場合) 73 command: dockerize -wait tcp://localhost:3306 -timeout 1m 74 - run: 75 name: setup database.yml #CircleCiで構築されるDBを反映 76 command: cp config/database.ci.yml config/database.yml 77 - run: 78 name: setup database #スキーマファイルからテーブル作成、--traceでfull_traceチェック 79 command: bin/rails db:schema:load --trace 80 - run: 81 name: Rubocop #rubocopの起動 82 command: bundle exec rubocop --lint 83 # local環境との不整合が疑われるため、chrome-driverのバージョンを更新する 84 - run: 85 name: update chromeDriver version 86 command: bundle exec rake webdrivers:chromedriver:update 87 - run: 88 name: execute rspec #Rspecの実行 89 command: | #RspecJunitFormatterのgemでrspec結果をCIが読める,rspecファイルをglobしファイル名でrspecを並行させる--split-by=timings 90 bundle exec rspec \ 91 --format RspecJunitFormatter \ 92 --out test_results/rspec.xml \ 93 --format progress \ 94 $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) 95 - store_test_results: #テスト結果のアップロード 96 path: test_results 97 - store_artifacts: 98 path: tmp/screenshots/

config/database.ci.yml

yml

1default: &default 2 adapter: mysql2 3 encoding: utf8 4 pool: <%= ENV.fetch("RAILS_MAX_THREADS"){ 5 } %> 5 port: 3306 6 host: '127.0.0.1' 7 username: 'root' 8 password: 9 10test: 11 <<: *default 12 database: circle_test

ビルドの共通しているrspecエラーを一部抜粋

61 tests failed out of 118 in rspec チャットルーム ユーザー詳細ページ チャットルームが存在しない場合 ユーザー詳細ページにてフォローするとDMボタンが出現すること - spec.system.chatrooms.chatrooms_spec spec/system/chatrooms/chatrooms_spec.rb Failure/Error: @user = login(params[:email], params[:password], params[:remember]) Redis::CannotConnectError: Error connecting to Redis on redis:6379 (SocketError) [Screenshot]: tmp/screenshots/failures_r_spec_example_groups_nested_nested_nested_ユーザー詳細ページにてフォローするとdmボタンが出現すること_846.png ./app/controllers/user_sessions_controller.rb:5:in `create' ------------------ --- Caused by: --- SocketError: getaddrinfo: Name or service not known ./app/controllers/user_sessions_controller.rb:5:in `create'

chromeインストールエラー

OK deb https://dl.yarnpkg.com/debian/ stable main Get:1 http://deb.debian.org/debian buster InRelease [122 kB] Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB] Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB] Get:4 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB] Get:5 https://dl.yarnpkg.com/debian stable/main amd64 Packages [10.5 kB] Get:6 https://dl.yarnpkg.com/debian stable/main all Packages [10.5 kB] Reading package lists... Done E: Repository 'http://security.debian.org/debian-security buster/updates InRelease' changed its 'Suite' value from 'stable' to 'oldstable' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details. N: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Version' value from '10.1' to '10.11' E: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Suite' value from 'stable' to 'oldstable' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details. E: Repository 'http://deb.debian.org/debian buster-updates InRelease' changed its 'Suite' value from 'stable-updates' to 'oldstable-updates' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details. --2022-01-03 08:17:50-- http://chromedriver.storage.googleapis.com/87.0.4280.88/chromedriver_linux64.zip Resolving chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)... 172.253.122.128, 2607:f8b0:4004:82f::2010 Connecting to chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)|172.253.122.128|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 6121623 (5.8M) [application/zip] Saving to: ‘/home/circleci/chromedriver_linux64.zip’ chromedriver_linux6 100%[===================>] 5.84M --.-KB/s in 0.06s 2022-01-03 08:17:50 (99.8 MB/s) - ‘/home/circleci/chromedriver_linux64.zip’ saved [6121623/6121623] Archive: /home/circleci/chromedriver_linux64.zip inflating: /home/circleci/chromedriver OK Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB] Get:2 http://deb.debian.org/debian buster InRelease [122 kB] Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB] Get:4 http://dl.google.com/linux/chrome/deb stable InRelease [1811 B] Hit:5 https://dl.yarnpkg.com/debian stable InRelease Get:6 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1091 B] Reading package lists... Done E: Repository 'http://security.debian.org/debian-security buster/updates InRelease' changed its 'Suite' value from 'stable' to 'oldstable' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details. N: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Version' value from '10.1' to '10.11' E: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Suite' value from 'stable' to 'oldstable' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details. E: Repository 'http://deb.debian.org/debian buster-updates InRelease' changed its 'Suite' value from 'stable-updates' to 'oldstable-updates' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details. Exited with code exit status 100 CircleCI received exit code 100

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

chromeをあえてインストールする必要性は疑問ですがそれがないと通らないですね

投稿2022/01/04 20:30

編集2022/01/04 20:33
JuniorSirius

総合スコア38

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問