Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update test.yml for SonarCloud integration #2

Merged
merged 4 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
name: test
on:
push:
branches-ignore: [main]
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
unit-tests:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest']
node_version: [lts/-1, lts/*, latest]
node_version: [lts/*]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
# Shallow clones should be disabled for a better relevancy of sonarqube analysis
fetch-depth: 0
- uses: pnpm/action-setup@v4
with:
version: 9.5.0
Expand All @@ -23,4 +28,9 @@ jobs:
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- run: pnpm run build
- run: pnpm run test
- run: pnpm run test:coverage
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
13 changes: 10 additions & 3 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"$schema": "https://json.schemastore.org/nycrc.json",
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"check-coverage": true,
"extensions": [".ts"],
"reporter": ["text", "html", "lcov"]
"check-coverage": false,
"extensions": [
".ts"
],
"reporter": [
"text",
"html",
"lcov"
]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"format:write": "prettier -w \"**/*.{ts,json}\"",
"postpack": "shx rm -f oclif.manifest.json",
"posttest": "pnpm run lint",
"prepack": "oclif manifest && pnpm run build:release && pnpm run test",
"test": "mocha",
"coverage": "nyc --reporter=lcov npm run test"
"prepack": "oclif manifest && pnpm run build:release && pnpm run test:unit",
"test:unit": "mocha",
"test:coverage": "nyc --reporter=lcov npm run test:unit"
},
"keywords": [
"obsidian",
Expand Down
6 changes: 6 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sonar.projectKey=ovm
sonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar.sources=src
sonar.exclusions=**/node_modules/**,**/coverage/**,**/dist/**
sonar.test.inclusions=**/*.test.ts
sonar.typescript.lcov.reportPaths=./coverage/lcov.info
Loading