From abcb38a3f77a3591798b8b7960e96e4f6ee4eb6b Mon Sep 17 00:00:00 2001 From: jenkins Date: Mon, 20 Apr 2026 08:14:01 -0300 Subject: [PATCH] ci(atlasbot): enforce docs/style before loc and publish docs_naming --- Jenkinsfile | 29 ++++++++++++++++++++++------- scripts/publish_test_metrics.py | 4 +++- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 082f2a2..61f229a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -218,19 +218,33 @@ PY ;; esac set +e - docker buildx build --platform "${TEST_PLATFORM_RESOLVED}" --target test --load -t atlasbot-test . \ - && docker run --rm -v "$PWD/build:/out" atlasbot-test \ - python -m ruff check atlasbot scripts --select E,F,W,B,C90,I,RUF,ARG --ignore E501 \ - && docker run --rm -v "$PWD/build:/out" atlasbot-test \ + docker buildx build --platform "${TEST_PLATFORM_RESOLVED}" --target test --load -t atlasbot-test . + prep_rc=$? + docs_rc=1 + gate_rc=1 + if [ "${prep_rc}" -eq 0 ]; then + docker run --rm -v "$PWD/build:/out" atlasbot-test \ + python -m ruff check atlasbot scripts --select E,F,W,B,C90,I,RUF,ARG --ignore E501 + ruff_rc=$? + if [ "${ruff_rc}" -eq 0 ]; then + docker run --rm -v "$PWD/build:/out" atlasbot-test \ + python scripts/check_docstrings.py --root atlasbot + docs_rc=$? + else + docs_rc=${ruff_rc} + fi + fi + printf '%s\n' "${docs_rc}" > build/docs-naming.rc + if [ "${prep_rc}" -eq 0 ] && [ "${docs_rc}" -eq 0 ]; then + docker run --rm -v "$PWD/build:/out" atlasbot-test \ python scripts/check_file_sizes.py --root atlasbot --max-lines 500 \ - && docker run --rm -v "$PWD/build:/out" atlasbot-test \ - python scripts/check_docstrings.py --root atlasbot \ && docker run --rm -v "$PWD/build:/out" atlasbot-test \ python -m slipcover --json --out /out/coverage.json --source atlasbot --fail-under 95 \ -m pytest -q --junitxml /out/junit.xml \ && docker run --rm -v "$PWD/build:/out" atlasbot-test \ python scripts/check_coverage.py /out/coverage.json --root atlasbot --threshold 95 - gate_rc=$? + gate_rc=$? + fi set -e printf '%s\n' "${gate_rc}" > build/quality-gate.rc ''' @@ -247,6 +261,7 @@ PY export COVERAGE_PATH='build/coverage.json' export SOURCE_ROOT='atlasbot' export QUALITY_GATE_RC_PATH='build/quality-gate.rc' + export QUALITY_GATE_DOCS_RC_PATH='build/docs-naming.rc' python scripts/publish_test_metrics.py || true ''' } diff --git a/scripts/publish_test_metrics.py b/scripts/publish_test_metrics.py index 246a3a3..7f2b979 100755 --- a/scripts/publish_test_metrics.py +++ b/scripts/publish_test_metrics.py @@ -178,12 +178,14 @@ def main() -> int: junit_path = Path(os.getenv("JUNIT_PATH", "build/junit.xml")) coverage_path = Path(os.getenv("COVERAGE_PATH", "build/coverage.json")) gate_rc_path = Path(os.getenv("QUALITY_GATE_RC_PATH", "build/quality-gate.rc")) + docs_rc_path = Path(os.getenv("QUALITY_GATE_DOCS_RC_PATH", "build/docs-naming.rc")) source_root = Path(os.getenv("SOURCE_ROOT", "atlasbot")) build_dir = Path(os.getenv("BUILD_DIR", "build")) totals = _load_junit(junit_path) coverage_pct = _load_coverage_percent(coverage_path) gate_rc = _load_gate_rc(gate_rc_path) + docs_rc = _load_gate_rc(docs_rc_path) source_lines_over_500 = _count_source_lines_over_500(source_root) passed = max(totals["tests"] - totals["failures"] - totals["errors"] - totals["skipped"], 0) outcome = "ok" if totals["tests"] > 0 and totals["failures"] == 0 and totals["errors"] == 0 else "failed" @@ -193,7 +195,7 @@ def main() -> int: "tests": "ok" if outcome == "ok" else "failed", "coverage": "ok" if coverage_pct >= 95.0 else "failed", "loc": "ok" if source_lines_over_500 == 0 else "failed", - "docs_naming": "not_applicable", + "docs_naming": "ok" if docs_rc == 0 else "failed", "gate_glue": "ok", "sonarqube": _sonarqube_check_status(build_dir), "supply_chain": _supply_chain_check_status(build_dir),