ci: add frontend SonarQube analysis #19
Conventional commits / commits (pull_request) Successful in 22s
Frontend security / security (pull_request) Successful in 16s
Frontend verify / verify (pull_request) Successful in 3m59s
Frontend security / security (push) Successful in 18s
Frontend verify / verify (push) Successful in 9m45s
Conventional commits / commits (pull_request) Successful in 22s
Frontend security / security (pull_request) Successful in 16s
Frontend verify / verify (pull_request) Successful in 3m59s
Frontend security / security (push) Successful in 18s
Frontend verify / verify (push) Successful in 9m45s
This commit was merged in pull request #20.
This commit is contained in:
@@ -11,6 +11,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Record checked revision
|
||||
run: git rev-parse HEAD
|
||||
- uses: https://github.com/actions/setup-node@v4
|
||||
@@ -24,3 +26,11 @@ jobs:
|
||||
env:
|
||||
# OXC raw transfer allocates a ~6 GiB buffer; use the standard parser in CI.
|
||||
KNIP_DISABLE_RAW_TRANSFER: '1'
|
||||
- name: Analyze develop with SonarQube
|
||||
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/develop'
|
||||
# v2.3.0: Docker-based scanner for the SonarQube 9.9 server.
|
||||
uses: https://github.com/SonarSource/sonarqube-scan-action@aecaf43ae57e412bd97d70ef9ce6076e672fe0a9
|
||||
env:
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
with:
|
||||
args: -Dsonar.qualitygate.wait=true
|
||||
|
||||
@@ -12,6 +12,7 @@ dist
|
||||
storybook-static
|
||||
dist-ssr
|
||||
coverage
|
||||
.scannerwork
|
||||
*.local
|
||||
|
||||
# Local runtime configuration
|
||||
|
||||
@@ -74,6 +74,42 @@ TypeScript остаётся на 5.9.3: `openapi-typescript@7.13.0` требуе
|
||||
обновите `src/shared/api/spec/openapi.json` копированием backend OpenAPI
|
||||
document и затем выполните `npm run openapi:generate`.
|
||||
|
||||
## SonarQube
|
||||
|
||||
Проект `wealthledger-frontend` использует настройки из
|
||||
`sonar-project.properties`. Анализируются исходники `src`; тесты учитываются
|
||||
отдельно, а Storybook fixtures, test helpers, generated API types и OpenAPI
|
||||
snapshot исключены. `npm run test:coverage` (также входит в `npm run verify`)
|
||||
создаёт `coverage/lcov.info` для импорта покрытия.
|
||||
|
||||
Для первого анализа установите SonarScanner CLI, совместимый с версией сервера,
|
||||
и выполните из корня frontend:
|
||||
|
||||
```bash
|
||||
nvm use --silent
|
||||
npm ci
|
||||
npm run test:coverage
|
||||
# SONAR_TOKEN передайте через окружение; не сохраняйте токен в репозитории.
|
||||
sonar-scanner
|
||||
```
|
||||
|
||||
В Gitea откройте frontend → Settings → Actions → Secrets и добавьте
|
||||
`SONAR_TOKEN` с токеном анализа проекта. Переименовывать основную ветку в
|
||||
SonarQube не требуется; `sonar.branch.name` не задаётся.
|
||||
Используется Community Edition 9.9.8: CI отправляет только
|
||||
push в `develop`, после успешного `verify`, и ожидает результат Quality Gate.
|
||||
PR и остальные ветки проходят обычные проверки без отправки в SonarQube.
|
||||
Отрицательный Quality Gate или ошибка scanner завершает `verify` с ошибкой.
|
||||
|
||||
Runner должен поддерживать Docker actions и иметь HTTPS-доступ к
|
||||
`https://sonarqube.ksv741.keenetic.pro`, GitHub и Docker Hub. Docker action
|
||||
SonarSource закреплён на commit версии 2.3.0; scanner запускается отдельно от
|
||||
Node 24, используемого для сборки. `tsconfig.sonar.json` содержит совместимые
|
||||
со старым анализатором TS настройки; приложение проверяется штатным TypeScript
|
||||
5.9 через `npm run verify`. После обновления сервера пересмотрите scanner и
|
||||
возможность использовать основной tsconfig. Успешный локальный `verify` не
|
||||
доказывает доступность сервера и успешность анализа в CI.
|
||||
|
||||
## UI-каталог Storybook
|
||||
|
||||
После `nvm use --silent` выполните `npm run dev:catalog`; статическая сборка —
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
sonar.projectKey=wealthledger-frontend
|
||||
sonar.projectName=WealthLedger frontend
|
||||
sonar.host.url=https://sonarqube.ksv741.keenetic.pro
|
||||
sonar.sourceEncoding=UTF-8
|
||||
|
||||
sonar.sources=src
|
||||
sonar.tests=src
|
||||
sonar.test.inclusions=src/**/*.test.ts,src/**/*.test.tsx
|
||||
sonar.exclusions=src/**/*.test.ts,src/**/*.test.tsx,src/**/*.stories.tsx,src/test/**,src/shared/api/generated/**,src/shared/api/spec/**
|
||||
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
||||
# SonarQube 9.9 embeds an older TypeScript analyzer than the application compiler.
|
||||
sonar.typescript.tsconfigPaths=tsconfig.sonar.json
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true,
|
||||
"baseUrl": ".",
|
||||
"paths": { "@/*": ["src/*"] }
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
+1
-1
@@ -21,7 +21,7 @@ export default defineConfig({
|
||||
"src/**/*.test.{ts,tsx}",
|
||||
"src/**/*.stories.tsx",
|
||||
],
|
||||
reporter: ["text", "html"],
|
||||
reporter: ["text", "html", "lcov"],
|
||||
thresholds: {
|
||||
statements: 82,
|
||||
branches: 75,
|
||||
|
||||
Reference in New Issue
Block a user