お世話になっております。
現在、Docker環境にて、CiecleCIを学習中です。
https://qiita.com/AK4747471/items/b2161784065f21cd1645
上記のサイトを参考にしながら、バージョンを合わせたりしながら、構築をしているのですが、下記のエラーで止まってしまっています。
circlrCI上のエラー
#!/bin/sh -eo pipefail # Unable to parse YAML # while parsing a block mapping # in 'string', line 27, column 11: # name: install dependencies # ^ # expected <block end>, but found '<scalar>' # in 'string', line 30, column 13: # gem install bundler -v 1.17.3 # ^ # # ------- # Warning: This configuration was auto-generated to show you the message above. # Don't rerun this job. Rerunning will have no effect. false Exited with code exit status 1 CircleCI received exit code 1
インデントや記述ミスがあると仮説を立て、該当箇所を書き換えてみたもののエラー文は変わりませんでした。
config.yml
version: 2 jobs: build: docker: - image: circleci/ruby:2.5.3-node-browsers environment: - BUNDLER_VERSION: 1.17.3 - RAILS_ENV: 'test' - image: circleci/mysql:5.6.49 environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'true' - MYSQL_ROOT_HOST: '%' working_directory: ~/repo steps: - checkout # Download and cache dependencies - restore_cache: keys: - v1-dependencies-{{ checksum "Gemfile.lock" }} # fallback to using the latest cache if no exact match is found - v1-dependencies- - run: name: install dependencies command: | gem install bundler -v 1.17.3 bundle install --jobs=4 --retry=3 --path vendor/bundle - save_cache: paths: - ./vendor/bundle key: v1-dependencies-{{ checksum "Gemfile.lock" }} # ②ちょっと無理やりですが、database.ymlとdatabase.yml.ciを入れ替える記述です。 - run: mv config/database.yml.ci config/database.yml # Database setup - run: bundle exec rake db:create - run: bundle exec rake db:schema:load # rubocopを走らせる記述です。 - run: name: Rubocop command: bundle exec rubocop # rspecを走らせる記述です。 # run tests! - run: name: run tests 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
エラーの27,30行目は下記に該当します。
circleci.yml
- run: name: install dependencies command: | gem install bundler -v 1.17.3 bundle install --jobs=4 --retry=3 --path vendor/bundle
database.yml.ci
test: adapter: mysql2 encoding: utf8 pool: 5 username: 'root' port: 3306 host: '127.0.0.1' database: _test
docker-compose .yml
version: '3' services: db: image: mysql:5.6.49 environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: root ports: - "4306:3306" web: build: . command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/app_name ports: - "3000:3000" links: - db
database.yml
# MySQL. Versions 5.1.10 and up are supported. # # Install the MySQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: password # docker-compose.ymlのMYSQL_ROOT_PASSWORD host: db # docker-compose.ymlのservice名 development: <<: *default database: app_name_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: app_name_test # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password as a unix environment variable when you boot # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full rundown on how to provide these environment variables in a # production deployment. # # On Heroku and other platform providers, you may have a full connection URL # available as an environment variable. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # You can use this database configuration with: # # production: # url: <%= ENV['DATABASE_URL'] %> # production: <<: *default database: app_name_production username: app_name password: <%= ENV['APP_NAME_DATABASE_PASSWORD'] %>
ターミナル
% bundler -v Bundler version 1.17.3
よろしくお願い致します。
あなたの回答
tips
プレビュー