Programming Journal

学習したことの整理用です。

【CircleCI】エラー

モデルスペックは通るのに、システムスペックを追加したら、ローカルではパスするのにCircleCI上で落ちるようになった。 半日苦しんだので、メモ

ローカルでjobを実行できない

❯ circleci local execute --job build
Docker image digest: sha256:ed0cf0f38d357f2599fb3872009de30d79664d48b6fb7167c54867befbc0d794
docker: Error response from daemon: dial unix docker.raw.sock: connect: connection refused.
See 'docker run --help'.

docker起動してなかった。。。

f:id:Study-Diary:20201209194655p:plain
docker-desktop

Systemスペックが落ちる

モデルスペックは問題なし。システムスペックだけ、ローカルでは大丈夫なのにCircleCI上で落ちる。

f:id:Study-Diary:20201209194726p:plain
CIrcleCIエラー

Error reading historical timing data: file does not exist
Requested weighting by historical based timing, but they are not present. Falling back to weighting by name.
DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload ActionText::ContentHelper, for example,
the expected changes won't be reflected in that stale Module object.

These autoloaded constants have been unloaded.

Please, check the "Autoloading and Reloading Constants" guide for solutions.
 (called from <top (required)> at /home/circleci/repo/config/environment.rb:5)
..........Since there is no EDITOR or BETTER_ERRORS_EDITOR environment variable, using Textmate by default.
FFFFFFFF

Failures:

  1) UserSessions ログイン機能 メールアドレスとパスワードが一致しているとき ログインに成功する
     Failure/Error: fill_in 'メールアドレス', with: user.email
     
     Capybara::ElementNotFound:
       Unable to find field "メールアドレス" that is not disabled
     
     [Screenshot]: /home/circleci/repo/tmp/screenshots/failures_r_spec_example_groups_user_sessions_nested_nested_ログインに成功する_166.png

     
     # ./spec/system/user_sessions_spec.rb:10:in `block (4 levels) in <main>'

日本語フォントに対応していない??と思い、フォントをダウンロードしたり色々試したけどできず。
テスト結果のスクリーンショットを見てみる(見方は後述)※色々試すより、先にこの設定をすればよかった。

f:id:Study-Diary:20201209194757p:plain
テスト結果スクリーンショット

Webpacker::Manifest::MissingEntryError

ということなので、yarn installを設定ファイルに追加

    steps:
      - checkout

      # yarnインストール
      - run:
          name: yarn Install
          command: yarn install

やっとできた!

f:id:Study-Diary:20201209194826p:plain
解決!

デバッグ

CircleCIでエラーがでたときのデバッグ方法がわからずに無駄に色々試してしまった

テスト結果を保存する設定を追記する。
これで、CircleCI上のArtifactsのタブからスクリーンショットを確認できる。

      # テスト結果の保存(CircleCI上で見れる)
      - store_test_results:
          path: /tmp/test-results
          destination: test-results
      - store_artifacts:
          path: tmp/screenshots
          destination: test-screenshots