-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (72 loc) · 2.64 KB
/
Copy pathsonarqube.yml
File metadata and controls
83 lines (72 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: SonarQube Code Quality
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
workflow_dispatch:
concurrency:
group: sonarqube-${{ github.ref }}
cancel-in-progress: true
jobs:
sonarqube:
name: Scan & enforce Quality Gate
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout (full history for accurate blame)
uses: actions/checkout@v4
with:
fetch-depth: 0
# -------------------------------------------------------------------
# Backend (Python) — produce coverage.xml for Sonar
# -------------------------------------------------------------------
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install backend deps + coverage tools
working-directory: backend
run: |
python -m pip install --upgrade pip
pip install -e .
pip install coverage pytest pytest-cov
- name: Run backend tests with coverage
working-directory: backend
env:
SKIP_LOCAL_OLLAMA: "1"
SKIP_CLOUD: "1"
run: |
pytest \
--cov=app \
--cov-report=xml:coverage.xml \
--junitxml=pytest-report.xml \
tests || true # don't fail the job here; Quality Gate decides
# -------------------------------------------------------------------
# Frontend (Next.js / TS) — produce lcov.info for Sonar
# -------------------------------------------------------------------
- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install frontend deps
working-directory: frontend
run: npm ci || npm install
# If/when you add Jest/Vitest, uncomment to emit coverage:
# - name: Run frontend tests with coverage
# working-directory: frontend
# run: npx vitest run --coverage --coverage.reporter=lcov
# -------------------------------------------------------------------
# SonarQube scan — uploads analysis AND waits for the Quality Gate
# in a single step (-Dsonar.qualitygate.wait=true). The job fails
# red when the gate is not passed.
# -------------------------------------------------------------------
- name: SonarQube Scan & Quality Gate
uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
with:
args: >
-Dsonar.qualitygate.wait=true
-Dsonar.qualitygate.timeout=300