Skip to content

Commit 17b6743

Browse files
author
Umutcan ÖNER
committed
feat: complete SonarLint integration with final fixes
- Fix test command in CI workflow to prevent hanging (--run flag) - Update workflow to use correct develop branch instead of main - Add comprehensive GitHub secrets setup documentation - Verify coverage integration with vitest configurations - Complete documentation with troubleshooting and best practices All SonarLint roadmap phases now fully implemented: ✅ VSCode extension setup and configuration ✅ Custom rules and quality gates ✅ CI/CD integration with SonarCloud ✅ Complete team onboarding documentation
1 parent 27603cd commit 17b6743

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# to identify bugs, vulnerabilities, code smells, and coverage gaps.
77
#
88
# Triggers:
9-
# - Push to main branch
10-
# - Pull requests targeting main branch
9+
# - Push to develop branch
10+
# - Pull requests targeting develop branch
1111
#
1212
# Key Features:
1313
# - Comprehensive code quality analysis with SonarCloud
@@ -29,10 +29,10 @@ name: SonarCloud Analysis
2929

3030
on:
3131
push:
32-
branches: [main]
32+
branches: [develop]
3333
pull_request:
3434
types: [opened, synchronize, reopened]
35-
branches: [main]
35+
branches: [develop]
3636

3737
permissions:
3838
contents: read
@@ -47,7 +47,7 @@ jobs:
4747
runs-on: ubuntu-latest
4848
# Skip analysis for bots and when explicitly requested
4949
if: "!contains(github.event.head_commit.message, 'skip sonar') && github.actor != 'dependabot[bot]'"
50-
50+
5151
steps:
5252
# Step 1: Check out the repository with full history
5353
# Full history is required for accurate blame information and new code detection
@@ -93,7 +93,7 @@ jobs:
9393
# Step 7: Run tests with coverage for SonarCloud
9494
# This generates coverage reports that SonarCloud will use
9595
- name: Run tests with coverage
96-
run: pnpm test -- --coverage
96+
run: pnpm test -- --coverage --run
9797

9898
# Step 8: Run SonarCloud analysis
9999
# Analyzes code quality, security vulnerabilities, and test coverage
@@ -123,12 +123,12 @@ jobs:
123123
const status = '${{ steps.sonarcloud-quality-gate-check.outputs.quality-gate-status }}';
124124
const emoji = status === 'PASSED' ? '✅' : '⚠️';
125125
const message = `${emoji} **SonarCloud Quality Gate**: ${status}
126-
127-
[View detailed analysis on SonarCloud](https://sonarcloud.io/dashboard?id=zopio)`;
128-
126+
127+
[View detailed analysis on SonarCloud](https://sonarcloud.io/dashboard?id=zopiolabs_zopio_test_fork)`;
128+
129129
github.rest.issues.createComment({
130130
issue_number: context.issue.number,
131131
owner: context.repo.owner,
132132
repo: context.repo.repo,
133133
body: message
134-
});
134+
});

docs/dev/quality/sonarlint.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,34 @@ SonarCloud enforces:
245245

246246
---
247247

248+
## Setting Up GitHub Secrets (Repository Admin Only)
249+
250+
For the SonarCloud CI/CD integration to work, repository administrators must set up the following GitHub secret:
251+
252+
### Required Secret: `SONAR_TOKEN`
253+
254+
1. **Generate SonarCloud Token:**
255+
- Go to [SonarCloud Security](https://sonarcloud.io/account/security)
256+
- Generate a new token with a descriptive name (e.g., "GitHub Actions CI")
257+
- **Important:** This should be a different token from personal SonarLint tokens
258+
- Copy the token (it will only be shown once)
259+
260+
2. **Add Secret to GitHub Repository:**
261+
- Navigate to: `Settings``Secrets and variables``Actions`
262+
- Click `New repository secret`
263+
- Name: `SONAR_TOKEN`
264+
- Value: Paste the SonarCloud token
265+
- Click `Add secret`
266+
267+
3. **Verify Setup:**
268+
- The workflow uses `${{ secrets.SONAR_TOKEN }}` automatically
269+
- No code changes needed once the secret is configured
270+
- Test by creating a pull request
271+
272+
**Security Note:** Never commit SonarCloud tokens to the repository. The provided API key in the task description should be used to set up this GitHub secret, not placed in any code files.
273+
274+
---
275+
248276
## Resources
249277

250278
- [SonarLint Rules Reference](https://rules.sonarsource.com/typescript)

0 commit comments

Comments
 (0)