Skip to content

Commit 4891ac8

Browse files
author
Petr Sramek
committed
added coverage settings
1 parent 9bc6fc3 commit 4891ac8

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

.github/actions/test/action.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ inputs:
2929
code-coverage-output-format:
3030
description: 'Code coverage output format. Default: cobertura'
3131
required: false
32-
default: 'coverage'
32+
default: 'cobertura'
33+
code-coverage-settings-file:
34+
description: 'Code coverage settings file. Default: '
35+
required: false
36+
default: ''
3337
upload-test-artifacts:
3438
description: 'Upload test artifacts, Default: true'
3539
required: false
@@ -68,7 +72,14 @@ runs:
6872
- if: ${{ inputs.collect-code-coverage == 'true' }}
6973
name: 'Set CODE_COVERAGE_ARGS environment variable'
7074
shell: bash
71-
run: echo "CODE_COVERAGE_ARGS=--coverage --coverage-output-format ${{ inputs.code-coverage-output-format}}" >> $GITHUB_ENV
75+
run: |
76+
echo "CODE_COVERAGE_ARGS=--coverage --coverage-output-format ${{ inputs.code-coverage-output-format}}" >> $GITHUB_ENV
77+
78+
- if: ${{ inputs.collect-code-coverage == 'true' && inputs.code-coverage-settings-file != ''}}
79+
name: 'Set CODE_COVERAGE_ARGS environment variable'
80+
shell: bash
81+
run: |
82+
echo "CODE_COVERAGE_ARGS=${{ env.CODE_COVERAGE_ARGS }} --coverage-settings ${{ inputs.code-coverage-settings-file }}" >> $GITHUB_ENV
7283
7384
- name: 'Test with .NET CLI'
7485
shell: bash

.github/workflows/dotnet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
with:
9999
test-project-glob-pattern: ${{ vars.TEST_DEFAULT_GLOB_PATTERN }}
100100
test-results-directory: '${{ runner.temp }}/test-results/'
101+
code-coverage-settings-file: '${{ github.workspace}}/code-coverage-settings.xml'
101102

102103
- uses: ./.github/actions/test-report
103104
id: test-report

code-coverage-settings.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Configuration>
3+
<CodeCoverage>
4+
<!-- Match assembly file paths: -->
5+
<ModulePaths>
6+
<IncludeDirectories>
7+
<Directory>src/**</Directory>
8+
</IncludeDirectories>
9+
</ModulePaths>
10+
11+
<!-- Match attributes on any code element: -->
12+
<Attributes>
13+
<Exclude>
14+
<!-- Don't forget "Attribute" at the end of the name -->
15+
<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
16+
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
17+
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
18+
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
19+
</Exclude>
20+
</Attributes>
21+
22+
<EnableStaticManagedInstrumentation>True</EnableStaticManagedInstrumentation>
23+
<EnableDynamicManagedInstrumentation>True</EnableDynamicManagedInstrumentation>
24+
25+
</CodeCoverage>
26+
</Configuration>

0 commit comments

Comments
 (0)