Skip to content

Commit 7df2c17

Browse files
Add test inputs to Sonar tests (#453)
1 parent d92f49b commit 7df2c17

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.github/workflows/_sonar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
args: >
6969
"-Dsonar.organization=${{ github.repository_owner }}"
7070
"-Dsonar.projectKey=${{ github.repository_owner }}_${{ github.event.repository.name }}"
71-
"-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}"
71+
${{ contains(github.event_name, 'pull_request') && format('"-Dsonar.pullrequest.key={0}"', github.event.pull_request.number) || '' }}
7272
${{ inputs.sonar-test-inclusions != '' && format('"-Dsonar.test.inclusions={0}"', inputs.sonar-test-inclusions) || '' }}
7373
${{ inputs.sonar-exclusions != '' && format('"-Dsonar.exclusions={0}"', inputs.sonar-exclusions) || '' }}
7474
${{ inputs.sonar-sources != '' && format('"-Dsonar.sources={0}"', inputs.sonar-sources) || '' }}

.github/workflows/test-sonar.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ on:
1010
branches:
1111
- "main"
1212
workflow_dispatch:
13+
inputs:
14+
sonar-config:
15+
description: "Configuration for Sonar"
16+
type: string
17+
default: "default"
18+
sonar-test-inclusions:
19+
description: "Glob pattern(s) for test files to include in Sonar analysis"
20+
type: string
21+
sonar-exclusions:
22+
description: "Glob pattern(s) for files to exclude from Sonar analysis"
23+
type: string
1324

1425
permissions: {}
1526

@@ -25,3 +36,7 @@ jobs:
2536
contents: read
2637
pull-requests: write
2738
id-token: write
39+
with:
40+
sonar-config: ${{ github.event.inputs.sonar-config }}
41+
sonar-test-inclusions: ${{ github.event.inputs.sonar-test-inclusions }}
42+
sonar-exclusions: ${{ github.event.inputs.sonar-exclusions }}

0 commit comments

Comments
 (0)