Skip to content

Commit ab70075

Browse files
authored
Merge pull request #13 from HodStudio/feature/CodeCoverage
Integrating build with CoverRalls
2 parents b9d6958 + 02a400b commit ab70075

3 files changed

Lines changed: 60 additions & 25 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _An easy way to create entity changes' log using Entity Framework_
1212

1313
[![Build status](https://ci.appveyor.com/api/projects/status/1r9ebih0q0ntqfu4?svg=true)](https://ci.appveyor.com/project/Cussa/entityframeworkdifflog)
1414
[![AppVeyor tests (compact)](https://img.shields.io/appveyor/tests/cussa/entityframeworkdifflog?compact_message&logo=appveyor)](https://ci.appveyor.com/project/Cussa/entityframeworkdifflog/build/tests)
15+
[![Coverage Status](https://coveralls.io/repos/github/HodStudio/EntityFrameworkDiffLog/badge.svg?branch=master)](https://coveralls.io/github/HodStudio/EntityFrameworkDiffLog?branch=master)
1516

1617
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=HodStudio.EntityFrameworkDiffLog&metric=alert_status)](https://sonarcloud.io/dashboard?id=HodStudio.EntityFrameworkDiffLog)
1718
[![sqale_rating](https://sonarcloud.io/api/project_badges/measure?project=HodStudio.EntityFrameworkDiffLog&metric=sqale_rating)](https://sonarqube.com/dashboard?id=HodStudio.EntityFrameworkDiffLog)

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: 57 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,68 @@ 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" }
167146

168-
#exec { & reportgenerator "-reports:$($env:APPVEYOR_BUILD_FOLDER)\TestResults\*\*.xml" "-targetdir:$($env:APPVEYOR_BUILD_FOLDER)\TestResults\" "-reporttypes:SonarQube" }
147+
echo "Code Coverage information"
169148

170-
exec { & dotnet sonarscanner end /d:sonar.login="$env:sonartoken" }
149+
$opencoverFile = Get-ChildItem -Path "$($env:APPVEYOR_BUILD_FOLDER)\TestResults" -Filter coverage.opencover.xml -Recurse -ErrorAction SilentlyContinue -Force
150+
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+
if ($env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null)
172+
{
173+
exec { & csmacnz.Coveralls `
174+
--opencover `
175+
-i "$($env:APPVEYOR_BUILD_FOLDER)\TestResults\coverage.opencover.xml" `
176+
--repoToken $env:coverallstoken `
177+
--useRelativePaths `
178+
--commitId $env:APPVEYOR_REPO_COMMIT `
179+
--commitBranch $env:APPVEYOR_REPO_BRANCH `
180+
--commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR `
181+
--commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL `
182+
--commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE `
183+
--jobId $env:APPVEYOR_BUILD_NUMBER `
184+
--serviceName appveyor `
185+
--pullRequest $env:APPVEYOR_PULL_REQUEST_NUMBER
186+
}
187+
}
188+
else {
189+
exec { & csmacnz.Coveralls `
190+
--opencover `
191+
-i "$($env:APPVEYOR_BUILD_FOLDER)\TestResults\coverage.opencover.xml" `
192+
--repoToken $env:coverallstoken `
193+
--useRelativePaths `
194+
--commitId $env:APPVEYOR_REPO_COMMIT `
195+
--commitBranch $env:APPVEYOR_REPO_BRANCH `
196+
--commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR `
197+
--commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL `
198+
--commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE `
199+
--jobId $env:APPVEYOR_BUILD_NUMBER `
200+
--serviceName appveyor
201+
}
202+
}
171203

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

0 commit comments

Comments
 (0)