-
-
Notifications
You must be signed in to change notification settings - Fork 65
206 lines (161 loc) · 7.49 KB
/
ci_FolderDestination.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
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@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.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@v2
- 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: Get Build Reference
id: GetBuildReference
shell: powershell
run: |
Invoke-WebRequest -Uri 'https://dataplat.github.io/assets/dbatools-buildref-index.json' -OutFile 'DBADashBuild\CLI\BuildReference.json'
- 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/[email protected]
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: Create Identity Test DB
run: |
sqlcmd -S localhost -U sa -P dbatools.I0 -d tempdb -Q "CREATE DATABASE TestIdentity"
sqlcmd -S localhost -U sa -P dbatools.I0 -d TestIdentity -Q "CREATE TABLE dbo.IdentityTest(ID TINYINT IDENTITY(1,1));DECLARE @i INT=1; WHILE @i <250 BEGIN INSERT INTO dbo.IdentityTest DEFAULT VALUES; SET @i+=1; END"
- 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_FromFolder;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 "Data Source=localhost;UID=sa;pwd=dbatools.I0;Initial Catalog=DBADashDB_Direct;Encrypt=True;TrustServerCertificate=True;" -a AddDestination
./dbadashconfig -c $DBADashFolderDestination -a AddDestination
./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 FromFolder
shell: powershell
run: |
Invoke-Sqlcmd -ServerInstance $params.ServerInstance -Database "DBADashDB_FromFolder" -Query "SELECT * FROM dbo.CollectionErrorLog" -TrustServerCertificate | Format-Table
- name: Output CollectionErrorLog Direct
shell: powershell
run: |
Invoke-Sqlcmd -ServerInstance $params.ServerInstance -Database "DBADashDB_Direct" -Query "SELECT * FROM dbo.CollectionErrorLog" -TrustServerCertificate | Format-Table
- name: Output Table Counts FromFolder
shell: powershell
run: |
./Scripts/Get-TableCounts -ServerInstance "LOCALHOST" -Database "DBADashDB_FromFolder"
- name: Output Table Counts Direct
shell: powershell
run: |
./Scripts/Get-TableCounts -ServerInstance "LOCALHOST" -Database "DBADashDB_Direct"
- name: Run Pester Tests FromFolder
shell: powershell
run: |
Install-Module Pester -Force -SkipPublisherCheck
Import-Module Pester -PassThru
$container = New-PesterContainer -Path 'Scripts\CI_Workflow.Tests.ps1' -Data @{ Database = "DBADashDB_FromFolder" }
Invoke-Pester -Container $container -Output Detailed
- name: Run Pester Tests Direct
shell: powershell
run: |
$container = New-PesterContainer -Path 'Scripts\CI_Workflow.Tests.ps1' -Data @{ Database = "DBADashDB_Direct" }
Invoke-Pester -Container $container -Output Detailed
- 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