ci: install dev deps and publish quality gate status
This commit is contained in:
parent
2eecc3d88d
commit
1dab607230
93
Jenkinsfile
vendored
93
Jenkinsfile
vendored
@ -83,6 +83,8 @@ spec:
|
|||||||
METRICS_PREFIX = 'ariadne_ci'
|
METRICS_PREFIX = 'ariadne_ci'
|
||||||
VM_IMPORT_URL = 'http://victoria-metrics-single-server.monitoring.svc.cluster.local:8428/api/v1/import/prometheus'
|
VM_IMPORT_URL = 'http://victoria-metrics-single-server.monitoring.svc.cluster.local:8428/api/v1/import/prometheus'
|
||||||
REPO_NAME = 'ariadne'
|
REPO_NAME = 'ariadne'
|
||||||
|
SUITE_NAME = 'ariadne'
|
||||||
|
PUSHGATEWAY_URL = 'http://platform-quality-gateway.monitoring.svc.cluster.local:9091'
|
||||||
}
|
}
|
||||||
options {
|
options {
|
||||||
disableConcurrentBuilds()
|
disableConcurrentBuilds()
|
||||||
@ -103,6 +105,7 @@ spec:
|
|||||||
sh(script: '''
|
sh(script: '''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
|
python -m pip install --no-cache-dir -r requirements-dev.txt
|
||||||
python -m ruff check ariadne --select C90,PLR
|
python -m ruff check ariadne --select C90,PLR
|
||||||
python -m slipcover \
|
python -m slipcover \
|
||||||
--json \
|
--json \
|
||||||
@ -193,6 +196,96 @@ python -c "import json; payload=json.load(open('build/coverage.json', encoding='
|
|||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
success {
|
||||||
|
container('tester') {
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
|
export QUALITY_STATUS=ok
|
||||||
|
python - <<'PY'
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
suite = os.environ.get("SUITE_NAME", "ariadne")
|
||||||
|
status = os.environ.get("QUALITY_STATUS", "failed")
|
||||||
|
gateway = os.environ.get("PUSHGATEWAY_URL", "http://platform-quality-gateway.monitoring.svc.cluster.local:9091").rstrip("/")
|
||||||
|
text = urllib.request.urlopen(f"{gateway}/metrics", timeout=10).read().decode("utf-8", errors="replace")
|
||||||
|
|
||||||
|
def counter(name: str) -> float:
|
||||||
|
pattern = re.compile(
|
||||||
|
rf'^platform_quality_gate_runs_total\\{{[^}}]*job="platform-quality-ci"[^}}]*suite="{re.escape(suite)}"[^}}]*status="{name}"[^}}]*\\}}\\s+([0-9]+(?:\\.[0-9]+)?)$',
|
||||||
|
re.M,
|
||||||
|
)
|
||||||
|
match = pattern.search(text)
|
||||||
|
return float(match.group(1)) if match else 0.0
|
||||||
|
|
||||||
|
ok = counter("ok")
|
||||||
|
failed = counter("failed")
|
||||||
|
if status == "ok":
|
||||||
|
ok += 1
|
||||||
|
else:
|
||||||
|
failed += 1
|
||||||
|
payload = (
|
||||||
|
"# TYPE platform_quality_gate_runs_total counter\\n"
|
||||||
|
f'platform_quality_gate_runs_total{{suite="{suite}",status="ok"}} {int(ok)}\\n'
|
||||||
|
f'platform_quality_gate_runs_total{{suite="{suite}",status="failed"}} {int(failed)}\\n'
|
||||||
|
)
|
||||||
|
req = urllib.request.Request(
|
||||||
|
f"{gateway}/metrics/job/platform-quality-ci/suite/{suite}",
|
||||||
|
data=payload.encode("utf-8"),
|
||||||
|
method="POST",
|
||||||
|
headers={"Content-Type": "text/plain"},
|
||||||
|
)
|
||||||
|
urllib.request.urlopen(req, timeout=10).read()
|
||||||
|
PY
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
container('tester') {
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
|
export QUALITY_STATUS=failed
|
||||||
|
python - <<'PY'
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
suite = os.environ.get("SUITE_NAME", "ariadne")
|
||||||
|
status = os.environ.get("QUALITY_STATUS", "failed")
|
||||||
|
gateway = os.environ.get("PUSHGATEWAY_URL", "http://platform-quality-gateway.monitoring.svc.cluster.local:9091").rstrip("/")
|
||||||
|
text = urllib.request.urlopen(f"{gateway}/metrics", timeout=10).read().decode("utf-8", errors="replace")
|
||||||
|
|
||||||
|
def counter(name: str) -> float:
|
||||||
|
pattern = re.compile(
|
||||||
|
rf'^platform_quality_gate_runs_total\\{{[^}}]*job="platform-quality-ci"[^}}]*suite="{re.escape(suite)}"[^}}]*status="{name}"[^}}]*\\}}\\s+([0-9]+(?:\\.[0-9]+)?)$',
|
||||||
|
re.M,
|
||||||
|
)
|
||||||
|
match = pattern.search(text)
|
||||||
|
return float(match.group(1)) if match else 0.0
|
||||||
|
|
||||||
|
ok = counter("ok")
|
||||||
|
failed = counter("failed")
|
||||||
|
if status == "ok":
|
||||||
|
ok += 1
|
||||||
|
else:
|
||||||
|
failed += 1
|
||||||
|
payload = (
|
||||||
|
"# TYPE platform_quality_gate_runs_total counter\\n"
|
||||||
|
f'platform_quality_gate_runs_total{{suite="{suite}",status="ok"}} {int(ok)}\\n'
|
||||||
|
f'platform_quality_gate_runs_total{{suite="{suite}",status="failed"}} {int(failed)}\\n'
|
||||||
|
)
|
||||||
|
req = urllib.request.Request(
|
||||||
|
f"{gateway}/metrics/job/platform-quality-ci/suite/{suite}",
|
||||||
|
data=payload.encode("utf-8"),
|
||||||
|
method="POST",
|
||||||
|
headers={"Content-Type": "text/plain"},
|
||||||
|
)
|
||||||
|
urllib.request.urlopen(req, timeout=10).read()
|
||||||
|
PY
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
if (fileExists('build/junit.xml')) {
|
if (fileExists('build/junit.xml')) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user