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(testing): Switch coverage reporting from Codecov to SonarCloud #34

Merged
merged 6 commits into from
Dec 2, 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
25 changes: 11 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ jobs:
run: pnpm test -- --environment=edge-runtime
env:
GOOGLE_SAFE_BROWSING_API_KEY: ${{ secrets.GOOGLE_SAFE_BROWSING_API_KEY }}
coverage:
name: Coverage
analytics:
name: Analytics
needs: [node, edge]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@ac5bf11548bf5e19b8aadb8182072616590fa4a6
- name: Set up Node.js
Expand All @@ -86,18 +88,13 @@ jobs:
run: pnpm test -- --coverage.enabled
env:
GOOGLE_SAFE_BROWSING_API_KEY: ${{ secrets.GOOGLE_SAFE_BROWSING_API_KEY }}
TEST_ANALYTICS: 1
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a
if: ${{ github.actor != 'renovate[bot]' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ github.actor != 'renovate[bot]' && !cancelled() }}
uses: codecov/test-results-action@6515afe67c25cf11657e6eb2dd44cc0b032c8883
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: 'coverage/junit.xml'
- name: Run ESLint
run: pnpm test:eslint
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@383f7e52eae3ab0510c3cb0e7d9d150bbaeab838
env:
SONAR_TOKEN: ${{ secrets. SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deno:
name: Deno
needs: lints
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ node_modules/
# environment variables
.env*

# testing
# reports
coverage
lints
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# google-safe-browsing [![JSR](https://jsr.io/badges/@hckhanh/google-safe-browsing)](https://jsr.io/@hckhanh/google-safe-browsing)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=hckhanh_google-safe-browsing&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=hckhanh_google-safe-browsing)
[![codecov](https://codecov.io/gh/hckhanh/google-safe-browsing/graph/badge.svg?token=OTWNSODDXK)](https://codecov.io/gh/hckhanh/google-safe-browsing)

A JavaScript client for [Google Safe Browsing](https://safebrowsing.google.com) [API](https://developers.google.com/safe-browsing)

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"scripts": {
"test": "vitest related src/*.ts",
"test:prettier": "prettier --check .",
"test:types": "deno check src/index.ts"
"test:types": "deno check src/index.ts",
"test:eslint": "eslint . -f json -o lints/eslint-report.json"
},
"author": {
"name": "Khánh Hoàng",
Expand Down
5 changes: 5 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sonar.projectKey=hckhanh_google-safe-browsing
sonar.organization=hckhanh

sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.eslint.reportPaths=lints/eslint-report.json
7 changes: 2 additions & 5 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ export default defineConfig({
'*.config.js',
...coverageConfigDefaults.exclude,
],
reporter: process.env.CI ? ['clover'] : coverageConfigDefaults.reporter,
reporter: process.env.CI ? ['lcovonly'] : coverageConfigDefaults.reporter,
},
reporters: process.env.CI
? process.env.TEST_ANALYTICS
? ['junit', 'dot', 'github-actions']
: ['dot', 'github-actions']
? ['dot', 'github-actions']
: configDefaults.reporters,
outputFile: 'coverage/junit.xml',
},
})