Skip to content

Commit

Permalink
ci: added sonar to action
Browse files Browse the repository at this point in the history
  • Loading branch information
rH4rtinger committed Oct 9, 2024
1 parent f7ba14c commit 001a88c
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: ESLint

on:
push:
branches: [ "main" ]
pull_request:

permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results

jobs:
eslint:
name: Run eslint scanning
Expand All @@ -18,4 +23,41 @@ jobs:
run: npm ci

- name: Run ESLint
run: npm run lint
run: npm run lint --format json --output-file eslint-results.json || true

- name: Install Coverage Reporters
run: npm install -g nyc
npm install -d mocha-multi-reporters
npm install -d mocha-junit-reporter
npm install -d mocha-sonarqube-reporter
- run: |
echo '{
"reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter"
}' > config.json
- name: Run tests with coverage
run: nyc --reporter lcovonly npm run test -- --reporter mocha-multi-reporters --reporter-options configFile=config.json


- name: Analyze with SonarCloud
uses: SonarSource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
# Additional arguments for the SonarScanner CLI
args:
# Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu)
# mandatory
-Dsonar.projectKey=aditosoftware_driver-dependencies
-Dsonar.organization=aditosoftware
-Dsonar.eslint.reportPaths=eslint-results.json
-Dsonar.testExecutionReportPaths=xunit.xml
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
# Comma-separated paths to directories containing main source files.
#-Dsonar.sources= # optional, default is project base directory
# Comma-separated paths to directories containing test source files.
#-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/
# Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing.
#-Dsonar.verbose= # optional, default is false
# When you need the analysis to take place in a directory other than the one from which it was launched, default is .
projectBaseDir: .

0 comments on commit 001a88c

Please sign in to comment.