Skip to content

Commit 2df2896

Browse files
Add MySQL 8 to CI (#564)
1 parent e25ea9e commit 2df2896

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
- "1.11.4-erlang-21.3.8.24-alpine-3.13.3"
4444
mysql:
4545
- "5.7"
46+
- "8.0"
4647
steps:
4748
- uses: earthly/actions-setup@v1
4849
- uses: actions/checkout@v3

Earthfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ integration-test-mysql:
110110
--pull "mysql:$MYSQL"
111111
RUN set -e; \
112112
timeout=$(expr $(date +%s) + 30); \
113-
docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "mysql:$MYSQL" --sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES"; \
113+
docker run --name mysql --network=host -d -e MYSQL_ROOT_PASSWORD=root "mysql:$MYSQL" \
114+
--sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES" \
115+
# the default authentication plugin for MySQL 8 is sha 256 but it doesn't come with the docker image. falling back to the 5.7 way
116+
--default-authentication-plugin=mysql_native_password; \
114117
# wait for mysql to start
115118
while ! mysqladmin ping --host=127.0.0.1 --port=3306 --protocol=TCP --silent; do \
116119
test "$(date +%s)" -le "$timeout" || (echo "timed out waiting for mysql"; exit 1); \

integration_test/myxql/test_helper.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ Application.put_env(:ecto_sql, TestRepo,
1919
url: Application.get_env(:ecto_sql, :mysql_test_url) <> "/ecto_test",
2020
pool: Ecto.Adapters.SQL.Sandbox,
2121
show_sensitive_data_on_connection_error: true,
22+
after_connect: {Ecto.Integration.TestRepo, :set_connection_charset, []},
2223
log: false
2324
)
2425

2526
defmodule Ecto.Integration.TestRepo do
2627
use Ecto.Integration.Repo, otp_app: :ecto_sql, adapter: Ecto.Adapters.MyXQL
2728

29+
def set_connection_charset(conn) do
30+
%{rows: [[version]]} = MyXQL.query!(conn, "SELECT @@version", [])
31+
32+
if version >= "8.0.0" do
33+
_ = MyXQL.query!(conn, "SET NAMES utf8mb4 COLLATE utf8mb4_0900_ai_ci;", [])
34+
end
35+
end
36+
2837
def create_prefix(prefix) do
2938
"create database #{prefix}"
3039
end

0 commit comments

Comments
 (0)