Skip to content

Commit

Permalink
Updating code coverage config (#4983)
Browse files Browse the repository at this point in the history
* Create CodeCoverage.yml

* Update CodeCoverage.yml

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Delete .github/workflows/CodeCoverage.yml

* Update CodeCoverage.runsettings

* Update template-run-integration-tests.yaml

* Update template-run-unit-tests.yaml

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Update CodeCoverage.runsettings

* Updating code coverage

* Updating coverage

* Removing unneeded source files

* Removing config

* Adding more exclusion folders

* Update

* Config update

* update

* Updating code coverage

* Update

* Update

* Update

* Update

* Update

* Update

* Update

* Code Coverage Update

* Update

* Update

* Update

* Update

* update

* Update template-run-integration-tests.yaml

* Update template-run-unit-tests.yaml

* Update CodeCoverage.runsettings

* Update

* Update template-run-cachecompat-tests.yaml

* Adding code coverage gate

* Updated code coverage to use variable

* Update template-build-and-run-all-tests.yaml

* Apply suggestions from code review

Co-authored-by: Gladwin Johnson <[email protected]>

---------

Co-authored-by: trwalke <[email protected]>
Co-authored-by: Gladwin Johnson <[email protected]>
  • Loading branch information
3 people authored Nov 19, 2024
1 parent d28bc08 commit dc93a54
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 36 deletions.
68 changes: 37 additions & 31 deletions build/CodeCoverage.runsettings
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>

<!-- Customised run settings file to exclude test assemblies from coverage.
See https://msdn.microsoft.com/en-us/library/jj159530.aspx for more info. -->

<!-- File name extension must be .runsettings -->
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<!--
<!-- File name extension must be .runsettings -->
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>

<!--
About include/exclude lists:
Empty "Include" clauses imply all; empty "Exclude" clauses imply none.
Each element in the list is a regular expression (ECMAScript syntax). See http://msdn.microsoft.com/library/2k3te2cs.aspx.
An item must first match at least one entry in the include list to be included.
Included items must then not match any entries in the exclude list to remain included.
-->

<!-- Match assembly file paths: -->
<ModulePaths>
<Include>
<ModulePath>.*\microsoft.identitymodel.clients.activedirectory.dll$</ModulePath>
<ModulePath>.*\microsoft.identity.core.dll$</ModulePath>
<ModulePath>.*\microsoft.identity.client.dll$</ModulePath>

</Include>
<Exclude>
</Exclude>
</ModulePaths>

</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>

-->
<ModulePaths>
<Include>
<ModulePath>.*\microsoft.identity.client.dll$</ModulePath>
</Include>
<Exclude><!-- Exclude all test-related files -->
<ModulePath>.*\\test\\.*</ModulePath>
<ModulePath>.*Test\.dll</ModulePath>
<ModulePath>.*Test\.exe</ModulePath>
</Exclude>
</ModulePaths>
<Sources>
<Exclude><!-- Exclude generated or non-essential source files -->
<Source>.*\\devapps\\.*</Source>
<Source>.*\\CacheCompat\\.*</Source>
<Source>.*\\obj\\.*</Source>
<Source>.*\\json\\.*</Source>
<Source>.*\\android\\.*</Source>
<Source>.*\\ios\\.*</Source>
</Exclude>
</Sources>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
13 changes: 13 additions & 0 deletions build/template-build-and-run-all-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,16 @@ jobs: #Build and stage projects

steps:
- template: template-desktop-unit-and-automation.yaml

- task: BuildQualityChecks@9
inputs:
checkCoverage: true
coverageFailOption: 'build'
coverageType: 'lines'
treat0of0as100: true
forceCoverageImprovement: true
coverageUpperThreshold: '90'
includePartiallySucceeded: false
fallbackOnPRTargetBranch: false
baseDefinitionId: '905' #this is the PR build and it is used as a baseline
baseBranchRef: 'main'
2 changes: 1 addition & 1 deletion build/template-run-cachecompat-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ steps:
testSelector: 'testAssemblies'
testAssemblyVer2: '**\CacheCompat\CommonCache.Test.Unit\bin\**\CommonCache.Test.Unit.dll'
searchFolder: '$(System.DefaultWorkingDirectory)'
codeCoverageEnabled: true
codeCoverageEnabled: false
failOnMinTestsNotRun: true
minimumExpectedTests: '1'
runInParallel: true
5 changes: 3 additions & 2 deletions build/template-run-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ steps:
rerunFailedTests: true
rerunMaxAttempts: '3'
runInParallel: false
codeCoverageEnabled: true
codeCoverageEnabled: false
failOnMinTestsNotRun: true
minimumExpectedTests: '1'
pathtoCustomTestAdapters: 'C:\temp' # Workaround for test failure, as NUnit Test Adapter that gets detected seems to mess something up
Expand All @@ -28,7 +28,7 @@ steps:
rerunFailedTests: true
rerunMaxAttempts: '3'
runInParallel: false
codeCoverageEnabled: true
codeCoverageEnabled: false
failOnMinTestsNotRun: true
minimumExpectedTests: '1'

Expand All @@ -44,3 +44,4 @@ steps:
codeCoverageEnabled: true
failOnMinTestsNotRun: true
minimumExpectedTests: '1'
runSettingsFile: 'build\CodeCoverage.runsettings'
5 changes: 3 additions & 2 deletions build/template-run-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ steps:
testAssemblyVer2: '**\Microsoft.Identity.Test.Unit\bin\**\net4*\Microsoft.Identity.Test.Unit.dll'
searchFolder: '$(System.DefaultWorkingDirectory)'
runInParallel: true
codeCoverageEnabled: true
codeCoverageEnabled: false
failOnMinTestsNotRun: true
minimumExpectedTests: '1'
pathtoCustomTestAdapters: 'C:\temp' # Workaround for test failure, as NUnit Test Adapter that gets detected seems to mess something up
Expand All @@ -27,7 +27,7 @@ steps:
testAssemblyVer2: '**\Microsoft.Identity.Test.Unit\bin\**\net4*\Microsoft.Identity.Test.Unit.dll'
searchFolder: '$(System.DefaultWorkingDirectory)'
runInParallel: true
codeCoverageEnabled: true
codeCoverageEnabled: false
failOnMinTestsNotRun: true
minimumExpectedTests: '1'

Expand All @@ -41,3 +41,4 @@ steps:
codeCoverageEnabled: true
failOnMinTestsNotRun: true
minimumExpectedTests: '1'
runSettingsFile: 'build\CodeCoverage.runsettings'

0 comments on commit dc93a54

Please sign in to comment.