ci: keep quality report handling in its own script
All checks were successful
Tests / Declarative: Post Actions passed: 155

This commit is contained in:
codex 2026-10-04 08:42:35 -05:00
parent ef9e79737c
commit 5fbc6d0d5c
2 changed files with 48 additions and 46 deletions

48
Jenkinsfile vendored
View File

@ -320,52 +320,8 @@ EOF
stage('Run quality gate') {
steps {
container('publisher') {
sh '''
set -eu
mkdir -p build
set +e
apt-get update
apt_rc=$?
if [ "${apt_rc}" -eq 0 ]; then
apt-get install -y --no-install-recommends golang-go nodejs npm
apt_rc=$?
fi
if [ "${apt_rc}" -eq 0 ]; then
python -m testing.pegasus_gate report
gate_rc=$?
else
gate_rc="${apt_rc}"
fi
set -e
if [ ! -f build/gate-summary.json ]; then
python3 - <<'PY'
import json
from pathlib import Path
Path("build/gate-summary.json").write_text(
json.dumps(
{
"ok": False,
"issues": [
{
"check": "gate_glue",
"path": "Jenkinsfile",
"detail": "quality gate dependencies or report command failed before summary generation",
}
],
"file_count": 0,
"backend_coverage": {},
"frontend_coverage": {},
},
indent=2,
sort_keys=True,
)
+ "\\n",
encoding="utf-8",
)
PY
fi
printf '%s\n' "${gate_rc}" > build/quality-report.rc
'''
sh 'sh scripts/report_quality_gate.sh'
}
}
}

46
scripts/report_quality_gate.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
# Generate a gate report, including an explicit failure if tooling cannot start.
set -eu
mkdir -p build
set +e
apt-get update
apt_rc=$?
if [ "${apt_rc}" -eq 0 ]; then
apt-get install -y --no-install-recommends golang-go nodejs npm
apt_rc=$?
fi
if [ "${apt_rc}" -eq 0 ]; then
python -m testing.pegasus_gate report
gate_rc=$?
else
gate_rc="${apt_rc}"
fi
set -e
if [ ! -f build/gate-summary.json ]; then
python3 - <<'PY'
import json
from pathlib import Path
Path("build/gate-summary.json").write_text(
json.dumps(
{
"ok": False,
"issues": [
{
"check": "gate_glue",
"path": "Jenkinsfile",
"detail": "quality gate dependencies or report command failed before summary generation",
}
],
"file_count": 0,
"backend_coverage": {},
"frontend_coverage": {},
},
indent=2,
sort_keys=True,
)
+ "\n",
encoding="utf-8",
)
PY
fi
printf '%s\n' "${gate_rc}" > build/quality-report.rc