Remove PreDeployment1 script #369
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DBA Dash CI with Folder Source/Destination | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
language: [csharp] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
dotnet-quality: 'ga' | |
- name: Check SDK version | |
run: dotnet --list-sdks | |
- name: Build | |
run: dotnet build -c CLI | |
- name: Build GUI | |
run: dotnet build DBADashGUI -o DBADashBuild\DBADashGUIOnly | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v1.3 | |
- name: Build DB | |
run: msbuild dbadashdb -property:Configuration=CLI | |
- name: Get Version | |
id: GetVersion | |
shell: powershell | |
run: | | |
$path = [System.IO.Path]::Combine((Get-Location),"DBADashBuild\CLI\DBADash.dll") | |
$version = [System.Reflection.Assembly]::LoadFrom($path).GetName().Version | |
$version.ToString(3) | |
Write-Output "BUILD_NUMBER=$($version.ToString(3))" >> $env:GITHUB_OUTPUT | |
- name: Zip | |
shell: powershell | |
run: | | |
$zipPath = "DBADash_${{steps.GetVersion.outputs.BUILD_NUMBER}}.zip" | |
Compress-Archive -Path "DBADashBuild\CLI\*" -DestinationPath $zipPath | |
$guiZipPath = "DBADash_GUI_Only_${{steps.GetVersion.outputs.BUILD_NUMBER}}.zip" | |
Compress-Archive -Path "DBADashBuild\DBADashGUIOnly\*" -DestinationPath $guiZipPath | |
- name: Install SQL | |
uses: potatoqualitee/mssqlsuite@v1.7 | |
with: | |
install: sqlengine | |
collation: Latin1_General_BIN | |
- name: Check SQL Install | |
run: | | |
sqlcmd -S localhost -U sa -P dbatools.I0 -d tempdb -Q "SELECT @@version as Version;" | |
sqlcmd -S localhost -U sa -P dbatools.I0 -d tempdb -Q "SELECT SERVERPROPERTY('Collation') AS Collation;" | |
- name: Install Service to Read from Folder | |
shell: powershell | |
run: | | |
$ErrorActionPreference = "Stop" | |
$zipPath = "DBADash_${{steps.GetVersion.outputs.BUILD_NUMBER}}.zip" | |
$ServiceName = "DBADashReadFromFolder" | |
$InstallPath = "C:\$ServiceName" | |
$DBADashFolderDestination = "C:\Dump" | |
md $DBADashFolderDestination | |
"Extract to $InstallPath" | |
Expand-Archive -Path $zipPath -DestinationPath $InstallPath -Force -ErrorAction Stop | |
Set-Location $InstallPath | |
./dbadashconfig -a SetServiceName --ServiceName $ServiceName | |
./dbadashconfig -c $DBADashFolderDestination -a Add | |
./dbadashconfig -c "Data Source=localhost;UID=sa;pwd=dbatools.I0;Initial Catalog=DBADashDB_GitHubAction;Encrypt=True;TrustServerCertificate=True;" -a SetDestination | |
"Install Service" | |
./DBADashService install --localsystem | |
"Start Service" | |
net start $ServiceName | |
"Wait 60 sec" | |
Start-Sleep -s 60 | |
"Get Logs" | |
Get-ChildItem -Path "$InstallPath\Logs" | Get-Content | |
exit 0 | |
- name: Install Service to Write to Folder | |
shell: powershell | |
run: | | |
$ErrorActionPreference = "Stop" | |
$zipPath = "DBADash_${{steps.GetVersion.outputs.BUILD_NUMBER}}.zip" | |
$ServiceName = "DBADashWriteToFolder" | |
$InstallPath = "C:\$ServiceName" | |
$DBADashFolderDestination = "C:\Dump" | |
"Extract to $InstallPath" | |
Expand-Archive -Path $zipPath -DestinationPath $InstallPath -Force -ErrorAction Stop | |
Set-Location $InstallPath | |
"Configure" | |
./dbadashconfig -a SetServiceName --ServiceName $ServiceName | |
./dbadashconfig -c $DBADashFolderDestination -a SetDestination | |
./dbadashconfig -c "Data Source=localhost;UID=sa;pwd=dbatools.I0;Encrypt=True;TrustServerCertificate=True;" -a Add --PlanCollectionEnabled --SlowQueryThresholdMs 1000 --SchemaSnapshotDBs "*" | |
"Install Service" | |
./DBADashService install --localsystem | |
"Start Service" | |
net start $ServiceName | |
"Wait 60 sec" | |
Start-Sleep -s 60 | |
"Get Logs" | |
Get-ChildItem -Path "$InstallPath\Logs" | Get-Content | |
exit 0 | |
- name: Wait 5min | |
shell: powershell | |
run: | | |
"Wait 5min" | |
Start-Sleep -s 300 | |
- name: Output Log (DBADashWriteToFolder) | |
shell: powershell | |
run: | | |
./Scripts/Get-LogContent -LogPath "C:\DBADashWriteToFolder\Logs" | |
- name: Output Log (DBADashReadFromFolder) | |
shell: powershell | |
run: | | |
./Scripts/Get-LogContent -LogPath "C:\DBADashReadFromFolder\Logs" | |
- name: Output CollectionErrorLog | |
shell: powershell | |
run: | | |
Invoke-Sqlcmd -ServerInstance $params.ServerInstance -Database "DBADashDB_GitHubAction" -Query "SELECT * FROM dbo.CollectionErrorLog" -TrustServerCertificate | Format-Table | |
- name: Output Table Counts | |
shell: powershell | |
run: | | |
./Scripts/Get-TableCounts -ServerInstance "LOCALHOST" -Database "DBADashDB_GitHubAction" | |
- name: Run Pester Tests | |
shell: powershell | |
run: | | |
Install-Module Pester -Force | |
Import-Module Pester -PassThru | |
Invoke-Pester -Output Detailed Scripts\CI_Workflow.Tests.ps1 | |
- name: Output Log and Check for Errors (DBADashWriteToFolder) | |
shell: powershell | |
run: | | |
./Scripts/Get-LogContent -LogPath "C:\DBADashWriteToFolder\Logs" -ThrowError | |
- name: Output Log and Check for Errors (DBADashReadFromFolder) | |
shell: powershell | |
run: | | |
./Scripts/Get-LogContent -LogPath "C:\DBADashReadFromFolder\Logs" -ThrowError |