2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rails5.0のRSpecをAWS CodeBuildで実行するためにnode, MySQL5.7, yarnをインストールしたときのメモ

Last updated at Posted at 2018-06-09

buildspec.ymlファイルに以下を記述

buildspec.yml
version: 0.2

env:
  variables:
    RAILS_ENV: "test"
    DB_ROOT_PASSWORD: "password"
    DB_HOST: "localhost"
    DB_PASSWORD: "password"
    DB_SOCKET: "/var/run/mysqld/mysqld.sock"

phases:
  install:
    commands:
      - rm -rf db/seeds/test
      - cp -rf db/seeds/development db/seeds/test
      - gem install bundler
      - bundle install
      - curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
      - sudo apt-get install -y nodejs
      - apt-get install -y gnupg procps
      - export DEBIAN_FRONTEND=noninteractive
      - echo "mysql-server mysql-server/root_password password ${DB_ROOT_PASSWORD}" |debconf-set-selections
      - echo "mysql-server mysql-server/root_password_again password ${DB_ROOT_PASSWORD}" |debconf-set-selections
      - apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 5072E1F5
      - echo "deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-5.7" | tee /etc/apt/sources.list.d/mysql.list
      - sudo apt-get update -y
      - sudo apt-get install -y mysql-server
      - service mysql start
      - mysql --version
      - mysql -hlocalhost -uroot -ppassword -P3306 -e "show databases;"
      - mysql -hlocalhost -uroot -ppassword -P3306 -e "show variables like '%sock%';"
      - mysql -hlocalhost -uroot -ppassword -P3306 -e "GRANT ALL PRIVILEGES on *.* to 'root'@'localhost' IDENTIFIED BY '${DB_ROOT_PASSWORD}'; FLUSH PRIVILEGES;"
      - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
      - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
      - sudo apt-get update && sudo apt-get install yarn
      - yarn install
  pre_build:
    commands:
      - bundle exec rails db:setup
  build:
    commands:
      - bundle exec rspec
  post_build:
    commands:
      - echo 'Test completed!'

artifacts:
  files:
    - '**/*'

参考URL

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?