Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

circleCIでのエラー解決4つ

①syntaxエラー

7ab0a745c2ca516cb52a789a2427a249.png
画像はただのインデントエラーなのですが、Qiitaなどに転がっている「野良コード」をいきなり参考にすると、どこを直してもこんな感じでsyntaxエラーが起こります。信頼できるリソース(例えば有料のハンズオン)を参考にしないと初学で引っかかりました。

②Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket 'hogehoge' (2)

これはデータベースを見失っているということだったので画像のように開発環境用のローカルホスト「'127.0.0.1'」を記述。

database.yml
test:
  <<: *default
  database: stearch_test
  host: <%= ENV['MYSQL_ROOT_HOST'] || '127.0.0.1' %>

③Failure/Error: raise BrowserNotFound, 'Failed to find Chrome binary.'

imageの末尾にbrowsersをつけるとChromeの処理をしてくれます。

circleci/config.yml
version: 2.1
jobs:
 build:
   docker:
   - image: circleci/ruby:2.6.5-node-browsers

④Webpacker::Manifest::MissingEntryError

これはwebpackerがインストールされてないということでyarn installをrunさせます!

circleci/config.yml
   # yarn install
   - run:
       name: yarn install
       command: yarn install
   - run: bundle exec bin/webpack

7a123da37031657fc8b1b9443a333071.png

元のcircleciファイルです。

circleci/config.yml
version: 2.1
jobs:
 build:
   docker:
   - image: circleci/ruby:2.6.5-node-browsers
     environment:
       RAILS_ENV: test
   - image: circleci/mysql:5.7-ram
     environment:
       MYSQL_DATABASE: myapp_test
       MYSQL_ALLOW_EMPTY_PASSWORD: true
       MYSQL_ROOT_HOST: '%'
       MYSQL_USER: root
       MYSQL_PORT: 3306
   working_directory: ~/myapp
   steps:
   - checkout
   - restore_cache:
       keys:
       - v1-dependencies-{{ checksum "Gemfile.lock" }}
       - v1-dependencies-
   - run:
       name: install dependencies
       command: |
         gem install bundler -v 2.0.1
         bundle install --jobs=4 --retry=3 --path vendor/bundle
   - save_cache:
       paths:
       - ./vendor/bundle
       key: v1-dependencies-{{ checksum "Gemfile.lock" }}
   # yarn install
   - run:
       name: yarn install
       command: yarn install
   - run: bundle exec bin/webpack
   # Database setup
   - run:
       name: Prepare db
       command: |
        bin/rails db:schema:load --trace
   # 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 --color --format documentation

   # collect reports
   - store_test_results:
       path: /tmp/test-results
   - store_artifacts:
       path: /tmp/test-results
       destination: test-results
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away