From 3225214e4322359bdc671d91a77dff5218bb13d5 Mon Sep 17 00:00:00 2001 From: Dilshod Rasulov <20490215+markmorado@users.noreply.github.com> Date: Tue, 18 Aug 2026 23:59:21 +0500 Subject: [PATCH] Add files via upload --- .github/workflows/sonarcloud.yml | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/sonarcloud.yml diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..a5e1d50 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,66 @@ +name: SonarCloud + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + sonarcloud: + name: SonarCloud Analysis + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + # SonarCloud needs full history for accurate blame/new-code detection + fetch-depth: 0 + + # --- Backend: generate coverage.xml so Sonar can report Python coverage --- + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + cache-dependency-path: backend/requirements-dev.txt + + - name: Install backend dependencies + working-directory: backend + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + + - name: Run pytest with coverage + working-directory: backend + run: | + python -m pytest \ + --cov=app \ + --cov-report=xml \ + -p no:warnings + # Don't fail the whole Sonar run just because a test flaked; + # Sonar will simply show stale/no coverage for this run instead. + continue-on-error: true + + # --- Frontend: optional ESLint report for Sonar's JS/TS rules --- + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: npm + cache-dependency-path: frontend/package-lock.json + + - name: Install frontend dependencies + working-directory: frontend + run: npm ci + + - name: Run ESLint (JSON report for Sonar) + working-directory: frontend + run: npx eslint . --format json --output-file eslint-report.json + continue-on-error: true + + # --- SonarCloud scan --- + - name: SonarCloud Scan + uses: SonarSource/sonarqube-scan-action@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}