Skip to content

Commit db4462f

Browse files
Copilotkerryjiang
andcommitted
Use MySQL Docker service in CI for reliable authentication setup
Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
1 parent e541db7 commit db4462f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14+
services:
15+
mysql:
16+
image: mysql:8.0
17+
env:
18+
MYSQL_ROOT_PASSWORD: root
19+
MYSQL_DATABASE: test
20+
ports:
21+
- 3306:3306
22+
options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=5s --health-retries=3
1423
steps:
1524
- uses: actions/checkout@v1
1625
- name: Setup .NET Core
@@ -29,12 +38,9 @@ jobs:
2938
dotnet nuget locals all --clear
3039
- name: Build
3140
run: dotnet build -c Debug
32-
- name: Run MySQL
41+
- name: Setup MySQL auth
3342
run: |
34-
cp tests/SuperSocket.MySQL.Test/mysql.cnf ~/.my.cnf
35-
sudo systemctl start mysql.service
36-
mysql -V
37-
sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; FLUSH PRIVILEGES;"
43+
mysql -h 127.0.0.1 -u root -proot -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'; FLUSH PRIVILEGES;"
3844
- name: Test
3945
run: |
4046
cd tests/SuperSocket.MySQL.Test

tests/SuperSocket.MySQL.Test/TestConst.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace SuperSocket.MySQL.Test
22
{
33
public static class TestConst
44
{
5-
public const string Host = "localhost";
5+
public const string Host = "127.0.0.1";
66

77
public const string Username = "root";
88

0 commit comments

Comments
 (0)