Skip to content

Commit 7b6cd1f

Browse files
committed
Integrating build with CoverRalls
1 parent 87d2c99 commit 7b6cd1f

2 files changed

Lines changed: 41 additions & 25 deletions

File tree

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ branches:
77
environment:
88
sonartoken:
99
secure: DRj3fNloTg/lBt6VibH5zebVnMv0pF7+lXBkaR28lR4Iu3g4KSyXl6Vn+Ni/Nx96
10+
coverallstoken:
11+
secure: rq9rS0GTzSpI+qdT6UjfOphfjLRxUKqwPdY+CzM4rH1Iq68orl6bhFI7e051lPuA
1012
nuget:
1113
disable_publish_on_pr: true
1214
build_script:

scripts/Build.ps1

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ echo "Build entire solution"
5656
exec { & dotnet build -c Release }
5757

5858
echo "Tests Core version"
59-
dotnet test -c Release --test-adapter-path:. --logger:"nunit;LogFilePath=$($env:APPVEYOR_BUILD_FOLDER)\TestResults\core-results.xml"
59+
dotnet test -c Release --test-adapter-path:. --logger:"nunit;LogFilePath=$($env:APPVEYOR_BUILD_FOLDER)\TestResults\core-results.xml" -s "$($env:APPVEYOR_BUILD_FOLDER)\coverletArgs.runsettings" -r "$($env:APPVEYOR_BUILD_FOLDER)\TestResults\"
6060

6161
$corePassed = $lastexitcode
6262

@@ -111,25 +111,6 @@ Catch
111111
else { echo "sonarscanner already installed" }
112112
}
113113

114-
echo "Installing reportgenerator"
115-
Try
116-
{
117-
exec { & dotnet tool install -g dotnet-reportgenerator-globaltool }
118-
}
119-
Catch
120-
{
121-
$needInstallSonar = dotnet tool list -g | Select-String -Pattern "dotnet-reportgenerator-globaltool" | % { $_.Matches.Value -eq $NULL }
122-
if ($needInstallSonar -eq $true)
123-
{
124-
$ErrorMessage = $_.Exception.Message
125-
$FailedItem = $_.Exception.ItemName
126-
echo $FailedItem
127-
echo $ErrorMessage
128-
return -1
129-
}
130-
else { echo "reportgenerator already installed" }
131-
}
132-
133114
echo "Starting Sonar for Library"
134115

135116
if ($env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null)
@@ -146,7 +127,6 @@ if ($env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null)
146127
/d:sonar.pullrequest.provider="GitHub" `
147128
/d:sonar.pullrequest.github.repository="$env:APPVEYOR_REPO_NAME" `
148129
}
149-
#/d:sonar.coverageReportPaths="$($env:APPVEYOR_BUILD_FOLDER)\testresults\SonarQube.xml" }
150130
}
151131
else
152132
{
@@ -158,16 +138,50 @@ else
158138
/d:sonar.host.url="https://sonarcloud.io" `
159139
/version:"$completeVersion" `
160140
}
161-
#/d:sonar.coverageReportPaths="$($env:APPVEYOR_BUILD_FOLDER)\testresults\SonarQube.xml" }
162141
}
163142

164143
exec { & dotnet build $libraryOnlySolutionPath -c Release }
165144

166-
#dotnet test -c Release -s "$($env:APPVEYOR_BUILD_FOLDER)\coverletArgs.runsettings" -r "$($env:APPVEYOR_BUILD_FOLDER)\TestResults\"
145+
exec { & dotnet sonarscanner end /d:sonar.login="$env:sonartoken" }
146+
147+
echo "Code Coverage information"
167148

168-
#exec { & reportgenerator "-reports:$($env:APPVEYOR_BUILD_FOLDER)\TestResults\*\*.xml" "-targetdir:$($env:APPVEYOR_BUILD_FOLDER)\TestResults\" "-reporttypes:SonarQube" }
149+
$opencoverFile = Get-ChildItem -Path "$($env:APPVEYOR_BUILD_FOLDER)\TestResults" -Filter coverage.opencover.xml -Recurse -ErrorAction SilentlyContinue -Force
169150

170-
exec { & dotnet sonarscanner end /d:sonar.login="$env:sonartoken" }
151+
Copy-Item $opencoverFile.FullName -Destination "$($env:APPVEYOR_BUILD_FOLDER)\TestResults"
152+
153+
echo "Installing coverralls"
154+
Try
155+
{
156+
exec { & dotnet tool install -g coveralls.net }
157+
}
158+
Catch
159+
{
160+
$needInstallSonar = dotnet tool list -g | Select-String -Pattern "coveralls.net" | % { $_.Matches.Value -eq $NULL }
161+
if ($needInstallSonar -eq $true)
162+
{
163+
$ErrorMessage = $_.Exception.Message
164+
$FailedItem = $_.Exception.ItemName
165+
echo $FailedItem
166+
echo $ErrorMessage
167+
return -1
168+
}
169+
else { echo "coveralls already installed" }
170+
}
171+
172+
exec { & csmacnz.Coveralls `
173+
--opencover `
174+
-i coverage.opencover.xml `
175+
--repoToken $env:coverrallstoken `
176+
--useRelativePaths `
177+
--commitId $env:APPVEYOR_REPO_COMMIT `
178+
--commitBranch $env:APPVEYOR_REPO_BRANCH `
179+
--commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR `
180+
--commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL `
181+
--commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE `
182+
--jobId $env:APPVEYOR_BUILD_NUMBER `
183+
--serviceName appveyor
184+
}
171185

172186
echo "Packing the library"
173187
exec { & dotnet pack $projectPath -c Release -o "$($env:APPVEYOR_BUILD_FOLDER)\artifacts" --version-suffix=$revision }

0 commit comments

Comments
 (0)