Skip to content

Commit

Permalink
ci: Integrate Sonar analysis with test coverage on PRs into CI (#2182)
Browse files Browse the repository at this point in the history
* Integrate Sonar analysis with test coverage on PRs into CI

* Force CI to run again

* Fix project name

* Add comments and be consistent with projectName
  • Loading branch information
edwardsph authored Jun 23, 2022
1 parent 8d57b6f commit a7e1302
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,46 @@ jobs:
cache: npm
- run: npm ci
- run: npm run test

# Sonar analysis needs the full history for features like automatic assignment of bugs. If the following step
# is not included the project will show a warning about incomplete information.
- run: git fetch --unshallow
if: ${{ matrix.node-version == '16' }}

# Since this is a monorepo, the Sonar scan must be run on each of the packages but this will pull in the test
# coverage information produced by the tests already run.
- name: SonarCloud Scan - Browser
if: ${{ matrix.node-version == '16' }}
uses: SonarSource/sonarcloud-github-action@v1.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: packages/browser

- name: SonarCloud Scan - Core
if: ${{ matrix.node-version == '16' }}
uses: SonarSource/sonarcloud-github-action@v1.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: packages/core

- name: SonarCloud Scan - Node
if: ${{ matrix.node-version == '16' }}
uses: SonarSource/sonarcloud-github-action@v1.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: packages/node

- name: SonarCloud Scan - OIDC
if: ${{ matrix.node-version == '16' }}
uses: SonarSource/sonarcloud-github-action@v1.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: packages/oidc
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
],
reporters: ["default"],
collectCoverage: true,
coverageReporters: ["text"],
coverageReporters: process.env.CI ? ["text", "lcov"] : ["text"],
coverageThreshold: {
global: {
branches: 100,
Expand Down
15 changes: 15 additions & 0 deletions packages/browser/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sonar.projectKey=inrupt_solid-client-authn-browser
sonar.projectName=solid-client-authn-browser
sonar.organization=inrupt

# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=src

# Typescript tsconfigPath JSON file
sonar.typescript.tsconfigPath=.

# Comma-delimited list of paths to LCOV coverage report files. Paths may be absolute or relative to the project root.
sonar.javascript.lcov.reportPaths=./coverage/lcov.info

# Exclude tests from analysis
sonar.exclusions=**/*.test.ts
15 changes: 15 additions & 0 deletions packages/core/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sonar.projectKey=inrupt_solid-client-authn-core
sonar.projectName=solid-client-authn-core
sonar.organization=inrupt

# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=src

# Typescript tsconfigPath JSON file
sonar.typescript.tsconfigPath=.

# Comma-delimited list of paths to LCOV coverage report files. Paths may be absolute or relative to the project root.
sonar.javascript.lcov.reportPaths=./coverage/lcov.info

# Exclude tests from analysis
sonar.exclusions=**/*.test.ts
15 changes: 15 additions & 0 deletions packages/node/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sonar.projectKey=inrupt_solid-client-authn-node
sonar.projectName=solid-client-authn-node
sonar.organization=inrupt

# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=src

# Typescript tsconfigPath JSON file
sonar.typescript.tsconfigPath=.

# Comma-delimited list of paths to LCOV coverage report files. Paths may be absolute or relative to the project root.
sonar.javascript.lcov.reportPaths=./coverage/lcov.info

# Exclude tests from analysis
sonar.exclusions=**/*.test.ts
15 changes: 15 additions & 0 deletions packages/oidc/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sonar.projectKey=inrupt_oidc-client-ext
sonar.projectName=oidc-client-ext
sonar.organization=inrupt

# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=src

# Typescript tsconfigPath JSON file
sonar.typescript.tsconfigPath=.

# Comma-delimited list of paths to LCOV coverage report files. Paths may be absolute or relative to the project root.
sonar.javascript.lcov.reportPaths=./coverage/lcov.info

# Exclude tests from analysis
sonar.exclusions=**/*.test.ts

0 comments on commit a7e1302

Please sign in to comment.