diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index ec955ddf0..941c70a8f 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -1,5 +1,9 @@ name: "Run unit tests" +permissions: + contents: read + pull-requests: write + on: push: branches: @@ -58,9 +62,34 @@ jobs: - name: Test with .NET 7.0.x run: dotnet test --no-restore --no-build Microsoft.Identity.Web.sln -f net7.0 -v normal -p:FROM_GITHUB_ACTION=true --configuration Release --filter "(FullyQualifiedName!~Microsoft.Identity.Web.Test.Integration)&(FullyQualifiedName!~WebAppUiTests)&(FullyQualifiedName!~IntegrationTests)&(FullyQualifiedName!~TokenAcquirerTests)" - + - name: Test with .NET 8.0.x - run: dotnet test --no-restore --no-build Microsoft.Identity.Web.sln -f net8.0 -v normal -p:FROM_GITHUB_ACTION=true --configuration Release --filter "(FullyQualifiedName!~Microsoft.Identity.Web.Test.Integration)&(FullyQualifiedName!~WebAppUiTests)&(FullyQualifiedName!~IntegrationTests)&(FullyQualifiedName!~TokenAcquirerTests)" + run: dotnet test --no-restore --no-build Microsoft.Identity.Web.sln -f net8.0 -v normal -p:FROM_GITHUB_ACTION=true --configuration Release --collect "Xplat Code Coverage" --filter "(FullyQualifiedName!~Microsoft.Identity.Web.Test.Integration)&(FullyQualifiedName!~WebAppUiTests)&(FullyQualifiedName!~IntegrationTests)&(FullyQualifiedName!~TokenAcquirerTests)" + + - 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 + }) - name: Test with .NET 9.0.x run: dotnet test --no-restore --no-build Microsoft.Identity.Web.sln -f net9.0 -v normal -p:FROM_GITHUB_ACTION=true -p:TargetNet9=True --configuration Release --filter "(FullyQualifiedName!~Microsoft.Identity.Web.Test.Integration)&(FullyQualifiedName!~WebAppUiTests)&(FullyQualifiedName!~IntegrationTests)&(FullyQualifiedName!~TokenAcquirerTests)" @@ -73,4 +102,3 @@ jobs: - name: Test with .NET Standard 2.0 run: dotnet test --no-restore --no-build Microsoft.Identity.Web.sln -f netstandard2.0 -v normal -p:FROM_GITHUB_ACTION=true --configuration Release --filter "(FullyQualifiedName!~Microsoft.Identity.Web.Test.Integration)&(FullyQualifiedName!~WebAppUiTests)&(FullyQualifiedName!~IntegrationTests)" - diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 5ae61436c..f0578133c 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -21,7 +21,7 @@ 2.9.2 4.2.2 1.0.13 - 3.1.2 + 6.0.2 4.8.0 108.0.5359.7100 0.12.1 diff --git a/tests/E2E Tests/GraphServiceClientTests/GraphServiceClientTests.csproj b/tests/E2E Tests/GraphServiceClientTests/GraphServiceClientTests.csproj index a7f312181..391086481 100644 --- a/tests/E2E Tests/GraphServiceClientTests/GraphServiceClientTests.csproj +++ b/tests/E2E Tests/GraphServiceClientTests/GraphServiceClientTests.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -13,10 +13,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - diff --git a/tests/E2E Tests/NET 7 tests/IntegrationTests/IntegrationTests.csproj b/tests/E2E Tests/NET 7 tests/IntegrationTests/IntegrationTests.csproj index 92a6459b7..880c5cbe7 100644 --- a/tests/E2E Tests/NET 7 tests/IntegrationTests/IntegrationTests.csproj +++ b/tests/E2E Tests/NET 7 tests/IntegrationTests/IntegrationTests.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -22,10 +22,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - diff --git a/tests/E2E Tests/TokenAcquirerTests/TokenAcquirerTests.csproj b/tests/E2E Tests/TokenAcquirerTests/TokenAcquirerTests.csproj index dbf237031..f2b7bec4b 100644 --- a/tests/E2E Tests/TokenAcquirerTests/TokenAcquirerTests.csproj +++ b/tests/E2E Tests/TokenAcquirerTests/TokenAcquirerTests.csproj @@ -1,4 +1,4 @@ - + net7.0; net8.0 @@ -14,10 +14,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - diff --git a/tests/E2E Tests/WebAppUiTests/WebAppUiTests.csproj b/tests/E2E Tests/WebAppUiTests/WebAppUiTests.csproj index 1fda9e6fd..95a980e45 100644 --- a/tests/E2E Tests/WebAppUiTests/WebAppUiTests.csproj +++ b/tests/E2E Tests/WebAppUiTests/WebAppUiTests.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -19,10 +19,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - diff --git a/tests/Microsoft.Identity.Web.Test/Microsoft.Identity.Web.Test.csproj b/tests/Microsoft.Identity.Web.Test/Microsoft.Identity.Web.Test.csproj index bec4ae402..4b349e814 100644 --- a/tests/Microsoft.Identity.Web.Test/Microsoft.Identity.Web.Test.csproj +++ b/tests/Microsoft.Identity.Web.Test/Microsoft.Identity.Web.Test.csproj @@ -1,4 +1,4 @@ - + $(DefineConstants);DOTNET_472 @@ -19,6 +19,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all +