Skip to content

Commit

Permalink
ci: added sonar action (#7)
Browse files Browse the repository at this point in the history
* ci: added sonar action

* docs: added badges to readme

* refactor: corrected sonar warning
  • Loading branch information
rH4rtinger authored Oct 14, 2024
1 parent 35bea6d commit 31d7d31
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 27 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/lint.yml

This file was deleted.

60 changes: 55 additions & 5 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 @@ -16,16 +21,61 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Check Node.js version
run: node -v

- name: Check npm versions
run: npm -v

- name: Cache node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}
- name: Run clean install
run: npm ci

- run: xvfb-run -a npm test
if: runner.os == 'Linux'
- run: npm test
if: runner.os != 'Linux'

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

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x

- name: Restore cached node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-ubuntu-latest-node-22.x-${{ hashFiles('package-lock.json') }}
restore-keys: |
node_modules-ubuntu-latest-node-22.x
- name: Run ESLint
run: npm run lint -- --format json --output-file eslint-results.json || true

- 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: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --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_vscode-input
-Dsonar.organization=aditosoftware
-Dsonar.eslint.reportPaths=eslint-results.json
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# vscode-input

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-input&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-input)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-input&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-input)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-input&metric=coverage)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-input)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=aditosoftware_vscode-input&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=aditosoftware_vscode-input)

This is used to add a simple and easy to use input elements to any VS Code extension.

These input elements should be used for any multi step inputs.
Expand Down
2 changes: 1 addition & 1 deletion src/type/quickPick/AbstractQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export abstract class GenericQuickPick<T extends GenericQuickPickOptions> extend

quickPick.items.forEach((pItem) => {
const label = pItem.label;
if (oldValues && oldValues.includes(label)) {
if (oldValues?.includes(label)) {
// if the current item was in the oldValues, then pick it
pItem.picked = true;
selectedItems.push(pItem);
Expand Down

0 comments on commit 31d7d31

Please sign in to comment.