Skip to content

Commit

Permalink
Test custom chocolatey packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
lauxjpn committed Oct 8, 2023
1 parent 7daed5a commit ae43087
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
maxConnections: 512
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
skipAllTests: false
skipAllTests: true
skipWindowsTests: false
jobs:
BuildAndTest:
Expand All @@ -39,9 +39,7 @@ jobs:
- 10.4.31-mariadb
os:
- ubuntu-latest
include:
- os: windows-latest
dbVersion: 8.0.31-mysql
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -59,12 +57,17 @@ jobs:
$databaseServerVersion = $dbVersionParts[0]
echo "databaseServerVersion=$databaseServerVersion" >> $env:GITHUB_ENV
$skipTests = '${{ env.skipAllTests }}' -eq 'true' -or $os -eq 'windows' -and '${{ env.skipWindowsTests }}' -eq 'true'
# The parenthesis around the second OR argument is mandatory for the expression to work correctly, because in PowerShell, AND and OR
# operators have the SAME precedence.
$skipTests = '${{ env.skipAllTests }}' -eq 'true' -or ($os -eq 'windows' -and '${{ env.skipWindowsTests }}' -eq 'true')
echo "skipTests=$skipTests" >> $env:GITHUB_ENV
$sqlMode = $databaseServerType -eq 'mariadb' ? '${{ env.mariadbSqlMode }}' : $databaseServerType -eq 'mysql' -and $databaseServerVersion.Split('.')[0] -lt 8 ? '${{ env.mysqlLegacySqlMode }}' : '${{ env.mysqlCurrentSqlMode }}'
echo "sqlMode=$sqlMode" >> $env:GITHUB_ENV
$serverExecutable = 'mysqld'
echo "serverExecutable=$serverExecutable" >> $env:GITHUB_ENV
$clientExecutable = $databaseServerType -eq 'mariadb' -and $databaseServerVersion.Split('.')[0] -ge 11 ? 'mariadb' : 'mysql'
echo "clientExecutable=$clientExecutable" >> $env:GITHUB_ENV
Expand All @@ -85,6 +88,7 @@ jobs:
echo "skipTests: ${{ env.skipTests }}"
echo "skipAllTests: ${{ env.skipAllTests }}"
echo "skipWindowsTests: ${{ env.skipWindowsTests }}"
echo "serverExecutable: ${{ env.serverExecutable }}"
echo "clientExecutable: ${{ env.clientExecutable }}"
echo "clientCommandPrefix: ${{ env.clientCommandPrefix }}"
echo "windowsUserTempLocation: ${{ env.windowsUserTempLocation }}"
Expand Down Expand Up @@ -113,8 +117,8 @@ jobs:
uses: actions/cache@v3
if: ${{ env.os == 'windows' }}
with:
path: ${{ env.windowsUserTempLocation }}\${{ env.databaseServerType }}
key: database-windows-${{ env.databaseServerType }}-${{ env.databaseServerVersion }}-v2
path: ${{ env.windowsUserTempLocation }}\Pomelo.Chocolatey.${{ env.databaseServerType }}.Server
key: database-windows-${{ env.databaseServerType }}-${{ env.databaseServerVersion }}-v3
- name: Install Database Server - Linux
if: ${{ env.os == 'linux' }}
shell: pwsh
Expand Down Expand Up @@ -163,9 +167,10 @@ jobs:
run: |
$mySqlServiceName = '${{ env.databaseServerType }}_${{ env.databaseServerVersion }}'
$lowerCaseTableNames = 2
$mySqlBinPath = 'C:\tools\mysql\current\bin'
$mySqlIniPath = 'C:\tools\mysql\current\my.ini'
$mySqlDataPath = 'C:\ProgramData\MySQL\data'
$packageName = 'Pomelo.Chocolatey.${{ env.databaseServerType }}.Server'
$mySqlBinPath = "C:\tools\${packageName}\current\bin"
$mySqlIniPath = "C:\tools\${packageName}\current\my.ini"
$mySqlDataPath = 'C:\ProgramData\${{ env.databaseServerType }}\data'
dir "$env:Temp\${{ env.databaseServerType }}\${{ env.databaseServerVersion }}" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
Expand All @@ -177,30 +182,39 @@ jobs:
}
# choco config set cacheLocation '$(Pipeline.Workspace)/cache/database'
echo "Chocolatey command: choco install '${{ env.databaseServerType }}' '--version=${{ env.databaseServerVersion }}' --params `"/serviceName:$mySqlServiceName`""
choco install '${{ env.databaseServerType }}' '--version=${{ env.databaseServerVersion }}' --params "/serviceName:$mySqlServiceName"
choco install $packageName '--version=${{ env.databaseServerVersion }}' --ignore-dependencies --source 'https://www.myget.org/F/pomelo/api/v2;https://community.chocolatey.org/api/v2' --params "/serviceName:$mySqlServiceName"
Get-Service '*${{ env.databaseServerType }}*' -ErrorAction SilentlyContinue
Stop-Service $mySqlServiceName -Verbose
echo "Update PATH environment variable"
$env:PATH = "$mySqlBinPath;$env:PATH"
# [Environment]::SetEnvironmentVariable('PATH', $env:PATH, 'Machine')
echo "PATH=$env:PATH" >> $env:GITHUB_ENV
echo "Update configuration file"
"lower_case_table_names=$lowerCaseTableNames" >> $mySqlIniPath
Remove-Item $mySqlDataPath/* -Recurse -Force -Verbose
echo "Reinitialize database server"
mysqld --defaults-file="$mySqlIniPath" --initialize-insecure
if ('${{ env.databaseServerType }}' -eq 'mysql')
{
${{ env.serverExecutable }} --defaults-file="$mySqlIniPath" --initialize-insecure
}
else
{
mysql_install_db --datadir="$mySqlDataPath"
}
Start-Service $mySqlServiceName -Verbose
echo "Setup credentials"
${{ env.clientCommandPrefix }} -h localhost -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password12!';"
${{ env.clientCommandPrefix }} -h localhost -u root -pPassword12! -e "SELECT @@version;"
dir "$env:Temp\${{ env.databaseServerType }}\${{ env.databaseServerVersion }}" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
dir "$env:Temp\${packageName}\${{ env.databaseServerVersion }}" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
- name: Setup Database
shell: pwsh
run: ${{ env.clientCommandPrefix }} -u root -pPassword12! -e "SET GLOBAL sql_mode = '${{ env.sqlMode }}'; SET GLOBAL max_connections = ${{ env.maxConnections }};"
Expand Down

0 comments on commit ae43087

Please sign in to comment.