Skip to content

Commit 685276f

Browse files
authored
Pass more args to Sonar (#2356)
* Pass projectVersion to Sonar * Fix s'more * Fix sonar.lang.patterns.ts
1 parent 03a79dc commit 685276f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/sonarqube.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ jobs:
1010
runs-on: ubuntu-latest
1111
if: github.event.workflow_run.conclusion == 'success'
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
with:
15-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
15+
ref: ${{ github.event.workflow_run.head_sha }} # checkout commit that triggered this workflow
16+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
17+
18+
# fetch develop so that Sonar can identify new issues in PR builds
19+
- name: Fetch develop
20+
if: "github.event.workflow_run.head_branch != 'develop'"
21+
run: git rev-parse HEAD && git fetch origin develop:develop && git status && git rev-parse HEAD
1622

1723
# There's a 'download artifact' action, but it hasn't been updated for the workflow_run action
1824
# (https://github.com/actions/download-artifact/issues/60) so instead we get this mess:
@@ -40,8 +46,16 @@ jobs:
4046
- name: Extract Coverage Report
4147
run: unzip -d coverage coverage.zip && rm coverage.zip
4248

49+
- name: Read version
50+
id: version
51+
uses: WyriHaximus/github-action-get-previous-tag@v1
52+
4353
- name: SonarCloud Scan
4454
uses: SonarSource/sonarcloud-github-action@master
55+
with:
56+
args: >
57+
-Dsonar.projectVersion=${{ steps.version.outputs.tag }}
58+
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
4559
env:
4660
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
4761
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-project.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ sonar.typescript.tsconfigPath=./tsconfig.json
1212
sonar.javascript.lcov.reportPaths=coverage/lcov.info
1313
sonar.coverage.exclusions=spec/**/*
1414
sonar.testExecutionReportPaths=coverage/test-report.xml
15+
16+
sonar.lang.patterns.ts=**/*.ts,**/*.tsx

0 commit comments

Comments
 (0)