免费在 GitHub 公开
ci
Run the local CI pipeline (ruff, bandit, pytest, sonar-scanner) and refresh SonarQube.
中文简介正在准备中。当前显示原文说明。
查看安装方法包含的文件(1)
- SKILL.md2.1 KB
SKILL.md(原文)
安装前可以查看交给 AI 代理的指令内容。
/ci: full local CI + SonarQube refresh
Run this before opening a PR, or whenever the mcp__sonarqube__* findings look stale. The scanner
uploads the JSON reports that ruff, bandit, and pytest produce, so those have to run first.
Steps
- Drop stale reports so the scanner never uploads yesterday's data.
- Sync dev and test deps.
- Run ruff with a JSON report (exit-zero so the chain continues even if there are findings).
- Run bandit with a JSON report (exit-zero, same reason).
- Run the full pytest suite (must pass; pytest-cov writes
reports/coverage.xml). - Assert
reports/coverage.xmlexists and is non-empty. This guards against the "0% coverage" trap wheresonar-scannersilently ships an empty report. - Invoke
sonar-scanner, tee the log toreports/sonar-scan.log.
rm -f reports/coverage.xml reports/lcov.info reports/ruff_report.json reports/bandit_report.json && \
uv sync --group dev --group test && \
uv run ruff check --fix --output-format=json --output-file=reports/ruff_report.json --exit-zero . && \
uv run bandit --configfile pyproject.toml --recursive --format json --output reports/bandit_report.json --exit-zero . && \
uv run pytest && \
test -s reports/coverage.xml && \
sonar-scanner 2>&1 | tee reports/sonar-scan.log
After the scanner finishes, use mcp__sonarqube__search_sonar_issues_in_projects to pull new
findings for review.
Notes
- pytest is the gate: if tests fail, the chain stops before the scanner runs.
- The
test -s reports/coverage.xmlguard is the second gate. If coverage.xml is missing or empty the chain stops before upload, so the SonarCloud dashboard never flips back to 0%. - ruff and bandit are set to
--exit-zeroon purpose so report JSON is always written. - Do not skip this pipeline to make findings disappear. If something is flaky, fix the flake.
- Do not run
sonar-scanneron its own. Without a freshreports/coverage.xmlit uploads an analysis with 0% coverage and overwrites the last good one.
评价
还没有评价。欢迎分享你的使用感受。
评论
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。