generated from arcus-azure/arcus.github.template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: publish code coverage * pr-fix: ci trigger * pr-fix: collect code coverage * pr-fix: coverlage update * pr-fix: project var name * pr-fix: add coverage to integration test project * pr-fix: use az devops code coverge * pr-fix: add coverage settings to integration test project * pr-fix: check integrtion test coverage * pr-fix: single publish coverage result * pr-fix: use single test stage * pr-fix: adds depends on * pr-fix: publish artifacts directly * pr-fix: publish artifacts directly * pr-fix: publish artifacts directly * pr-fix: publish artifacts directly * pr-fix: publish artifacts directly * pr-fix: single test job * pr-fix: single test job * pr-fix: remove msbuild from csproj * pr-fix: force result directory * pr-fix: force result directory * pr-fix: explicitly publish results * pr-fix: Cobertura type * Update publish-coverage.yml * pr-fix: add gh comment * pr-fix: add summary report * pr-fix: secrets * pr-fix: pr number * pr-fix: pr number * pr-fix: pr number * pr-fix: publish code coverage in gh workflow * pr-fix: correct gh action * pr-fix: publish on pr * pr-fix: correct path * pr-fix: use gh cli * pr-fix: install other way * pr-fix: remove useless test * pr-fix: use pr number * pr-fix: upsert comment * pr-fix: change summary * pr-fix: use gh summary * pr-fix: separate jobs * pr-fix: use wildards * pr-fix: use own test * pr-fix: use correct artifacts * pr-fix: use correct var name * pr-fix: correct multi-line * pr-fix: correct coverage path * pr-ifix: correct multi-line * pr-fix: correct format * pr-fix: sinlge line * pr-fix: w/o no-build * pr-fix: publish to gh * pr-fix: update comment * pr-fix: motivational message * pr-fix: correct syntax error * pr-fix: improve coverage * pr-fix: error multi-line * pr-fix: more coverage + flexibe retrieval * pr-fix: write host * pr-fix: correct pattern * pr-fix: update with more coverage * pr-fix: improve branch coverage * pr-fix: improve coverage * pr-fix: improve coverage * pr-fix: correct tests * pr-fix: resuse min coverage level
- Loading branch information
1 parent
d59d161
commit 6c0cb08
Showing
22 changed files
with
564 additions
and
101 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
jobs: | ||
- job: PublishCoverage | ||
displayName: 'Publish code coverage' | ||
pool: | ||
vmImage: '$(Vm.Image)' | ||
dependsOn: | ||
- UnitTests | ||
- IntegrationTests | ||
steps: | ||
- task: DownloadPipelineArtifact@2 | ||
displayName: 'Download coverage unit artifacts' | ||
inputs: | ||
artifact: 'Coverage-Unit' | ||
path: '$(Build.SourcesDirectory)/TestResults' | ||
|
||
- task: DownloadPipelineArtifact@2 | ||
displayName: 'Download coverage integration artifacts' | ||
inputs: | ||
artifact: 'Coverage-Integration' | ||
path: '$(Build.SourcesDirectory)/TestResults' | ||
|
||
- task: reportgenerator@5 | ||
displayName: 'Generate code coverage report' | ||
inputs: | ||
reports: '$(Build.SourcesDirectory)/TestResults/**/coverage.cobertura.xml' | ||
targetdir: coveragereport | ||
reporttypes: Html;HtmlInline_AzurePipelines_Dark;Cobertura;MarkdownSummaryGithub | ||
publishCodeCoverageResults: true | ||
|
||
- script: sudo apt install gh | ||
displayName: 'Install GitHub CLI' | ||
|
||
- powershell: | | ||
gh auth login --with-token $(GITHUB_TOKEN) | ||
gh repo view | ||
$summary = Get-Content -Path './coveragereport/SummaryGithub.md' -Raw | ||
Write-Host "Summary: $summary" | ||
$lineCoveragePattern = "\*\*Line coverage:\*\*\s*\|\s*(\d+(\.\d+)?%)" | ||
$branchCoveragePattern = "\*\*Branch coverage:\*\*\s*\|\s*(\d+(\.\d+)?%)" | ||
$lineCoverage = "N/A" | ||
if ($summary -match $lineCoveragePattern) { | ||
$lineCoverage = $matches[1] | ||
Write-Host "Line coverage: $lineCoverage" | ||
} else { | ||
Write-Host "Line coverage not found" | ||
} | ||
$branchCoverage = "N/A" | ||
if ($summary -match $branchCoveragePattern) { | ||
$branchCoverage = $matches[1] | ||
Write-Host "Branch coverage: $branchCoverage" | ||
} else { | ||
Write-Host "Branch coverage not found" | ||
} | ||
$lineCoverageValue = [double]($lineCoverage -replace '%', '') | ||
$branchCoverageValue = [double]($branchCoverage -replace '%', '') | ||
$buildId = $env:BUILD_BUILDID | ||
$reportUrl = "https://dev.azure.com/codit/Arcus/_build/results?buildId=$buildId&view=codecoverage-tab" | ||
$minCoverage = 80 | ||
if ($lineCoverageValue -ge $minCoverage -and $branchCoverage -ge $minCoverage) { | ||
$motivationalMessage = "Great job! 😎 Your code coverage is higher than my caffeine levels! ☕" | ||
} else { | ||
$motivationalMessage = @" | ||
😟 Your code coverage is not fully reaching **$minCoverage %** yet. | ||
Please inspect [the report]($reportUrl) to find possible improvements and before you know it, your code coverage will reach the stars! 🚀 | ||
"@ | ||
} | ||
if ($lineCoverageValue -ge $minCoverage) { $lineCoverageBadge = "🟢" } else { $lineCoverageBadge = "🔴" } | ||
if ($branchCoverageValue -ge $minCoverage) { $branchCoverageBadge = "🟢" } else { $branchCoverageBadge = "🔴" } | ||
$comments = gh pr view $env:PR_NUMBER --json comments --jq '.comments[].body' | ||
$commentExists = $comments | Where-Object { $_ -like "*Code coverage*" -and $_ -like "*summary*" } | ||
$content = @" | ||
## 🧪 [Code coverage]($reportUrl) summary | ||
| Metric | Value | | ||
| ------ | ----- | | ||
| Line coverage | $lineCoverageBadge **$lineCoverage** | | ||
| Branch coverage | $branchCoverageBadge **$branchCoverage** | | ||
$motivationalMessage | ||
"@ | ||
if ($commentExists) { | ||
gh pr comment $env:PR_NUMBER --body $content --edit-last | ||
} else { | ||
gh pr comment $env:PR_NUMBER --body $content | ||
} | ||
env: | ||
GITHUB_TOKEN: $(GITHUB_TOKEN) | ||
PR_NUMBER: $(System.PullRequest.PullRequestNumber) | ||
displayName: 'Publish code coverage summary on GitHub' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/Arcus.Testing.Tests.Integration/DemoIntegrationTest.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.