-
Notifications
You must be signed in to change notification settings - Fork 549
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
GitHub Actions: Add macOS cases. #1170
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Ubuntu | ||
name: Build | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
|
@@ -38,6 +38,16 @@ jobs: | |
# `service mysql restart` fails. | ||
- {os: ubuntu-20.04, ruby: 2.4, db: mysql80, allow-failure: true} | ||
- {os: ubuntu-18.04, ruby: 'head', db: '', allow-failure: true} | ||
# db: A DB's brew package name in macOS case. | ||
# Set a name "db: '[email protected]'" when using an old version. | ||
# MariaDB lastet version | ||
# Allow failure due to the following test failures. | ||
# https://github.com/brianmario/mysql2/issues/965 | ||
# https://github.com/brianmario/mysql2/issues/1152 | ||
- {os: macos-latest, ruby: 2.4, db: mariadb, allow-failure: true} | ||
# MySQL latest version | ||
# Allow failure due to the issue #1165. | ||
- {os: macos-latest, ruby: 2.4, db: mysql, 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,24 @@ | |
|
||
set -eux | ||
|
||
CHANGED_PWD=false | ||
# Change the password recreating the root user on mariadb < 10.2 | ||
# Change the password to be empty. | ||
CHANGED_PASSWORD=false | ||
# Change the password to be empty, recreating the root user on mariadb < 10.2 | ||
# where ALTER USER is not available. | ||
# https://stackoverflow.com/questions/56052177/ | ||
CHANGED_PWD_BY_RECREATE=false | ||
CHANGED_PASSWORD_BY_RECREATE=false | ||
|
||
# Install the default used DB if DB is not set. | ||
if [[ -n ${GITHUB_ACTION-} && -z ${DB-} ]]; then | ||
if [[ -n ${GITHUB_ACTIONS-} && -z ${DB-} ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if command -v lsb_release > /dev/null; then | ||
case "$(lsb_release -cs)" in | ||
xenial | bionic) | ||
sudo apt-get install -qq mysql-server-5.7 mysql-client-core-5.7 mysql-client-5.7 | ||
CHANGED_PWD=true | ||
CHANGED_PASSWORD=true | ||
;; | ||
focal) | ||
sudo apt-get install -qq mysql-server-8.0 mysql-client-core-8.0 mysql-client-8.0 | ||
CHANGED_PWD=true | ||
CHANGED_PASSWORD=true | ||
;; | ||
*) | ||
;; | ||
|
@@ -34,30 +35,30 @@ fi | |
# Install MySQL 5.7 if DB=mysql57 | ||
if [[ -n ${DB-} && x$DB =~ ^xmysql57 ]]; then | ||
sudo bash .travis_mysql57.sh | ||
CHANGED_PWD=true | ||
CHANGED_PASSWORD=true | ||
fi | ||
|
||
# Install MySQL 8.0 if DB=mysql80 | ||
if [[ -n ${DB-} && x$DB =~ ^xmysql80 ]]; then | ||
sudo bash .travis_mysql80.sh | ||
CHANGED_PWD=true | ||
CHANGED_PASSWORD=true | ||
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 | ||
if [[ -n ${GITHUB_ACTION-} ]]; then | ||
if [[ -n ${GITHUB_ACTIONS-} ]]; then | ||
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.0 libmariadb2 | ||
CHANGED_PWD_BY_RECREATE=true | ||
CHANGED_PASSWORD_BY_RECREATE=true | ||
else | ||
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' libmariadbclient-dev | ||
fi | ||
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 | ||
if [[ -n ${GITHUB_ACTION-} ]]; then | ||
if [[ -n ${GITHUB_ACTIONS-} ]]; then | ||
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.1 libmariadb-dev | ||
CHANGED_PWD_BY_RECREATE=true | ||
CHANGED_PASSWORD_BY_RECREATE=true | ||
else | ||
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' libmariadbclient-dev | ||
fi | ||
|
@@ -70,16 +71,29 @@ if [[ -n ${DB-} && x$DB =~ ^xmariadb10.2 ]]; then | |
fi | ||
|
||
# Install MariaDB 10.3 if DB=mariadb10.3 | ||
if [[ -n ${GITHUB_ACTION-} && -n ${DB-} && x$DB =~ ^xmariadb10.3 ]]; then | ||
if [[ -n ${GITHUB_ACTIONS-} && -n ${DB-} && x$DB =~ ^xmariadb10.3 ]]; then | ||
sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.3 libmariadb-dev | ||
CHANGED_PWD=true | ||
CHANGED_PASSWORD=true | ||
fi | ||
|
||
# Install MySQL if OS=darwin | ||
# Install MySQL/MariaDB if OS=darwin | ||
if [[ x$OSTYPE =~ ^xdarwin ]]; then | ||
brew update | ||
brew install "$DB" mariadb-connector-c | ||
$(brew --prefix "$DB")/bin/mysql.server start | ||
brew update > /dev/null | ||
|
||
# Check available packages. | ||
for KEYWORD in mysql mariadb; do | ||
brew search "${KEYWORD}" | ||
done | ||
|
||
brew info "$DB" | ||
brew install "$DB" | ||
DB_PREFIX="$(brew --prefix "${DB}")" | ||
export PATH="${DB_PREFIX}/bin:${PATH}" | ||
export LDFLAGS="-L${DB_PREFIX}/lib" | ||
export CPPFLAGS="-I${DB_PREFIX}/include" | ||
|
||
mysql.server start | ||
CHANGED_PASSWORD_BY_RECREATE=true | ||
fi | ||
|
||
# TODO: get SSL working on OS X in Travis | ||
|
@@ -88,14 +102,12 @@ if ! [[ x$OSTYPE =~ ^xdarwin ]]; then | |
sudo service mysql restart | ||
fi | ||
|
||
# Print the MySQL version and create the test DB | ||
if [[ x$OSTYPE =~ ^xdarwin ]]; then | ||
$(brew --prefix "$DB")/bin/mysqld --version | ||
$(brew --prefix "$DB")/bin/mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test' | ||
else | ||
mysqld --version | ||
mysqld --version | ||
|
||
if [[ -n ${GITHUB_ACTION-} && -f /etc/mysql/debian.cnf ]]; then | ||
MYSQL_OPTS='' | ||
DB_SYS_USER=root | ||
if ! [[ x$OSTYPE =~ ^xdarwin ]]; then | ||
if [[ -n ${GITHUB_ACTIONS-} && -f /etc/mysql/debian.cnf ]]; then | ||
MYSQL_OPTS='--defaults-extra-file=/etc/mysql/debian.cnf' | ||
# Install from packages in OS official packages. | ||
if sudo grep -q debian-sys-maint /etc/mysql/debian.cnf; then | ||
|
@@ -105,25 +117,20 @@ else | |
# xenial | ||
DB_SYS_USER=root | ||
fi | ||
else | ||
# Install from official mysql packages. | ||
MYSQL_OPTS='' | ||
DB_SYS_USER=root | ||
fi | ||
fi | ||
|
||
if [ "${CHANGED_PWD}" = true ]; then | ||
# https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/ | ||
sudo mysql ${MYSQL_OPTS} -u "${DB_SYS_USER}" \ | ||
-e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''" | ||
elif [ "${CHANGED_PWD_BY_RECREATE}" = true ]; then | ||
sudo mysql ${MYSQL_OPTS} -u "${DB_SYS_USER}" <<SQL | ||
if [ "${CHANGED_PASSWORD}" = true ]; then | ||
# https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/ | ||
sudo mysql ${MYSQL_OPTS} -u "${DB_SYS_USER}" \ | ||
-e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''" | ||
elif [ "${CHANGED_PASSWORD_BY_RECREATE}" = true ]; then | ||
sudo mysql ${MYSQL_OPTS} -u "${DB_SYS_USER}" <<SQL | ||
DROP USER 'root'@'localhost'; | ||
CREATE USER 'root'@'localhost' IDENTIFIED BY ''; | ||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION; | ||
FLUSH PRIVILEGES; | ||
SQL | ||
fi | ||
|
||
# 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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new macOS |
||
fi | ||
|
||
mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHANGED_PWD
toCHANGED_PASSWORD
, becausePWD
makes me imaginepwd
(print working directory) command. Sorry it was my typo.