diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 9a68b05..6f2b3e0 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -15,7 +15,7 @@ jobs: uses: astral-sh/setup-uv@v4 with: enable-cache: true - cache-dependency-glob: "main/backend/uv.lock" + cache-dependency-glob: "backend/uv.lock" - name: Setup Bun uses: oven-sh/setup-bun@v1 @@ -29,18 +29,15 @@ jobs: uses: extractions/setup-just@v2 - name: Install backend dependencies - working-directory: main run: cd backend && uv sync --dev - name: Install frontend dependencies - working-directory: main run: cd frontend && bun install --frozen-lockfile - name: Install code quality tools run: npm install -g jscpd fallow - name: Run fallow analysis (frontend — SvelteKit) - working-directory: main run: cd frontend && npx fallow --format json --sarif-file fallow-results.sarif > fallow-results.json continue-on-error: true @@ -48,40 +45,37 @@ jobs: uses: github/codeql-action/upload-sarif@v3 if: always() with: - sarif_file: main/frontend/fallow-results.sarif + sarif_file: frontend/fallow-results.sarif category: fallow-frontend - name: Run duplication analysis (backend only) - working-directory: main run: just duplication - name: Run complexity analysis - working-directory: main run: just complexity - name: Run dead code analysis (backend — Python) - working-directory: main run: cd backend && uv run vulture app/ vulture_whitelist.py --min-confidence 80 2>&1 | tee ../vulture-report.txt continue-on-error: true - name: Run dead code analysis (frontend — SvelteKit) - working-directory: main run: cd frontend && npx fallow dead-code --format json > ../fallow-frontend-dead-code.json continue-on-error: true - name: Check quality thresholds - working-directory: main run: | echo "=== Quality Threshold Check ===" FAIL=0 - if [ -f jscpd-report/index.html ]; then - DUP_PCT=$(grep -oP '\d+(?=%)' jscpd-report/index.html | head -1) + if [ -f jscpd-report/jscpd-report.html ]; then + # Scope to the "Duplicated Lines" stat card; a bare grep for digits + # before % matches CSS values like width:100% earlier in the HTML. + DUP_PCT=$(grep -A1 'Duplicated Lines' jscpd-report/jscpd-report.html | grep -oP '\d+(?:\.\d+)?(?=%)' | head -1) if [ -z "$DUP_PCT" ]; then echo "::warning::Could not parse duplication percentage from jscpd report" DUP_PCT=0 fi echo "Duplication: ${DUP_PCT}%" - if [ "$DUP_PCT" -gt 20 ] 2>/dev/null; then + if awk "BEGIN {exit !($DUP_PCT > 20)}"; then echo "::error::Duplication above 20% threshold: ${DUP_PCT}%" FAIL=1 fi @@ -125,11 +119,11 @@ jobs: with: name: code-quality-reports path: | - main/jscpd-report/ - main/vulture-report.txt - main/frontend/fallow-results.json - main/frontend/fallow-results.sarif - main/fallow-frontend-dead-code.json + jscpd-report/ + vulture-report.txt + frontend/fallow-results.json + frontend/fallow-results.sarif + fallow-frontend-dead-code.json - name: Create failure issue if: failure()