Skip to content

Commit 62dbf6e

Browse files
authored
Add sonar exclusion input for dotnet (#16)
* Add sonar-exclusions for dotnet * Update sonar exclusions default
1 parent b5937db commit 62dbf6e

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/reusable-dotnet-quality.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ on:
4848
type: boolean
4949
required: false
5050
default: false
51+
sonar-exclusions:
52+
description: Files or directories that should be excluded from Sonar analysis
53+
type: string
54+
required: false
55+
default: "node_modules"
5156
sonar-host-url:
5257
description: Sonar host URL
5358
type: string
@@ -150,10 +155,11 @@ jobs:
150155
uses: ./workflow-parts/actions/dotnet/build-test-sonar
151156
with:
152157
dotnet-test-args: ${{ inputs.dotnet-test-args }}
153-
sonar-organization: ${{ inputs.sonar-organization }}
158+
sonar-exclusions: ${{ inputs.sonar-exclusions }}
154159
sonar-host-url: ${{ inputs.sonar-host-url }}
155-
sonar-project-name: ${{ inputs.sonar-project-name }}
160+
sonar-organization: ${{ inputs.sonar-organization }}
156161
sonar-project-key: ${{ inputs.sonar-project-key }}
162+
sonar-project-name: ${{ inputs.sonar-project-name }}
157163
sonar-token: ${{ secrets.sonar-token }}
158164
- name: Check license compliance with FOSSA
159165
if: ${{ inputs.fossa-enabled }}

actions/dotnet/build-test-sonar/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ inputs:
1010
description: Java version that will be installed (for Sonar CLI)
1111
required: false
1212
default: "21"
13+
sonar-exclusions:
14+
description: Files or directories that should be excluded from Sonar analysis
15+
required: false
16+
default: "**/node_modules/**"
1317
report-folder:
1418
description: Folder where report files will be generated
1519
required: false
@@ -71,7 +75,7 @@ runs:
7175
/d:sonar.token="${{ inputs.sonar-token}}" \
7276
/d:sonar.host.url="${{ inputs.sonar-host-url }}" \
7377
/d:sonar.cpd.exclusions="**/*Generated*.cs,${{ inputs.report-folder }}/**" \
74-
/d:sonar.exclusions="${{ inputs.report-folder }}/**/*" \
78+
/d:sonar.exclusions="${{ inputs.report-folder }}/**,${{ inputs.sonar-exclusions }}" \
7579
/d:sonar.coverageReportPaths="${{ inputs.report-folder }}/SonarQube.xml" \
7680
/d:sonar.cs.vstest.reportsPaths="${{ inputs.report-folder }}/TestResults/*.trx"
7781
shell: bash

0 commit comments

Comments
 (0)