Skip to content
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
21 changes: 19 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ on:

permissions:
contents: read
pull-requests: read

jobs:
test:
runs-on: ubuntu-latest
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN || secrets.SONARCLOUD_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v5
Expand All @@ -26,5 +31,17 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test
- name: Run tests with coverage
run: npm run test:coverage

- name: SonarCloud scan
uses: SonarSource/sonarqube-scan-action@v7
if: ${{ env.SONAR_TOKEN != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}

- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: coverage
if-no-files-found: error
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const eslintConfig = defineConfig([
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"coverage/**",
"out/**",
"build/**",
"next-env.d.ts",
Expand Down
148 changes: 148 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "next build",
"start": "next start",
"lint": "eslint",
"test": "vitest run"
"test": "vitest run",
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"exceljs": "^4.4.0",
Expand All @@ -25,6 +26,7 @@
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"@vitest/coverage-v8": "^4.1.8",
"eslint": "^9",
"eslint-config-next": "16.2.7",
"jsdom": "^29.1.1",
Expand Down
8 changes: 8 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sonar.projectKey=arnabnandy7_api-response-comparator
sonar.organization=arnabnandy7

sonar.sources=src
sonar.tests=test

sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.coverage.exclusions=src/**/*.d.ts
7 changes: 7 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ export default defineConfig({
},
test: {
environment: 'jsdom',
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html', 'lcov'],
reportsDirectory: './coverage',
include: ['src/**/*.{ts,tsx}'],
exclude: ['src/**/*.d.ts'],
},
},
});
Loading