掲題の通りです。
以下のようなエラーになります。
bash
1#!/bin/bash --login 2bundle exec rake db:create 3bundle exec rake db:schema:load 4 5I, [2021-04-20T08:36:32.197469 #9588] INFO -- sentry: ** [Raven] Raven 2.9.0 configured not to capture errors: Not configured to send/capture in environment 'default' 6rake aborted! 7Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 8/home/ubuntu/Hardreggaecafe/vegewel/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in `connect' 9/home/ubuntu/Hardreggaecafe/vegewel/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in `initialize' 10
記載した.circleci/config.ymlです。
yaml
1version: 2 2jobs: 3 build: 4 working_directory: ~/Hardreggaecafe/vegewel 5 parallelism: 1 6 shell: /bin/bash --login 7 environment: 8 CIRCLE_ARTIFACTS: /tmp/circleci-artifacts 9 CIRCLE_TEST_REPORTS: /tmp/circleci-test-results 10 docker: 11 - image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37 12 - image: circleci/ruby:2.5.0-node-browsers 13 environment: 14 - BUNDLER_VERSION: 1.16.1 15 - RAILS_ENV: 'test' 16 - image: circleci/mysql:5.7 17 environment: 18 - MYSQL_ALLOW_EMPTY_PASSWORD: 'true' 19 - MYSQL_ROOT_HOST: '127.0.0.1' 20 steps: 21 - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS 22 - run: 23 working_directory: ~/Hardreggaecafe/vegewel 24 command: pip install pip==20.3.4 25 - run: 26 working_directory: ~/Hardreggaecafe/admin-vegewel 27 command: pip install urllib3==1.26 28 - run: 29 working_directory: ~/Hardreggaecafe/vegewel 30 command: pip install awsebcli --upgrade --user 31 - checkout 32 - run: 33 name: install dependencies 34 command: | 35 gem install bundler -v 2.0.2 36 bundle install --jobs=4 --retry=3 --path vendor/bundle 37 # Database setup 38 - run: mv ./config/database.yml.ci ./config/database.yml 39 - run: 40 name: Databasesetup 41 command: | 42 bundle exec rake db:create 43 bundle exec rake db:schema:load 44 45 # run tests! 46 - run: 47 name: Run rspec 48 command: | 49 mkdir /tmp/test-results 50 TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \ 51 circleci tests split --split-by=timings)" 52 53 bundle exec rspec \ 54 --format progress \ 55 --format RspecJunitFormatter \ 56 --out /tmp/test-results/rspec.xml \ 57 --format progress \ 58 $TEST_FILES 59 60 # collect reports 61 - store_test_results: 62 path: /tmp/test-results 63 - store_artifacts: 64 path: /tmp/test-results 65 destination: test-results 66 67 - run: 68 name: Deploy 69 command: | 70 if [ "${CIRCLE_BRANCH}" == "master" ]; then 71 echo "Deploy production" 72 eb deploy Vegewel-production 73 else 74 echo "Deploy staging" 75 eb deploy vegewel-staging 76 fi 77 78workflows: 79 version: 2 80 build-n-deploy: 81 jobs: 82 - build: 83 filters: 84 branches: 85 only: 86 - staging 87 - master 88
環境ですが、
Ruby 2.5.0
Rails 5.2
MySQL 5.7
でAWSのElasticBeansTalk使っています(なのでEB CLIでeb deployしてます)。
恐らくですが、CircleCI内にRailsとMySQL環境作ろうとして終わってないうちにDBのコマンドを打っているからと思うのですが(画像は実行中のCircleCI)このあたりを制御する方法はあるのでしょうか?
あなたの回答
tips
プレビュー