Skip to content

Commit 21dcc8f

Browse files
author
Pierre-Luc Gagné
committed
Improve MSVC MySQL tool detection and startup
1 parent 6f225aa commit 21dcc8f

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,17 @@ jobs:
218218
shell: pwsh
219219
run: |
220220
$mysqlCmd = Get-Command mysql -ErrorAction SilentlyContinue
221-
if (-not $mysqlCmd) {
221+
$mysqldCmd = Get-Command mysqld -ErrorAction SilentlyContinue
222+
if (-not $mysqlCmd -or -not $mysqldCmd) {
222223
choco install mysql --no-progress -y
223224
}
224225
226+
$mysqlCmd = Get-Command mysql -ErrorAction SilentlyContinue
227+
$mysqldCmd = Get-Command mysqld -ErrorAction SilentlyContinue
228+
if (-not $mysqlCmd -or -not $mysqldCmd) {
229+
throw "MySQL client/server binaries not available on PATH after installation"
230+
}
231+
225232
- name: Detect MySQL root
226233
shell: pwsh
227234
run: |
@@ -268,6 +275,12 @@ jobs:
268275
shell: pwsh
269276
run: |
270277
function Find-Tool([string]$toolName) {
278+
$toolBase = [System.IO.Path]::GetFileNameWithoutExtension($toolName)
279+
$fromPath = Get-Command $toolBase -ErrorAction SilentlyContinue
280+
if ($fromPath -and (Test-Path $fromPath.Source)) {
281+
return $fromPath.Source
282+
}
283+
271284
$candidates = @(
272285
(Join-Path $env:MYSQL_BIN_DIR $toolName),
273286
(Join-Path $env:MYSQL_ROOT_DIR $toolName),
@@ -301,7 +314,7 @@ jobs:
301314
302315
New-Item -ItemType Directory -Force -Path $dataDir | Out-Null
303316
304-
& $mysqldExe --initialize-insecure --basedir="$env:MYSQL_ROOT_DIR" --datadir="$dataDir" --console
317+
& $mysqldExe --initialize-insecure --datadir="$dataDir" --console
305318
if ($LASTEXITCODE -ne 0) {
306319
throw "mysqld --initialize-insecure failed with exit code $LASTEXITCODE"
307320
}
@@ -315,7 +328,6 @@ jobs:
315328
Write-Host "Trying MySQL port $port"
316329
317330
$process = Start-Process -FilePath $mysqldExe -ArgumentList @(
318-
"--basedir=$env:MYSQL_ROOT_DIR",
319331
"--datadir=$dataDir",
320332
"--port=$port",
321333
"--bind-address=$env:DS_MYSQL_TEST_HOST",

0 commit comments

Comments
 (0)