From 3a0ddc7da364671a2e59c03da9cefa85ca6c97c7 Mon Sep 17 00:00:00 2001 From: Westin Musser <127992899+westin-m@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:23:06 -0700 Subject: [PATCH 1/2] enable coverage report in PRs --- .github/workflows/dotnetcore.yml | 39 ++++++++++++++++++++++++++++---- build/CodeCoverage.runsettings | 4 ++++ build/commonTest.props | 4 ++++ build/dependenciesTest.props | 1 + 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 251b58d17e..f1181feb58 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -1,5 +1,9 @@ name: .NET Core +permissions: + contents: read + pull-requests: write + on: push: branches: @@ -30,20 +34,45 @@ jobs: uses: actions/setup-dotnet@v4.0.0 with: dotnet-version: 6.0.x - + - name: Setup .NET 8.0.x uses: actions/setup-dotnet@v4.0.0 with: - dotnet-version: 8.0.x - + dotnet-version: 8.0.x + - name: Setup .NET 9.0.x uses: actions/setup-dotnet@v4.0.0 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<> $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 \ No newline at end of file diff --git a/build/CodeCoverage.runsettings b/build/CodeCoverage.runsettings index 82114b22f3..d81f4ea1c1 100644 --- a/build/CodeCoverage.runsettings +++ b/build/CodeCoverage.runsettings @@ -40,6 +40,10 @@ Included items must then not match any entries in the exclude list to remain inc .*\microsoft.identitymodel.xml.dll .*\system.identitymodel.tokens.jwt.dll + + .*\\test\\.* + .*Test\.dll + diff --git a/build/commonTest.props b/build/commonTest.props index 0ab6a6d387..f011e71f99 100644 --- a/build/commonTest.props +++ b/build/commonTest.props @@ -39,6 +39,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + all runtime; build; native; contentfiles; analyzers diff --git a/build/dependenciesTest.props b/build/dependenciesTest.props index 297bb5c296..de16b18cd3 100644 --- a/build/dependenciesTest.props +++ b/build/dependenciesTest.props @@ -1,5 +1,6 @@ + 6.0.2 3.3.4 2.1.30 3.0.5 From 01481a81983cc520da7c0c903ddb38d5ff3cda8b Mon Sep 17 00:00:00 2001 From: Westin Musser <127992899+westin-m@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:17:04 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: msbw2 --- .github/workflows/dotnetcore.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index f1181feb58..5f6b376481 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -34,12 +34,10 @@ jobs: uses: actions/setup-dotnet@v4.0.0 with: dotnet-version: 6.0.x - - name: Setup .NET 8.0.x uses: actions/setup-dotnet@v4.0.0 with: - dotnet-version: 8.0.x - + dotnet-version: 8.0.x - name: Setup .NET 9.0.x uses: actions/setup-dotnet@v4.0.0 with: