From 97de2f0905191c6ef3b49b970905d905714558f7 Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Wed, 23 Nov 2022 11:42:44 +0100 Subject: [PATCH] Set up SonarCloud static analysis --- .github/workflows/build.yml | 31 ++++++++++++++++++++----------- sonar-project.properties | 6 ++++++ 2 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39c3639..b90f5ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,21 +10,23 @@ jobs: fail-fast: false matrix: include: - - { node-version: 10.x, lint: false, tests: false } - - { node-version: 11.x, lint: false, tests: false } - - { node-version: 12.x, lint: false, tests: false } - - { node-version: 13.x, lint: false, tests: false } - - { node-version: 14.x, lint: true, tests: true } - - { node-version: 15.x, lint: false, tests: true } - - { node-version: 16.x, lint: true, tests: true } - - { node-version: 17.x, lint: true, tests: true } - - { node-version: 18.x, lint: true, tests: true } - - { node-version: 19.x, lint: true, tests: true } + - { node-version: 10.x, lint: false, static-analysis: false, tests: false } + - { node-version: 11.x, lint: false, static-analysis: false, tests: false } + - { node-version: 12.x, lint: false, static-analysis: false, tests: false } + - { node-version: 13.x, lint: false, static-analysis: false, tests: false } + - { node-version: 14.x, lint: true, static-analysis: false, tests: true } + - { node-version: 15.x, lint: false, static-analysis: false, tests: true } + - { node-version: 16.x, lint: true, static-analysis: false, tests: true } + - { node-version: 17.x, lint: true, static-analysis: false, tests: true } + - { node-version: 18.x, lint: true, static-analysis: 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: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 @@ -75,6 +77,13 @@ jobs: run: npm run 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 run: npm test if: ${{ matrix.tests }} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..11e742c --- /dev/null +++ b/sonar-project.properties @@ -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