Skip to content

Commit a526ff5

Browse files
authored
chore: add sonar configuration for code quality analysis (#3171)
1 parent 389db5e commit a526ff5

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

.github/workflows/pr.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
# Tests are executed and coverage reports are emitted as to the action summary
44
# A dependent workflow which uses workflow_run as a trigger reads the archived outputs and emits comments to the PR triggering this build
55

6-
name: Build pr
6+
name: Build and Test
77

88
on:
9+
push:
10+
branches: [main, release/**, next/**]
911
pull_request:
1012
branches: [main, release/**, next/**]
1113

@@ -35,18 +37,19 @@ jobs:
3537
- run: yarn build
3638
- run: yarn lint
3739
- run: yarn test
40+
3841
- name: Archive test results
3942
uses: actions/upload-artifact@v2 # upload test results
4043
if: always() # run this step even if previous step failed
4144
with:
4245
name: test-results
4346
path: testResults/junit.xml
44-
- name: Archive coverage report
45-
uses: actions/upload-artifact@v2 # upload coverage report
47+
- name: Archive coverage artifacts
48+
uses: actions/upload-artifact@v3 # upload coverage rartifacts
4649
if: always() # run this step even if previous step failed
4750
with:
4851
name: coverage
49-
path: coverage/cobertura-coverage.xml
52+
path: coverage/
5053

5154
- name: Code Coverage Summary Report
5255
uses: irongut/[email protected]
@@ -72,3 +75,21 @@ jobs:
7275
- name: One or more build matrix options failed
7376
if: ${{ contains(needs.*.result, 'failure') }}
7477
run: exit 1
78+
79+
sonarcloud:
80+
name: SonarCloud Analysis
81+
runs-on: ubuntu-latest
82+
needs: build
83+
steps:
84+
- uses: actions/checkout@v3
85+
86+
- uses: actions/download-artifact@v3
87+
with:
88+
name: coverage
89+
path: coverage/
90+
91+
- name: Run sonar cloud analysis
92+
uses: SonarSource/sonarcloud-github-action@master
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
95+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-project.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
sonar.projectKey=microsoftgraph_microsoft-graph-toolkit
2+
sonar.organization=microsoftgraph2
3+
sonar.projectName=microsoft-graph-toolkit
4+
sonar.projectVersion=4.2.1
5+
sonar.host.url=https://sonarcloud.io
6+
7+
sonar.sources=packages
8+
sonar.test.inclusions=packages/**/*.tests.ts
9+
sonar.exclusions=node_modules,samples
10+
sonar.sourceEncoding=UTF-8
11+
12+
sonar.javascript.lcov.reportPaths=coverage/lcov.info

0 commit comments

Comments
 (0)