forked from RaminNietzsche/CVE-Radar
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (88 loc) · 2.96 KB
/
Copy pathquality-sonarcloud.yml
File metadata and controls
102 lines (88 loc) · 2.96 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Category: Quality | SonarCloud static analysis + coverage gate.
# Requires repository secret SONAR_TOKEN (see .github/SONARCLOUD.md).
name: Quality / SonarCloud
on:
pull_request:
branches: [main]
paths: &sonar-paths
- "src/**"
- "server/**"
- "shared/**"
- "tests/**"
- "package.json"
- "package-lock.json"
- ".npmrc"
- "tsconfig*.json"
- "eslint.config.js"
- "sonar-project.properties"
- "scripts/disable-sonar-autoscan.sh"
- "scripts/sonar-quality-gate-status.sh"
- "extended-docs/mermaid_fence.py"
- ".github/workflows/quality-sonarcloud.yml"
- ".github/workflows/quality/**"
push:
branches: [main]
paths: *sonar-paths
workflow_dispatch:
permissions:
contents: read
pull-requests: write
concurrency:
group: sonarcloud-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false
jobs:
analyze:
name: SonarCloud Code Analysis
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check SonarCloud token
id: sonar
env:
TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
if [ -n "$TOKEN" ]; then
echo "configured=true" >> "$GITHUB_OUTPUT"
else
echo "configured=false" >> "$GITHUB_OUTPUT"
echo "::error::SONAR_TOKEN is not set. Add it: https://github.com/RaminNietzsche/CVE-Radar/settings/secrets/actions — see .github/SONARCLOUD.md"
exit 1
fi
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
fetch-depth: 0
- name: Disable SonarCloud Automatic Analysis
if: steps.sonar.outputs.configured == 'true'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: bash scripts/disable-sonar-autoscan.sh
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Tests with coverage
run: npm run test:ci
- name: Verify coverage report
run: test -s coverage/lcov.info
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@689fb39b34b9aa95ebc5f8f119343ddd51542402 # v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: -Dsonar.python.version=3.12
- name: SonarCloud Quality Gate
id: quality-gate
uses: SonarSource/sonarqube-quality-gate-action@d304d050d930b02a896b0f85935344f023928496 # v1
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Quality Gate details
if: failure() && steps.quality-gate.outcome == 'failure'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: bash scripts/sonar-quality-gate-status.sh