Skip to content

Generate and upload code coverage reports#38482

Open
Copilot wants to merge 10 commits into
mainfrom
copilot/update-build-yml-code-coverage
Open

Generate and upload code coverage reports#38482
Copilot wants to merge 10 commits into
mainfrom
copilot/update-build-yml-code-coverage

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #24990

Wires the PR Build workflow into GitHub Code Quality coverage so reviewers see coverage results on pull requests. Also adds code coverage reporting to the AzDO pipelines.

Changes

  • Triggers — added push on main alongside pull_request; Code Quality diffs PR coverage against the default-branch baseline, so both are required.
  • Permissions — only the new coverage job grants contents: read + code-quality: write; all other jobs and the top-level stay at permissions: {}.
  • Package referenceMicrosoft.Testing.Extensions.CodeCoverage (18.8.0) is now referenced by all runnable test projects via test/Directory.Build.props (gated on IsTestProject != false, so shipped spec-test libraries are excluded). The version is declared as MicrosoftTestingExtensionsCodeCoverageVersion in eng/Versions.props and test/Directory.Packages.props. v18+ is required because v17 guarded its TestingPlatformBuilderHook behind GenerateTestingPlatformEntryPoint='True', which xunit v3 sets to false. MicrosoftTestingPlatformVersion is also bumped to 2.2.3 as required by CodeCoverage 18.x.
  • Coverage scope — a new eng/efcore.coverage.xml settings file restricts coverage collection to source files under src/ only (via a Sources > Include filter matching .*[/\\]src[/\\].*). This excludes test helpers such as EFCore.Specification.Tests and EFCore.Relational.Specification.Tests (which live under test/) from all reports.
  • Generate — a new CollectCoverage MSBuild property in test/Directory.Build.props appends --coverage --coverage-output-format cobertura --coverage-output <ArtifactsDir>/coverage/<ProjectName>.cobertura.xml --coverage-settings <repo>/eng/efcore.coverage.xml to TestingPlatformCommandLineArguments when set. Passing /p:CollectCoverage=true to the existing Arcade build/test command activates scoped coverage for all test projects without a separate test run.
  • Collect per job — each of the five test jobs (Main, Cosmos, SqlServer, Sqlite, microsoft-data-sqlite) collects per-project Cobertura XML files during its test run and uploads them as a workflow artifact (e.g., coverage-main-ubuntu-24.04). No merging or code-quality upload happens in individual test jobs.
  • Merge & upload (GitHub) — a new coverage job (needs all five test jobs, if: always()) downloads every coverage-* artifact, merges all Cobertura files into one coverage.cobertura.xml with dotnet-coverage merge, and does a single actions/upload-code-coverage upload (pinned to SHA, language: C#, label code-coverage, fail-on-error: false). The fork-skip guard is applied here.
  • API baselines — a new ApiBaselines job runs dotnet test test/EFCore.ApiBaseline.Tests on ubuntu-24.04. ApiBaseline is added to the Main job's exclusion list to avoid running it twice.
  • Upload (AzDO) — coverage is collected in all non-Helix jobs in azure-pipelines-public.yml (Windows, Windows_SqlServer, macOS, Linux) and azure-pipelines-internal-tests.yml (Windows, Windows_SqlServer, macOS, Linux, Linux_Cosmos) by passing /p:CollectCoverage=true to the existing build commands. The eng/efcore.coverage.xml settings file is automatically applied via the MSBuild property, so AzDO reports also cover only src/ code. Per-project Cobertura reports are merged and published with PublishCodeCoverageResults@2 so coverage is visible in the AzDO build UI. All coverage steps use continueOnError: true to keep failures non-blocking.

Note

The GitHub bot coverage comment also requires GitHub Code Quality to be enabled for the repository — a setting outside this file.

Copilot AI and others added 2 commits June 22, 2026 21:46
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class GitHub Code Quality code coverage reporting to the existing Build GitHub Actions workflow, so PRs can display coverage results and compare against the default branch baseline.

Changes:

  • Adds push triggers on main (in addition to pull_request) to support baseline comparisons.
  • Grants per-job contents: read and code-quality: write permissions required for coverage upload.
  • Generates Cobertura coverage during dotnet test, merges per-project reports, and uploads the merged report for each test job/matrix leg.

Comment thread .github/workflows/Build.yml Outdated
Comment thread .github/workflows/Build.yml Outdated
Comment thread .github/workflows/Build.yml Outdated
Comment thread .github/workflows/Build.yml Outdated
Comment thread .github/workflows/Build.yml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread .github/workflows/Build.yml
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI changed the title Generate and upload code coverage reports in Build.yml Generate and upload code coverage reports in Build.yml and azure-pipelines.yml Jun 22, 2026
Copilot AI requested a review from AndriySvyryd June 22, 2026 23:33
Comment thread azure-pipelines.yml Outdated
… jobs in azure-pipelines-public.yml and azure-pipelines-internal-tests.yml

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI changed the title Generate and upload code coverage reports in Build.yml and azure-pipelines.yml Generate and upload code coverage reports in Build.yml, azure-pipelines-public.yml, and azure-pipelines-internal-tests.yml Jun 23, 2026
Copilot AI requested a review from AndriySvyryd June 23, 2026 00:29
Comment thread .github/workflows/Build.yml Outdated
…MTP to 2.2.3

v17.10.1 guarded the TestingPlatformBuilderHook behind
GenerateTestingPlatformEntryPoint == 'True', which xunit v3 sets to false
(using GenerateSelfRegisteredExtensions=true instead), so the --coverage
MTP extension was never registered → "Unknown option '--coverage'".

v18.8.0 removes that condition. MTP must also be bumped to 2.2.3 because
CodeCoverage 18.8.0 has a hard dependency on it; Arcade's XUnitV3.targets
injects the MTP package references using $(MicrosoftTestingPlatformVersion).

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
@github-code-quality

github-code-quality Bot commented Jun 24, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/microsoft-data-sqlite-ubuntu-24.04

The overall coverage in the branch is 76%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File a0254d2 +/-
/home/runner/wo...e/SqliteBlob.cs 100%
/home/runner/wo...teDataReader.cs 99%
/home/runner/wo...eValueBinder.cs 98%
/home/runner/wo...tringBuilder.cs 97%
/home/runner/wo...teDataRecord.cs 93%
/home/runner/wo...qliteCommand.cs 90%
/home/runner/wo...teConnection.cs 88%
/home/runner/wo...eTransaction.cs 86%
/home/runner/wo...eValueReader.cs 85%
/home/runner/wo...tionInternal.cs 83%

C# / code-coverage/microsoft-data-sqlite-windows-2025

The overall coverage in the branch is 77%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File a0254d2 +/-
D:\a\efcore\efc...e\SqliteBlob.cs 100%
D:\a\efcore\efc...teDataReader.cs 99%
D:\a\efcore\efc...eValueBinder.cs 98%
D:\a\efcore\efc...tringBuilder.cs 97%
D:\a\efcore\efc...teDataRecord.cs 93%
D:\a\efcore\efc...qliteCommand.cs 90%
D:\a\efcore\efc...teConnection.cs 89%
D:\a\efcore\efc...eTransaction.cs 86%
D:\a\efcore\efc...eValueReader.cs 85%
D:\a\efcore\efc...tionInternal.cs 83%

C# / code-coverage/cosmos-ubuntu-24.04

The overall coverage in the branch is 39%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File a0254d2 +/-
/home/runner/wo...Data.Objects.cs 100%
/home/runner/wo...tersTestBase.cs 97%
/home/runner/wo...Relationship.cs 95%
/home/runner/wo...est.OneToOne.cs 93%
/home/runner/wo...st.OneToMany.cs 92%
/home/runner/wo...ueryTestBase.cs 87%
/home/runner/wo...odeGenerator.cs 84%
/home/runner/wo...gnKeyBuilder.cs 82%
/home/runner/wo...kingTestBase.cs 74%
/home/runner/wo...yTypeBuilder.cs 67%

C# / code-coverage/sqlite-ubuntu-24.04

The overall coverage in the branch is 58%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File a0254d2 +/-
/home/runner/wo...Data.Objects.cs 100%
/home/runner/wo...kingTestBase.cs 99%
/home/runner/wo...ixupTestBase.cs 99%
/home/runner/wo...atedTestBase.cs 99%
/home/runner/wo...LoadTestBase.cs 99%
/home/runner/wo...dateTestBase.cs 98%
/home/runner/wo...ueryTestBase.cs 96%
/home/runner/wo...tersTestBase.cs 95%
/home/runner/wo...est.OneToOne.cs 95%
/home/runner/wo...ueryTestBase.cs 94%

C# / code-coverage/sqlite-windows-2025

The overall coverage in the branch is 60%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File a0254d2 +/-
D:\a\efcore\efc...Data.Objects.cs 100%
D:\a\efcore\efc...kingTestBase.cs 99%
D:\a\efcore\efc...ixupTestBase.cs 99%
D:\a\efcore\efc...atedTestBase.cs 99%
D:\a\efcore\efc...LoadTestBase.cs 99%
D:\a\efcore\efc...dateTestBase.cs 98%
D:\a\efcore\efc...ueryTestBase.cs 96%
D:\a\efcore\efc...tersTestBase.cs 95%
D:\a\efcore\efc...est.OneToOne.cs 95%
D:\a\efcore\efc...ueryTestBase.cs 94%

C# / code-coverage/cosmos-windows-2025

The overall coverage in the branch is 39%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File a0254d2 +/-
D:\a\efcore\efc...Data.Objects.cs 100%
D:\a\efcore\efc...tersTestBase.cs 97%
D:\a\efcore\efc...Relationship.cs 95%
D:\a\efcore\efc...est.OneToOne.cs 93%
D:\a\efcore\efc...st.OneToMany.cs 92%
D:\a\efcore\efc...ueryTestBase.cs 88%
D:\a\efcore\efc...odeGenerator.cs 84%
D:\a\efcore\efc...gnKeyBuilder.cs 82%
D:\a\efcore\efc...kingTestBase.cs 74%
D:\a\efcore\efc...yTypeBuilder.cs 67%

C# / code-coverage/main-windows-2025

The overall coverage in the branch is 34%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File a0254d2 +/-
D:\a\efcore\efc...Data.Objects.cs 100%
D:\a\efcore\efc...LoadTestBase.cs 100%
D:\a\efcore\efc...kingTestBase.cs 99%
D:\a\efcore\efc...LoadTestBase.cs 99%
D:\a\efcore\efc...ixupTestBase.cs 98%
D:\a\efcore\efc...alidatorTest.cs 98%
D:\a\efcore\efc...ueryTestBase.cs 97%
D:\a\efcore\efc...ueryTestBase.cs 95%
D:\a\efcore\efc...est.OneToOne.cs 93%
D:\a\efcore\efc...tersTestBase.cs 85%

C# / code-coverage/main-ubuntu-24.04

The overall coverage in the branch is 34%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File a0254d2 +/-
/home/runner/wo...Data.Objects.cs 100%
/home/runner/wo...LoadTestBase.cs 100%
/home/runner/wo...kingTestBase.cs 99%
/home/runner/wo...LoadTestBase.cs 99%
/home/runner/wo...ixupTestBase.cs 98%
/home/runner/wo...alidatorTest.cs 98%
/home/runner/wo...ueryTestBase.cs 97%
/home/runner/wo...ueryTestBase.cs 95%
/home/runner/wo...est.OneToOne.cs 93%
/home/runner/wo...tersTestBase.cs 85%

Updated June 24, 2026 00:51 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

Comment thread .github/workflows/Build.yml Outdated
…es job

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Comment thread .github/workflows/Build.yml Outdated
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI requested a review from AndriySvyryd June 24, 2026 04:52
@AndriySvyryd AndriySvyryd marked this pull request as ready for review June 24, 2026 06:53
@AndriySvyryd AndriySvyryd requested review from a team and wtgodbe as code owners June 24, 2026 06:53
Copilot AI review requested due to automatic review settings June 24, 2026 06:53
@AndriySvyryd AndriySvyryd changed the title Generate and upload code coverage reports in Build.yml, azure-pipelines-public.yml, and azure-pipelines-internal-tests.yml Generate and upload code coverage reports Jun 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Comment thread azure-pipelines-public.yml
Comment thread azure-pipelines-public.yml
Comment thread azure-pipelines-public.yml Outdated
Comment thread azure-pipelines-public.yml Outdated
Comment thread azure-pipelines-internal-tests.yml
Comment thread azure-pipelines-internal-tests.yml
Comment thread azure-pipelines-internal-tests.yml Outdated
Comment thread azure-pipelines-internal-tests.yml Outdated
Comment thread azure-pipelines-internal-tests.yml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 25, 2026 01:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment on lines +27 to +28
<_CoverageOutputDir Condition="'$(CollectCoverage)' == 'true'">$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'coverage'))</_CoverageOutputDir>
<TestingPlatformCommandLineArguments Condition="'$(CollectCoverage)' == 'true'">$(TestingPlatformCommandLineArguments) --coverage --coverage-output-format cobertura --coverage-output $(_CoverageOutputDir)$(MSBuildProjectName).cobertura.xml --coverage-settings $(MSBuildThisFileDirectory)..\eng\efcore.coverage.xml</TestingPlatformCommandLineArguments>
Comment on lines +351 to +353
- name: Upload coverage report
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: actions/upload-code-coverage@abb5995db9e0199b0e2bb9dbd136fce4cb1ec4d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add code coverage report to AzDo

3 participants