Skip to content

Commit e995120

Browse files
authored
Merge pull request #258 from trilogy-libraries/ci-coverage
CI: test again MySQL 9.6 (innovation release)
2 parents e48d000 + ad15389 commit e995120

File tree

7 files changed

+76
-8
lines changed

7 files changed

+76
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
mysql: ["8.0", "8.4"]
21+
mysql: ["8.0", "8.4", "9.5"]
2222
distribution: ["debian:bookworm", "ubuntu:noble", "ubuntu:jammy", "ubuntu:focal"]
2323
ruby: ["3.3", "3.4", "4.0"]
2424
steps:

.github/workflows/macos.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,24 @@ jobs:
1515
name: Test
1616
runs-on: macos-latest
1717
strategy:
18+
fail-fast: false
1819
matrix:
19-
mysql: ["8.0", "8.4"]
20+
mysql: ["8.0", "8.4", "9.6"]
2021
steps:
2122
- uses: actions/checkout@v6
2223
- name: Setup MySQL
2324
run: |
2425
brew install mysql@${{ matrix.mysql }}
26+
# Apply macOS-specific config if it exists (e.g., 8.4 needs mysql_native_password=ON)
27+
# Homebrew MySQL reads config from $(brew --prefix)/etc/my.cnf
28+
if [[ -f "test/mysql/conf.d/${{ matrix.mysql }}/macos.cnf" ]]; then
29+
cat test/mysql/conf.d/${{ matrix.mysql }}/macos.cnf >> $(brew --prefix)/etc/my.cnf
30+
fi
2531
(unset CI; brew postinstall mysql@${{ matrix.mysql }})
2632
brew services start mysql@${{ matrix.mysql }}
2733
sleep 5
2834
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot -e 'CREATE DATABASE test'
35+
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/caching_sha2_password_user.sql
2936
- name: Build
3037
run: CFLAGS="-I$(brew --prefix openssl@1.1)/include" LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" make all test/test
3138
- name: test
@@ -34,8 +41,9 @@ jobs:
3441
name: Test Ruby
3542
runs-on: macos-latest
3643
strategy:
44+
fail-fast: false
3745
matrix:
38-
mysql: ["8.0"]
46+
mysql: ["8.0", "8.4", "9.6"]
3947
ruby: ["3.0", "3.1", "3.2", "3.3", "3.4", "4.0"]
4048
steps:
4149
- uses: actions/checkout@v6
@@ -47,12 +55,20 @@ jobs:
4755
MYSQL_VERSION: ${{ matrix.mysql }}
4856
run: |
4957
brew install mysql@${{ matrix.mysql }}
58+
# Apply macOS-specific config if it exists (e.g., 8.4 needs mysql_native_password=ON)
59+
# Homebrew MySQL reads config from $(brew --prefix)/etc/my.cnf
60+
if [[ -f "test/mysql/conf.d/${{ matrix.mysql }}/macos.cnf" ]]; then
61+
cat test/mysql/conf.d/${{ matrix.mysql }}/macos.cnf >> $(brew --prefix)/etc/my.cnf
62+
fi
5063
(unset CI; brew postinstall mysql@${{ matrix.mysql }})
5164
brew services start mysql@${{ matrix.mysql }}
5265
sleep 5
5366
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot -e 'CREATE DATABASE test'
54-
[[ "$MYSQL_VERSION" == "8.0" ]] && $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/caching_sha2_password_user.sql
55-
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/native_password_user.sql
67+
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/caching_sha2_password_user.sql
68+
# mysql_native_password plugin was removed in MySQL 9.x
69+
if [[ ! "${{ matrix.mysql }}" =~ ^9 ]]; then
70+
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot -e "CREATE USER 'native'@'%'; GRANT ALL PRIVILEGES ON test.* TO 'native'@'%'; ALTER USER 'native'@'%' IDENTIFIED WITH mysql_native_password BY 'password';"
71+
fi
5672
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/x509_user.sql
5773
$(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/cleartext_user.sql
5874
- name: Install dependencies

contrib/ruby/test/auth_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ def has_caching_sha2?
1717
server_version.split(".", 2)[0].to_i >= 8
1818
end
1919

20+
def has_native_password_plugin?
21+
new_tcp_client.query("SELECT PLUGIN_NAME FROM information_schema.plugins WHERE PLUGIN_NAME = 'mysql_native_password'").count > 0
22+
rescue Trilogy::Error
23+
false
24+
end
25+
2026
def test_connect_native_with_password
27+
return skip unless has_native_password_plugin?
2128
create_and_delete_test_user(username: "native", auth_plugin: "mysql_native_password") do
2229
client = new_tcp_client username: "native", password: "password"
2330

@@ -86,6 +93,7 @@ def test_connect_without_ssl_or_unix_socket_caching_sha2_raises
8693
end
8794

8895
def test_connection_error_native
96+
return skip unless has_native_password_plugin?
8997
create_and_delete_test_user(username: "native", auth_plugin: "mysql_native_password") do
9098

9199
err = assert_raises Trilogy::ConnectionError do

test/mysql/conf.d/8.4/macos.cnf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# macOS-specific MySQL configuration (used by brew)
2+
# Docker uses build.cnf which has additional SSL paths
3+
4+
[mysqld]
5+
mysql_native_password=ON

test/mysql/conf.d/9.5/build.cnf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This MySQL configuration file is mounted into the Database container (/etc/mysql/conf.d)
2+
# at boot and is picked up automatically.
3+
4+
[mysqld]
5+
6+
sql_mode = NO_ENGINE_SUBSTITUTION
7+
8+
server_id = 1
9+
gtid_mode = ON
10+
enforce_gtid_consistency = ON
11+
log_bin = mysql-bin.log
12+
13+
# Since we generate our own certificates for testing purposes, we need to instruct MySQL
14+
# on where to find them. The certifcates are generated as an entrypoint script located at:
15+
# mysql/docker-entrypoint-initdb.d/generate_keys.sh
16+
# The /mysql-certs directory is mounted into both the database container and the app
17+
# container so that they both can have access to the generated certificates.
18+
# --
19+
ssl_ca = /mysql-certs/ca.pem
20+
ssl_cert = /mysql-certs/server-cert.pem
21+
ssl_key = /mysql-certs/server-key.pem
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
# Create native password user only if MySQL version < 9.
4+
# MySQL 9.x completely removed the mysql_native_password plugin.
5+
6+
set -euo pipefail
7+
8+
# Get MySQL major version (use -h localhost to avoid MYSQL_HOST env var)
9+
MYSQL_MAJOR_VERSION=$(mysql -h localhost -uroot -N -e "SELECT SUBSTRING_INDEX(VERSION(), '.', 1)")
10+
11+
if [[ "$MYSQL_MAJOR_VERSION" -lt 9 ]]; then
12+
echo "MySQL $MYSQL_MAJOR_VERSION.x detected, creating native password user..."
13+
mysql -h localhost -uroot <<EOF
14+
CREATE USER 'native'@'%';
15+
GRANT ALL PRIVILEGES ON test.* TO 'native'@'%';
16+
ALTER USER 'native'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
17+
EOF
18+
echo "native user created successfully"
19+
else
20+
echo "MySQL $MYSQL_MAJOR_VERSION.x detected, mysql_native_password not available, skipping native user creation"
21+
fi

test/mysql/docker-entrypoint-initdb.d/native_password_user.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)