Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mysql jobs in CI build matrix #940

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
ruby-version: ${{ matrix.ruby }}
version: ${{ matrix.ruby }}
- uses: actions/checkout@v1
- run: sudo apt-get update && sudo apt-get install libpq-dev postgresql-client libmysqlclient-dev libsqlite3-dev -y
- run: sudo apt-get update && sudo apt-get install libpq-dev postgresql-client libmysqlclient-dev mysql-client libsqlite3-dev -y
Copy link
Contributor Author

@mattbrictson mattbrictson Apr 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mysql-client is needed because rake db:create uses the mysql CLI.

- id: cache-bundler
uses: actions/cache@v1
with:
Expand Down Expand Up @@ -52,4 +52,9 @@ jobs:
image: postgres:11.5
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

mysql:
image: mysql:5.7
ports: ["3306:3306"]
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
env:
MYSQL_ROOT_PASSWORD: root
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace :db do
driver = FriendlyId::Test::Database.driver
config = FriendlyId::Test::Database.config[driver]
commands = {
"mysql" => "mysql -u #{config['username']} --password=#{config['password']} -e 'create database #{config["database"]};' >/dev/null",
"mysql" => "mysql -h #{config['host']} -P #{config['port']} -u #{config['username']} --password=#{config['password']} -e 'create database #{config["database"]};' >/dev/null",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add host and port, otherwise mysql would try (and fail) to connect to /var/lib/mysql/mysql.sock.

"postgres" => "psql -c 'create database #{config['database']};' -U #{config['username']} >/dev/null"
}
%x{#{commands[driver] || true}}
Expand All @@ -83,7 +83,7 @@ namespace :db do
driver = FriendlyId::Test::Database.driver
config = FriendlyId::Test::Database.config[driver]
commands = {
"mysql" => "mysql -u #{config['username']} --password=#{config['password']} -e 'drop database #{config["database"]};' >/dev/null",
"mysql" => "mysql -h #{config['host']} -P #{config['port']} -u #{config['username']} --password=#{config['password']} -e 'drop database #{config["database"]};' >/dev/null",
"postgres" => "psql -c 'drop database #{config['database']};' -U #{config['username']} >/dev/null"
}
%x{#{commands[driver] || true}}
Expand Down
3 changes: 2 additions & 1 deletion test/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ mysql:
database: friendly_id_test
username: root
password: <%= ENV['MYSQL_PASSWORD'] %>
hostname: localhost
host: 127.0.0.1
port: 3306
encoding: utf8

postgres:
Expand Down