Skip to content

Commit 2b3cc4d

Browse files
Skip code coverage tasks for docs-only PRs (#12879)
### Context Docs-only PRs fail the Code Coverage CI job because tests are skipped (no coverage artifacts generated), but the job unconditionally attempts to download and publish those artifacts. ### Changes Made Modified `.vsts-dotnet-ci.yml` CodeCoverage job to respect the `onlyDocChanged` flag: - Added dependency on `IfOnlyDocumentionChanged` job to access the flag - Added `onlyDocChanged` variable to job variables - Conditioned all artifact downloads on `eq(variables.onlyDocChanged, 0)` - Conditioned coverage processing and publishing on `eq(variables.onlyDocChanged, 0)` This aligns with how other jobs (BootstrapMSBuildOnFullFrameworkWindows, CoreBootstrappedOnLinux, etc.) already handle docs-only PRs. ### Testing Pipeline configuration change - will be validated on next PR run. When `onlyDocChanged = 1`, all coverage tasks skip; when `onlyDocChanged = 0`, coverage runs normally. ### Notes Pre-existing typos in job/variable names (`Documention`, `Varibale`) intentionally preserved for consistency across the pipeline. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>docs only PRs fail code coverage CI check</issue_title> > <issue_description>#12805 > #12857 > > ``` > Code Coverage failed > [3 errors / 0 warnings](https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1217301) > > Annotations > [Check failure on line 9 in Build log](https://github.com/dotnet/msbuild/pull/12857/files#annotation_42398343450) > > @azure-pipelines > azure-pipelines > / msbuild-pr (Code Coverage) > Build log #L9 > > Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\1\s\artifacts\CoverageResults\merged.coverage > [Check failure on line 11 in Build log](https://github.com/dotnet/msbuild/pull/12857/files#annotation_42398343487) > > @azure-pipelines > azure-pipelines > / msbuild-pr (Code Coverage) > Build log #L11 > > Artifact LinuxCoreCoverage was not found for build 1217301. > [Check failure on line 9 in Build log](https://github.com/dotnet/msbuild/pull/12857/files#annotation_42398343497) > > @azure-pipelines > azure-pipelines > / msbuild-pr (Code Coverage) > Build log #L9 > > Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\1\s\artifacts\CoverageResults\merged.cobertura.xml > ``` > > This is probably because testing is skipped on docs only PRs, in that case code coverage should also be skipped</issue_description> > > <agent_instructions>fix this issue, note that the CI pipeline definition is called .vsts-dotnet-ci.yml</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes #12878 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/dotnet/msbuild/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JanProvaznik <[email protected]>
1 parent e5cd2f8 commit 2b3cc4d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

.vsts-dotnet-ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,14 @@ jobs:
533533
- job: CodeCoverage
534534
displayName: "Code Coverage"
535535
dependsOn:
536+
- IfOnlyDocumentionChanged
536537
- BootstrapMSBuildOnFullFrameworkWindows
537538
- BootstrapMSBuildOnCoreWindows
538539
- FullReleaseOnWindows
539540
- CoreBootstrappedOnLinux
540541
- CoreOnMac
542+
variables:
543+
onlyDocChanged: $[ dependencies.IfOnlyDocumentionChanged.outputs['SetIfOnlyDocumentionChangedVaribale.onlyDocChanged'] ]
541544
pool:
542545
vmImage: 'windows-2022'
543546
steps:
@@ -562,32 +565,36 @@ jobs:
562565
buildType: 'current'
563566
artifactName: 'LinuxCoreCoverage'
564567
targetPath: '$(Build.SourcesDirectory)/artifacts/TestResults/CoverageResults/LinuxCore'
568+
condition: eq(variables.onlyDocChanged, 0)
565569
- task: DownloadPipelineArtifact@2
566570
inputs:
567571
buildType: 'current'
568572
artifactName: 'MacCoreCoverage'
569573
targetPath: '$(Build.SourcesDirectory)/artifacts/TestResults/CoverageResults/MacCore'
574+
condition: eq(variables.onlyDocChanged, 0)
570575

571576
- task: PowerShell@2
572577
displayName: Process coverage reports
573578
inputs:
574579
filePath: $(Build.SourcesDirectory)\eng\process-coverage.ps1
575580
arguments: -repoRoot $(Build.SourcesDirectory) -coverageArtifactsDir $(Build.SourcesDirectory)/artifacts/CoverageResults
576581
pwsh: true
582+
condition: eq(variables.onlyDocChanged, 0)
577583
- task: PublishBuildArtifacts@1
578584
displayName: Publish Artifact $(Build.BuildNumber) Coverage
579585
inputs:
580586
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/CoverageResults/merged.coverage'
581587
ArtifactName: '$(Build.BuildNumber) Coverage'
582-
condition: succeededOrFailed()
588+
condition: and(succeededOrFailed(), eq(variables.onlyDocChanged, 0))
583589
- task: PublishBuildArtifacts@1
584590
displayName: Publish Artifact $(Build.BuildNumber) Cobertura
585591
inputs:
586592
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/CoverageResults/merged.cobertura.xml'
587593
ArtifactName: '$(Build.BuildNumber) Cobertura'
588-
condition: succeededOrFailed()
594+
condition: and(succeededOrFailed(), eq(variables.onlyDocChanged, 0))
589595
- task: PublishCodeCoverageResults@2
590596
inputs:
591597
summaryFileLocation: '$(Build.SourcesDirectory)/artifacts/CoverageResults/merged.coverage'
592598
pathToSources: $(Build.SourcesDirectory)
599+
condition: eq(variables.onlyDocChanged, 0)
593600
- template: /eng/common/templates/jobs/source-build.yml

0 commit comments

Comments
 (0)