Skip to content

Commit 4b4ed1c

Browse files
committed
Ability to ignore files from coverage
1 parent 96c8400 commit 4b4ed1c

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _Currently does not support username/password authentication and presumes you ar
88

99
```yaml
1010
- name: Sonarscanner for dotnet
11-
uses: Secbyte/dotnet-sonarscanner@v1.0
11+
uses: Secbyte/dotnet-sonarscanner@v1.1
1212
with:
1313
buildCommand: dotnet build .
1414
testCommand: dotnet test .
@@ -17,6 +17,7 @@ _Currently does not support username/password authentication and presumes you ar
1717
sonarOrganisation: an-org
1818
verbose: "true"
1919
openCoverPaths: "tests/coverage.opencover.xml"
20+
coverageExclusions: "**test*.cs"
2021
env:
2122
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2223
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -51,6 +52,9 @@ verbose:
5152
openCoverPaths:
5253
description: "Path(s) to coverage file(s)"
5354
required: false
55+
coverageExclusions:
56+
description: "Glob(s) for files to exclude from coverage"
57+
required: false
5458
```
5559
5660
## Environment variables

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ inputs:
2929
openCoverPaths:
3030
description: "Path(s) to coverage file(s)"
3131
required: false
32+
coverageExclusions:
33+
description: "Glob(s) for files to exclude from coverage"
34+
required: false
3235

3336
runs:
3437
using: "docker"
@@ -42,6 +45,7 @@ runs:
4245
- ${{ inputs.sonarOrganisation }}
4346
- ${{ inputs.verbose }}
4447
- ${{ inputs.openCoverPaths }}
48+
- ${{ inputs.coverageExclusions }}
4549

4650
branding:
4751
icon: 'check'

entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# sonarOrganisation = $6
99
# verbose = $7
1010
# openCoverPaths = $8
11+
# coverageExclusions = $9
1112

1213
set -eu
1314

@@ -44,6 +45,11 @@ then
4445
begin_cmd="$begin_cmd /d:sonar.cs.opencover.reportsPaths=\"$8\""
4546
fi
4647

48+
if [ -n "$9" ]
49+
then
50+
begin_cmd="$begin_cmd /d:sonar.coverage.exclusions=\"$9\""
51+
fi
52+
4753
if [ -n "${SONAR_TOKEN}" ]
4854
then
4955
begin_cmd="$begin_cmd /d:sonar.login=\"${SONAR_TOKEN}\""

0 commit comments

Comments
 (0)