Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

SonarCloud

SonarCloud #23

Workflow file for this run

# Copyright 2023 Rob Spoor
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: SonarCloud
on:
workflow_dispatch:
push:
# only run for branches, not tags
branches: ['**']
pull_request:
schedule:
- cron: '0 6 8 1,7 *'
jobs:
scan:
runs-on: ubuntu-latest
concurrency: sonar-${{ github.head_ref || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install packages
run: npm ci
- name: Run tests
run: npm run test:unit
- name: Read package.json
run: |
echo "projectName=`jq -r .name package.json`" >> $GITHUB_ENV
echo "projectDescription=`jq -r .description package.json`" >> $GITHUB_ENV
echo "projectHomepage=`jq -r .homepage package.json`" >> $GITHUB_ENV
echo "projectBugUrl=`jq -r .bugs.url package.json`" >> $GITHUB_ENV
echo "projectRepositoryUrl=`jq -r .repository.url package.json | sed 's/git+//'`" >> $GITHUB_ENV
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SonarCloudToken }}
SONAR_HOST_URL: https://sonarcloud.io
with:
# omitted for now: -Dsonar.projectDescription=${{ env.projectDescription }}
args: |
-Dsonar.organization=robtimus-github
-Dsonar.projectKey=robtimus:${{ env.projectName }}
-Dsonar.links.homepage=${{ env.projectHomepage }}
-Dsonar.links.issue=${{ env.projectBugUrl }}
-Dsonar.links.scm=${{ env.projectRepositoryUrl }}
-Dsonar.sources=src
-Dsonar.tests=test
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SonarCloudToken }}
SONAR_HOST_URL: https://sonarcloud.io