forked from microsoft/ReportingServicesTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appveyor.yml
159 lines (141 loc) · 8.22 KB
/
appveyor.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
# See http://www.appveyor.com/docs/appveyor-yml for many more options
environment:
galleryPublishingKey:
secure: 0PgkUpRd+qAfL0WFe5pFmOE/KasEJY19wogMfkRzk1NFqFqfDGLIU+CPbd1ZoR+1
access_token:
secure: kGlQZapsnS3J41iYVKMP4kqeYcSeFRPI3rXNxl5GwgkcnPiGJxQmU+HO30xaegQq
SqlSaPwd: i<3ReportingServices
# Skip on updates to the readme.
# We can force this by adding [skip ci] or [ci skip] anywhere in commit message
skip_commits:
message: /updated readme.*/
install:
- ps: Install-PackageProvider -Name NuGet -Force
- ps: Install-Module -Name PSScriptAnalyzer -Force
- ps: Install-Module -Name Pester -RequiredVersion 4.10.1
build: false
before_test:
- cmd: NET USER rsuser1 "%SqlSaPwd%" /ADD /Y
- ps: |
write-host "Showing Version of Pester"
write-host "PbiRS Download URL $($env:pbirsDownloadUrl)"
gci "C:\Program Files\WindowsPowerShell\Modules\Pester"
$ErrorActionPreference = 'Stop';
[Environment]::SetEnvironmentVariable("RsUser", "$($env:ComputerName)\rsuser1")
$url = "$($env:downloadUrl)/SQLServer2017-x64-ENU.exe"
$urlBox = "$($env:downloadUrl)/SQLServer2017-x64-ENU.box"
$pbiRsUrl = "$($env:pbirsDownloadUrl)/PowerBIReportServer.exe"
#arguments sqlserver needs for the installation
$silentArgs = "/IACCEPTSQLSERVERLICENSETERMS /Q /ACTION=install /INSTANCENAME=MSSQLSERVER /UPDATEENABLED=FALSE /FEATURES=SQLEngine /SQLSYSADMINACCOUNTS=`"BUILTIN\Administrators`" /SECURITYMODE=SQL /SAPWD=`"$($env:SqlSaPwd)`""
$tempDir = Join-Path (Get-Item $env:TEMP).FullName "sql2017"
if ((Test-Path $tempDir) -eq $false) { New-Item -ItemType Directory -Path $tempDir}
$fileFullPath = "$tempDir\SQLServer.exe"
$fileFullPathBox = "$tempDir\SQLServer.box"
$fileFullPathPbiRs = "$tempDir\PowerBIReportServer.exe"
Write-Host "Downloading... SQL Engine exe" (Get-Date).DateTime
(New-Object Net.WebClient).DownloadFile($url , $fileFullPath)
Write-Host "Downloading... SQL Engine box" (Get-Date).DateTime
(New-Object Net.WebClient).DownloadFile($urlBox , $fileFullPathBox)
Write-Host "Downloading... PBIRS" (Get-Date).DateTime
(New-Object Net.WebClient).DownloadFile($pbiRsUrl , $fileFullPathPbiRs)
Write-Host "Extracting..." (Get-Date).DateTime
$extractPath = "$tempDir\SQL2017TEMP"
Start-Process "$fileFullPath" "/Q /x:`"$extractPath`"" -Wait
Write-Host "Installing SQL Server..." (Get-Date).DateTime
Write-Host "Installation args: $silentArgs"
$setupPath = "$extractPath\setup.exe"
Start-Process $setupPath "$silentArgs" -Wait
Write-Host "Installation completed" (Get-Date).DateTime
Write-Host "Installing PBI RS" (Get-Date).DateTime
$pbiServerSilentArgs = "/Q /NORESTART IACCEPTLICENSETERMS=true"
Start-Process $fileFullPathPbiRs "$pbiServerSilentArgs" -Wait
Write-Host "Installation completed" (Get-Date).DateTime
Write-Host "Importing SQLPS Module..." (Get-Date).DateTime
Import-Module "C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\sqlps\sqlps.psd1"
Write-Host "SQLPS Module imported" (Get-Date).DateTime
# Activate verbose on Powershell
$VerbosePreference = "continue"
# Import Reporting Services tools
Import-Module .\ReportingServicesTools\ReportingServicesTools.psd1
Write-Host "Configuring PBI RS" (Get-Date).DateTime
Set-RsDatabase -ReportServerInstance PBIRS -ReportServerVersion SQLServervNext -DatabaseServerName localhost -DatabaseName ReportServer -DatabaseCredentialType ServiceAccount -Confirm:$false
Set-PbiRsUrlReservation -ReportServerInstance PBIRS -ReportServerVersion SQLServervNext
try {Initialize-Rs -ReportServerInstance PBIRS -ReportServerVersion SQLServervNext} catch {}
Stop-Service PowerBIReportServer
Start-Service PowerBIReportServer
Start-Service SQLSERVERAGENT
Write-Host "Configuration completed" (Get-Date).DateTime
test_script:
- ps: |
# Execute the script analyzer
Write-Host "Starting execution of script analyzer"
$results = Invoke-ScriptAnalyzer -Path .\ReportingServicesTools\functions -Recurse | where severity -eq "Error"
Write-Host "Completed execution of script analyzer"
# Format the results
$header = "<testsuite tests=`"$($results.Count)`">"
$body = $results | ForEach-Object {"<testcase classname=`"analyzer`" name=`"$($_.RuleName)`"><failure type=`"$($_.ScriptName)`">$($_.Message)</failure></testcase>"}
$footer = "</testsuite>"
$header + $body +$footer | out-file .\TestsResults.xml
# Upload results
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.xml))
# Fail if thre are issues
if($results.Count -gt 0){throw "ScriptAnalyzer found $($results.Count) issues"}
# Enable additional file formats
$newSettings = New-Object PSCustomObject -Property @{"PropertyValues" = @( @{"@odata.type"="#Model.Property"; "Name" = "AllowedResourceExtensionsForUpload"; "Value" = "*,*.xml,*.xsd,*.xsl,*.png,*.gif,*.jpg,*.tif,*.jpeg,*.tiff,*.bmp,*.pdf,*.svg,*.rtf,*.txt,*.doc,*.docx,*.pps,*.ppt,*.pptx,*.xlsx"})}
$stringNewRequest = $newSettings | ConvertTo-JSON -Depth 5
$isAllowedFileFormatUpdated = $false
for ($i=0 ; $i -le 10 -and $isAllowedFileFormatUpdated -eq $false ;$i++){
try{
$isAllowedFileFormatUpdated = $true;
Invoke-RestMethod -Uri "http://localhost/reports/api/v1.0/ReportServerInfo/Model.UpdateSettings" -Method POST -UseDefaultCredentials -ContentType 'application/json' -Body $stringNewRequest
Write-Host "Enable additional file formats completed" (Get-Date).DateTime
}
catch{
write-host $_.Exception
$isAllowedFileFormatUpdated = $false
Start-Sleep -Seconds 1
}
}
if ($isAllowedFileFormatUpdated -eq $false) {
Write-Host "Dumping Server Logs"
gci "C:\Program Files\Microsoft Power BI Report Server\PBIRS\LogFiles\*" -Include *.log | Get-Content
throw (New-Object System.Exception("Failed to update the AllowedResourceExtensionsForUpload"))
}
# Integration test section
Write-Host "Starting execution of Pester Tests"
# Activate verbose on Powershell
$VerbosePreference = "continue"
# Executing integration tests
$resultsIT = Invoke-Pester -Path ".\Tests" -OutputFormat NUnitXml -OutputFile TestsResultsIT.xml -PassThru
Write-Host "Completed execution of Pester Tests"
# Upload integration tests results
$wcIT = New-Object 'System.Net.WebClient'
$wcIT.UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResultsIT.xml))
Write-Host "Dumping Server Logs"
gci "C:\Program Files\Microsoft Power BI Report Server\PBIRS\LogFiles\*" -Include *.log | Get-Content
# Fail if thre are issues on integration tests
if($resultsIT.FailedCount -gt 0){throw "Integration Test found $($resultsIT.FailedCount) issues"}
deploy_script:
- ps: |
# Deploy to Powershell Gallery only where there is a tag which will have the version number
$ErrorActionPreference = 'Continue';
$deploy = ($env:APPVEYOR_REPO_TAG -eq $true)
if ($deploy)
{
$gitOut = git checkout master 2>&1
Write-Host "Starting Deployment tag $env:APPVEYOR_REPO_TAG_NAME"
$moduleName = "ReportingServicesTools"
$currentVersion = (Import-PowerShellDataFile .\ReportingServicesTools\$moduleName.psd1).ModuleVersion
((Get-Content .\ReportingServicesTools\ReportingServicesTools.psd1).replace("ModuleVersion = '$($currentVersion)'", "ModuleVersion = '$($env:APPVEYOR_REPO_TAG_NAME)'")) | Set-Content .\ReportingServicesTools\$moduleName.psd1
Publish-Module -Path .\ReportingServicesTools -NuGetApiKey $env:galleryPublishingKey
git config --global core.safecrlf false
git config --global credential.helper store
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):[email protected]`n"
git config --global user.email "[email protected]"
git config --global user.name "Jaime Tarquino"
git add ReportingServicesTools\ReportingServicesTools.psd1
git commit -m "Automatic Version Update from CI"
$gitOut = git push 2>&1
if ($?) {$out} else {$out.Exception}
}