Skip to content

Commit

Permalink
chore(testing): Configure SonarQube to include TypeScript test files (#…
Browse files Browse the repository at this point in the history
…36)

* chore(testing): Configure SonarQube to include TypeScript test files

Added a configuration to include TypeScript test files located in the `src` directory for SonarQube analysis. This change helps in capturing and analyzing test-specific metrics to enhance code quality assessments.

* Integrate SonarCloud config into GitHub Workflow

Remove the standalone sonar-project.properties file and incorporate its configuration directly into the GitHub Actions workflow. This change centralizes the SonarCloud configuration, streamlining the maintenance and execution process within the CI/CD pipeline.

* Update ESLint workflow to adjust report file paths

Modified the ESLint run command to process the report by removing the workspace path prefix in the 'eslint-report.json'. This change ensures that file paths in the report are relative, thus simplifying file path management and making reports easier to manage and interpret.

* Update ESLint report path in GitHub Actions

This change modifies the path replacement in the ESLint report generation step to use '/github/workspace/' instead of removing the GitHub workspace path prefix. This ensures that paths in the ESLint report correctly reflect the directory structure used during the GitHub Action's execution. It aims to improve the accuracy and usefulness of the ESLint reports in CI workflows.

* Add SonarCloud configuration and streamline CI setup

Introduce a new `sonar-project.properties` file to configure SonarCloud integration for the project. This change centralizes the SonarCloud settings and removes redundant command-line parameters from the GitHub Actions workflow. Additionally, it fixes the ESLint report path in CI by stripping the workspace prefix.

* Refactor sonar configuration and update ESLint command path.

Reordered the paths for JavaScript and ESLint reports in sonar-project.properties to enhance readability and maintain consistency. Updated the ESLint command in package.json to specify the src/ directory, ensuring linting is applied only to source files.
  • Loading branch information
hckhanh authored Dec 2, 2024
1 parent 690975f commit d58b49d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ jobs:
run: pnpm test -- --coverage.enabled
env:
GOOGLE_SAFE_BROWSING_API_KEY: ${{ secrets.GOOGLE_SAFE_BROWSING_API_KEY }}
- name: Run ESLint
run: pnpm test:eslint
- name: Generate ESLint report
run: |
pnpm test:eslint
sed -i 's|${{ github.workspace }}/||g' lints/eslint-report.json
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@383f7e52eae3ab0510c3cb0e7d9d150bbaeab838
env:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test": "vitest related src/*.ts",
"test:prettier": "prettier --check .",
"test:types": "deno check src/index.ts",
"test:eslint": "eslint . -f json -o lints/eslint-report.json"
"test:eslint": "eslint src/ -f json -o lints/eslint-report.json"
},
"author": {
"name": "Khánh Hoàng",
Expand Down
6 changes: 6 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
sonar.projectKey=hckhanh_google-safe-browsing
sonar.organization=hckhanh

sonar.sources=src/
sonar.exclusions=src/**/*.test.ts

sonar.tests=src/
sonar.test.inclusions=src/**/*.test.ts

sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.eslint.reportPaths=lints/eslint-report.json

0 comments on commit d58b49d

Please sign in to comment.