Skip to content

Generate and upload code coverage reports - #38482

Merged
AndriySvyryd merged 14 commits into
mainfrom
copilot/update-build-yml-code-coverage
Jun 27, 2026
Merged

AndriySvyryd merged 14 commits into
mainfrom
copilot/update-build-yml-code-coverage

Conversation

Copilot AI commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

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 reference — Microsoft.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. In the AzDO pipelines, EFCore.ApiBaseline.Tests is run as an explicit step only in the non-Helix Windows job (both azure-pipelines-public.yml and azure-pipelines-internal-tests.yml); a new <SkipTests> gate in EFCore.ApiBaseline.Tests.csproj (enabled via /p:SkipApiBaselineTests=true) ensures the project is skipped by the full-solution cibuild/build.sh invocations in all other jobs, preventing double-execution.
  • 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 left a comment

Copy link
Copy Markdown
Contributor

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 Resolved
Comment thread .github/workflows/Build.yml Resolved
Comment thread .github/workflows/Build.yml Resolved
Comment thread .github/workflows/Build.yml Resolved
Comment thread .github/workflows/Build.yml Resolved
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Comment thread .github/workflows/Build.yml Resolved
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 Resolved
… jobs in azure-pipelines-public.yml and azure-pipelines-internal-tests.yml

Co-authored-by: AndriySvyryd <[email protected]>
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 Resolved
…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 <[email protected]>
@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 copilot/update-build... branch is 76%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main copilot/update-build... 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 copilot/update-build... branch is 77%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main copilot/update-build... 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 copilot/update-build... branch is 39%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main copilot/update-build... 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 copilot/update-build... branch is 58%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main copilot/update-build... 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 copilot/update-build... branch is 60%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main copilot/update-build... 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 copilot/update-build... branch is 39%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main copilot/update-build... 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 copilot/update-build... branch is 34%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main copilot/update-build... 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 copilot/update-build... branch is 34%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main copilot/update-build... 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 Resolved
@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
Contributor

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 Resolved
Comment thread azure-pipelines-public.yml Resolved
Comment thread azure-pipelines-public.yml Resolved
Comment thread azure-pipelines-public.yml Resolved
Comment thread azure-pipelines-internal-tests.yml Resolved
Comment thread azure-pipelines-internal-tests.yml Resolved
Comment thread azure-pipelines-internal-tests.yml Resolved
Comment thread azure-pipelines-internal-tests.yml Resolved
Comment thread azure-pipelines-internal-tests.yml Resolved
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings June 25, 2026 01:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 thread test/Directory.Build.props Resolved
Comment thread .github/workflows/Build.yml Resolved
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings June 25, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 thread test/Directory.Build.props Resolved
Comment thread .github/workflows/Build.yml Resolved
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings June 25, 2026 18:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 no new comments.

Comment thread azure-pipelines-internal-tests.yml Resolved
Copilot AI requested review from Copilot and removed request for Copilot June 26, 2026 22:52

@wtgodbe wtgodbe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@AndriySvyryd
AndriySvyryd merged commit 0bb1c8d into main Jun 27, 2026
16 checks passed
@AndriySvyryd
AndriySvyryd deleted the copilot/update-build-yml-code-coverage branch June 27, 2026 02:39
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 28, 2026
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.

4 participants