Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable coverage report in PRs #2946

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: .NET Core

permissions:
contents: read
pull-requests: write

on:
push:
branches:
Expand Down Expand Up @@ -30,20 +34,43 @@ jobs:
uses: actions/[email protected]
with:
dotnet-version: 6.0.x

- name: Setup .NET 8.0.x
uses: actions/[email protected]
with:
dotnet-version: 8.0.x

- name: Setup .NET 9.0.x
uses: actions/[email protected]
with:
dotnet-version: 9.0.100-rc.2.24474.11

- name: Run the tests
run: dotnet test Wilson.sln
run: dotnet test Wilson.sln --collect:"XPlat Code Coverage" --settings:./build/CodeCoverage.runsettings

- name: Create code coverage report
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:CodeCoverage -reporttypes:'MarkdownSummaryGithub;Cobertura'

- name: Write Coverage to Job Summary
shell: bash
run: |
cat CodeCoverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
echo "COMMENT_CONTENT_ENV_VAR<<EOF" >> $GITHUB_ENV
echo $(cat CodeCoverage/SummaryGithub.md) >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Comment Coverage in PR
uses: actions/github-script@v7
id: comment
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.COMMENT_CONTENT_ENV_VAR
})

# Run baseline package validation
- name: Pack
run: dotnet pack Product.proj --no-restore --no-build
run: dotnet pack Product.proj --no-restore --no-build
4 changes: 4 additions & 0 deletions build/CodeCoverage.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Included items must then not match any entries in the exclude list to remain inc
<ModulePath>.*\microsoft.identitymodel.xml.dll</ModulePath>
<ModulePath>.*\system.identitymodel.tokens.jwt.dll</ModulePath>
</Include>
<Exclude>
<ModulePath>.*\\test\\.*</ModulePath>
<ModulePath>.*Test\.dll</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
Expand Down
4 changes: 4 additions & 0 deletions build/commonTest.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(BannedApiAnalyzersVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions build/dependenciesTest.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<CoverletCollectorVersion>6.0.2</CoverletCollectorVersion>
<BannedApiAnalyzersVersion>3.3.4</BannedApiAnalyzersVersion>
<DotNetCoreAppRuntimeVersion>2.1.30</DotNetCoreAppRuntimeVersion>
<MicrosoftAzureKeyVaultCryptographyVersion>3.0.5</MicrosoftAzureKeyVaultCryptographyVersion>
Expand Down
Loading