forked from microsoft/ReportingServicesTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappveyor.yml
126 lines (111 loc) · 6.33 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
# 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
build: false
before_test:
- cmd: NET USER rsuser1 "%SqlSaPwd%" /ADD /Y
- ps: |
$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 SQLServer2017 -DatabaseServerName localhost -DatabaseName ReportServer -DatabaseCredentialType ServiceAccount -Confirm:$false
Set-PbiRsUrlReservation -ReportServerInstance PBIRS -ReportServerVersion SQLServer2017
Initialize-Rs -ReportServerInstance PBIRS -ReportServerVersion SQLServer2017
Stop-Service PowerBIReportServer
Start-Service PowerBIReportServer
Start-Service SQLSERVERAGENT
Write-Host "Configuration completed" (Get-Date).DateTime
test_script:
- ps: |
# Execute the script analyzer
$results = Invoke-ScriptAnalyzer -Path .\ReportingServicesTools\functions -Recurse | where severity -eq "Error"
# 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"}
# Integration test section
# Activate verbose on Powershell
$VerbosePreference = "continue"
# Executing integration tests
$resultsIT = Invoke-Pester -Path ".\Tests" -OutputFormat NUnitXml -OutputFile TestsResultsIT.xml -PassThru
# 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))
# 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}
}