実現したいこと
Docker-composeで環境構築をしたRailsのアプリを、CircleCIを使ってリモートリポジトリにpushする際に、自動テストを走らせたいと思っています。
しかし、CircleCIをビルドしようとすると下記のエラーが出力されます。テストコード以外のコードに対するエラーなのではないかと思っているのですが、なかなか糸口が掴めません。
発生している問題・エラーメッセージ
#!/bin/bash -eo pipefail mkdir /tmp/test-results TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \ circleci tests split --split-by=timings)" bundle exec rspec \ --format progress \ --format RspecJunitFormatter \ --out /tmp/test-results/rspec.xml \ --format progress \ $TEST_FILES 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. /home/circleci/komarigoto_hiroba/vendor/bundle/ruby/2.7.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/helper.rb:355: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /home/circleci/komarigoto_hiroba/vendor/bundle/ruby/2.7.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:118: warning: The called method `[]' is defined here F Failures: 1) Users GET /new returns http success Failure/Error: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> ActionView::Template::Error: Webpacker can't find application in /home/circleci/komarigoto_hiroba/public/packs-test/manifest.json. Possible causes: 1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. webpack has not yet re-run to reflect updates. 3. You have misconfigured Webpacker's config/webpacker.yml file. 4. Your webpack configuration is not creating a manifest. Your manifest contains: { } # ./app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb__2870217039742820957_24220' # ./spec/requests/users_request_spec.rb:7:in `block (3 levels) in <main>' # ------------------ # --- Caused by: --- # Webpacker::Manifest::MissingEntryError: # Webpacker can't find application in /home/circleci/komarigoto_hiroba/public/packs-test/manifest.json. Possible causes: # 1. You want to set webpacker.yml value of compile to true for your environment # unless you are using the `webpack -w` or the webpack-dev-server. # 2. webpack has not yet re-run to reflect updates. # 3. You have misconfigured Webpacker's config/webpacker.yml file. # 4. Your webpack configuration is not creating a manifest. # Your manifest contains: # { # } # ./app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb__2870217039742820957_24220' Finished in 4.77 seconds (files took 3.44 seconds to load) 1 example, 1 failure Failed examples: rspec ./spec/requests/users_request_spec.rb:6 # Users GET /new returns http success Exited with code exit status 1
該当のソースコード
config.yml
version: 2 jobs: build: docker: - image: circleci/ruby:2.7.1-node-browsers environment: - BUNDLER_VERSION: 2.1.4 - RAILS_ENV: 'test' - image: circleci/mysql:5.7 environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'true' - MYSQL_ROOT_HOST: '127.0.0.1' working_directory: ~/komarigoto_hiroba steps: - checkout - restore_cache: keys: - v1-dependencies-{{ checksum "Gemfile.lock" }} - v1-dependencies- - run: name: install dependencies command: | gem install bundler -v 2.1.4 bundle install --jobs=4 --retry=3 --path vendor/bundle - save_cache: paths: - ./vendor/bundle key: v1-dependencies-{{ checksum "Gemfile.lock" }} # Database setup - run: mv ./config/database.yml.ci ./config/database.yml #- run: NODE_ENV=test bundle exec rails webpacker:compile # Database setup - run: name: Databasesetup command: | bundle exec rake db:create bundle exec rake db:schema:load # run tests! - run: name: Run rspec command: | mkdir /tmp/test-results TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \ circleci tests split --split-by=timings)" bundle exec rspec \ --format progress \ --format RspecJunitFormatter \ --out /tmp/test-results/rspec.xml \ --format progress \ $TEST_FILES # collect reports - store_test_results: path: /tmp/test-results - store_artifacts: path: /tmp/test-results destination: test-results
manifest.json
{ "application.js": "/packs/js/application-9afcbb5693aa87623e69.js", "application.js.map": "/packs/js/application-9afcbb5693aa87623e69.js.map", "entrypoints": { "application": { "js": [ "/packs/js/application-9afcbb5693aa87623e69.js" ], "js.map": [ "/packs/js/application-9afcbb5693aa87623e69.js.map" ] } } }
application.html.erb
ruby:application.html.erb
1<!DOCTYPE html> 2<html> 3 <head> 4 <title>komarigoto-hiroba</title> 5 <%= csrf_meta_tags %> 6 <%= csp_meta_tag %> 7 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 8 <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> 9 <%= render 'layouts/shim' %> 10 </head> 11 <body> 12 <%= render 'layouts/header' %> 13 <div class=""></div> 14 <div class="container"> 15 <%= yield %> 16 </div> 17 </body> 18</html>
試したこと
- application.html.erbの
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
の2行を消してみる
→消すとbootstrapなどを読み込まなくなる
- webpackersとyamlをインストールしてみる
→効果なし
- manifest.jsに
//= link_directory ../../javascript .js
の1行を加える
→ 効果なし
補足情報(FW/ツールのバージョンなど)
Ruby 2.7.1
Rails 6.0.3.2
MySQL 5.7
何卒よろしくお願いいたします。
あなたの回答
tips
プレビュー