Set up SonarCloud static analysis

This commit is contained in:
Lars Strojny 2022-11-23 11:42:44 +01:00
parent ddc85f5359
commit 97de2f0905
No known key found for this signature in database
GPG key ID: 887416A2AD3B0CA9
2 changed files with 26 additions and 11 deletions

View file

@ -10,21 +10,23 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- { node-version: 10.x, lint: false, tests: false } - { node-version: 10.x, lint: false, static-analysis: false, tests: false }
- { node-version: 11.x, lint: false, tests: false } - { node-version: 11.x, lint: false, static-analysis: false, tests: false }
- { node-version: 12.x, lint: false, tests: false } - { node-version: 12.x, lint: false, static-analysis: false, tests: false }
- { node-version: 13.x, lint: false, tests: false } - { node-version: 13.x, lint: false, static-analysis: false, tests: false }
- { node-version: 14.x, lint: true, tests: true } - { node-version: 14.x, lint: true, static-analysis: false, tests: true }
- { node-version: 15.x, lint: false, tests: true } - { node-version: 15.x, lint: false, static-analysis: false, tests: true }
- { node-version: 16.x, lint: true, tests: true } - { node-version: 16.x, lint: true, static-analysis: false, tests: true }
- { node-version: 17.x, lint: true, tests: true } - { node-version: 17.x, lint: true, static-analysis: false, tests: true }
- { node-version: 18.x, lint: true, tests: true } - { node-version: 18.x, lint: true, static-analysis: true, tests: true }
- { node-version: 19.x, lint: true, tests: true } - { node-version: 19.x, lint: true, static-analysis: false, tests: true }
name: Node.js ${{ matrix.node-version }}${{ matrix.lint && ', lint' || '' }}${{ matrix.tests && ', test' || '' }}, build name: Node.js ${{ matrix.node-version }}${{ matrix.lint && ', lint' || '' }}${{ matrix.static-analysis && ', static analysis' || ''}}${{ matrix.tests && ', test' || '' }}, build
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
@ -75,6 +77,13 @@ jobs:
run: npm run lint run: npm run lint
if: ${{ matrix.lint }} if: ${{ matrix.lint }}
- name: SonarCloud scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: ${{ matrix.static-analysis }}
- name: Run tests - name: Run tests
run: npm test run: npm test
if: ${{ matrix.tests }} if: ${{ matrix.tests }}

6
sonar-project.properties Normal file
View file

@ -0,0 +1,6 @@
sonar.projectKey=lstrojny_homebridge-prometheus-exporter
sonar.organization=lstrojny
sonar.sources=.
sonar.exclusions=tests/**
sonar.tests=tests
sonar.log.level=DEBUG