Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinstreicher/c22363334aae8673d5d27b60787a2856 to your computer and use it in GitHub Desktop.
Save martinstreicher/c22363334aae8673d5d27b60787a2856 to your computer and use it in GitHub Desktop.
Connect Codeship to a local install of MySQL 5.7
#
# Setup
export MYSQL_DIR="$HOME/mysql-5.7"
export MYSQL_PORT="3307"
export MYSQL_SOCKET="$MYSQL_DIR/socket/mysqld.sock"
export PATH="$MYSQL_DIR/bin:$PATH"
export RAILS_ENV=test
\curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/mysql-5.7.sh | bash -s
# If `.ruby-version` file is present, RVM will set Ruby to the declared version.
if [ -f .ruby-version ]; then rvm use $(cat .ruby-version) --install; fi
bundle config build.mysql --with-mysql-dir=$MYSQL_DIR
bundle install
#
# Pipeline
rubocop
cp config/database.yml.codeship config/database.yml
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rspec
#
# database.yml.codeship
development:
adapter: mysql2
database: development<%= ENV['TEST_ENV_NUMBER'] %>
encoding: utf8
host: localhost
password: <%= ENV['MYSQL_PASSWORD'] %>
pool: 10
port: <%= ENV['MYSQL_PORT'] %>
socket: <%= ENV['MYSQL_SOCKET'] %>
username: <%= ENV['MYSQL_USER'] %>
test:
adapter: mysql2
database: test<%= ENV['TEST_ENV_NUMBER'] %>
encoding: utf8
host: localhost
password: <%= ENV['MYSQL_PASSWORD'] %>
pool: 10
port: <%= ENV['MYSQL_PORT'] %>
socket: <%= ENV['MYSQL_SOCKET'] %>
username: <%= ENV['MYSQL_USER'] %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment