はじめに
Support for CircleCI 1.0 will end on August 31, 2018. Gain more flexibility with workflows, customize your environment with Docker, and access more powerful resources with CircleCI 2.0.
今までのCircleCI 1.0の設定で動くので8月までなので、CricelCI 2.0の設定に書き直す必要が出る。
設定例
.circleci/config.yml
version: 2
jobs:
build:
working_directory: ~/app
docker:
- image: circleci/ruby:2.5.1-node-browsers
environment:
RAILS_ENV: test
- image: mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
steps:
- checkout
- restore_cache:
keys:
- app-{{ checksum "Gemfile.lock" }}-{{ checksum "yarn.lock" }}
- app-
- run: bundle install --path vendor/bundle
- run: yarn install
- save_cache:
key: app-{{ checksum "Gemfile.lock" }}-{{ checksum "yarn.lock" }}
paths:
- vendor/bundle
- node_modules
- run: cp config/database.yml.circleci config/database.yml
- run: bundle exec rake db:create db:schema:load
- run: bundle exec bin/webpack
- run: bundle exec rspec
config/database.yml.circleci
test:
adapter: mysql2
encoding: utf8
pool: 5
database: app_test
username: root
password:
host: 127.0.0.1
引っかかったところ
- database.ymlのhostは
localhost
だと接続できない - mysqlにパスワードなしで接続する場合は
MYSQL_ALLOW_EMPTY_PASSWORD
をyes
に設定しておく