Skip to content

Commit

Permalink
Add GitHub Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
junaruga committed Feb 18, 2021
1 parent ad94a79 commit b4aa547
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 15 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test
on: [push, pull_request]
jobs:
build:
name: >-
${{ matrix.os }} ruby ${{ matrix.ruby }} ${{ matrix.db }}
# Run all the tests on the new environment as much as possible.
# https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
os:
# Comment out ubuntu-20.04 temporarily, as the oldest mysql is 8.0 on it, there is an issue.
# https://github.com/brianmario/mysql2/issues/1165
# - ubuntu-20.04 # focal
- ubuntu-18.04 # bionic
# - ubuntu-16.04 # xenial
ruby:
- '3.0'
- 2.7
- 2.6
- 2.5
- 2.4
- 2.3
- 2.2
- 2.1
db: ['']
allow-failure: [false]
include:
# Allow failure due to Mysql2::Error: Unknown system variable 'session_track_system_variables'.
- {os: ubuntu-16.04, ruby: 2.4, db: mariadb10.0, allow-failure: true}
# Comment out due to .travis_setup.sh freezing.
# - {os: ubuntu-18.04, ruby: 2.4, db: mariadb10.1, allow-failure: false}
# Allow failure due to the issue #1165.
- {os: ubuntu-20.04, ruby: 2.4, db: mariadb10.3, allow-failure: true}
- {os: ubuntu-18.04, ruby: 2.4, db: mysql57, allow-failure: false}
# Allow failure due to the issue #1165.
- {os: ubuntu-20.04, ruby: 2.4, db: mysql80, allow-failure: true}
- {os: ubuntu-18.04, ruby: 'head', db: '', allow-failure: true}
# On the fail-fast: true, it cancels all in-progress jobs
# if any matrix job fails unlike Travis fast_finish.
fail-fast: false
steps:
- uses: actions/checkout@v2
# https://github.com/ruby/setup-ruby
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: ruby -v
- run: bundle install --without benchmarks development
- if: matrix.db != ''
run: echo 'DB=${{ matrix.db }}' >> $GITHUB_ENV
- run: sudo echo "127.0.0.1 mysql2gem.example.com" | sudo tee -a /etc/hosts
- run: bash .travis_setup.sh
- run: bundle exec rake
5 changes: 2 additions & 3 deletions .travis_mysql57.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ apt-get purge -qq '^mysql*' '^libmysql*'
rm -fr /etc/mysql
rm -fr /var/lib/mysql
apt-key add support/5072E1F5.asc
# Verify the repository as add-apt-repository does not.
wget -q --spider http://repo.mysql.com/apt/ubuntu/dists/$(lsb_release -cs)/mysql-5.7
add-apt-repository 'http://repo.mysql.com/apt/ubuntu mysql-5.7'
apt-get update -qq
apt-get install -qq mysql-server libmysqlclient-dev

# https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''"
5 changes: 2 additions & 3 deletions .travis_mysql80.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ apt-get purge -qq '^mysql*' '^libmysql*'
rm -fr /etc/mysql
rm -fr /var/lib/mysql
apt-key add support/5072E1F5.asc
# Verify the repository as add-apt-repository does not.
wget -q --spider http://repo.mysql.com/apt/ubuntu/dists/$(lsb_release -cs)/mysql-8.0
add-apt-repository 'http://repo.mysql.com/apt/ubuntu mysql-8.0'
apt-get update -qq
apt-get install -qq mysql-server libmysqlclient-dev

# https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''"
40 changes: 37 additions & 3 deletions .travis_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

set -eux

# Install the default used DB if DB is not set.
if [[ -z ${DB-} ]]; then
sudo apt-get update -qq
sudo apt-get install -qq mysql-server-5.7 mysql-client-core-5.7 mysql-client-5.7
# sudo service mysql restart
fi

# Install MySQL 5.5 if DB=mysql55
if [[ -n ${DB-} && x$DB =~ ^xmysql55 ]]; then
sudo bash .travis_mysql55.sh
Expand All @@ -19,12 +26,12 @@ fi

# Install MariaDB client headers after Travis CI fix for MariaDB 10.2 broke earlier 10.x
if [[ -n ${DB-} && x$DB =~ ^xmariadb10.0 ]]; then
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' libmariadbclient-dev
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.0 libmariadb2
fi

# Install MariaDB client headers after Travis CI fix for MariaDB 10.2 broke earlier 10.x
if [[ -n ${DB-} && x$DB =~ ^xmariadb10.1 ]]; then
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' libmariadbclient-dev
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.1 libmariadbclient18
fi

# Install MariaDB 10.2 if DB=mariadb10.2
Expand Down Expand Up @@ -52,6 +59,33 @@ if [[ x$OSTYPE =~ ^xdarwin ]]; then
$(brew --prefix "$DB")/bin/mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test'
else
mysqld --version

if [ -f /etc/mysql/debian.cnf ]; then
MYSQL_OPTS='--defaults-extra-file=/etc/mysql/debian.cnf'
# Install from packages in OS official packages.
# Create a testing root user as the default root user does not allow the empty password.
# https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/
sudo cat /etc/mysql/debian.cnf
if sudo grep -q debian-sys-maint /etc/mysql/debian.cnf; then
# bionic, focal
DB_SYS_USER=debian-sys-maint
else
# xenial
DB_SYS_USER=root
fi
else
# Install from official mysql packages.
MYSQL_OPTS=''
DB_SYS_USER=root
fi

sudo mysql ${MYSQL_OPTS} -u "${DB_SYS_USER}" <<SQL
CREATE USER 'root-test'@'localhost' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'root-test'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
SQL
mysql -u root-test -e 'select Host, User, plugin from mysql.user;'

# IF NOT EXISTS is mariadb-10+ only - https://mariadb.com/kb/en/mariadb/comment-syntax/
mysql -u root -e 'CREATE DATABASE /*M!50701 IF NOT EXISTS */ test'
mysql -u root-test -e 'CREATE DATABASE /*M!50701 IF NOT EXISTS */ test'
fi
12 changes: 7 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ group :development do
gem 'rake-compiler-dock', '~> 0.7.0'
end

platforms :rbx do
gem 'rubysl-bigdecimal'
gem 'rubysl-drb'
gem 'rubysl-rake'
end
# On MRI Ruby >= 3.0, rubysl-rake causes the conflict on GitHub Actions.
# rubysl-rake was resolved to 1.0.1, which depends on Ruby
# platforms :rbx do
# gem 'rubysl-bigdecimal'
# gem 'rubysl-drb'
# gem 'rubysl-rake'
# end
2 changes: 1 addition & 1 deletion spec/configuration.yml.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
root:
host: localhost
username: root
username: root-test
password:
database: test

Expand Down

0 comments on commit b4aa547

Please sign in to comment.