Skip to content

Commit

Permalink
ci: moved sonar action into nodejs action file
Browse files Browse the repository at this point in the history
  • Loading branch information
rH4rtinger committed Oct 9, 2024
1 parent 680580c commit 43ce84d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 62 deletions.
62 changes: 0 additions & 62 deletions .github/workflows/lint.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Build Project

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

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

jobs:
build:
strategy:
Expand All @@ -27,3 +32,41 @@ jobs:

- name: Run tests
run: npm test

sonar:
name: Run eslint and sonar scanning
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: npm ci

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

- name: Install Coverage Reporters
run: npm install -g nyc
- name: Install Mocha reporters
run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter
- name: create mocha config
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:
args: -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

0 comments on commit 43ce84d

Please sign in to comment.