Bind CMS qualification to its private registered runner identity

This commit is contained in:
DCCONSTRUCTIONS
2026-11-04 22:27:59 +03:00
parent e629cf10bc
commit e09f249f4c
7 changed files with 178 additions and 9 deletions
+6 -2
View File
@@ -72,9 +72,11 @@ class NoRedirect(urllib.request.HTTPRedirectHandler):
class GiteaSource:
def __init__(self, token):
def __init__(self, token, *, runner_id=None):
require(isinstance(token, str) and re.fullmatch(r"[0-9a-f]{40}", token), "invalid_read_token")
require(runner_id is None or positive(runner_id), "invalid_registered_runner_id")
self._token = token
self._runner_id = runner_id
self._opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), NoRedirect())
def request(self, suffix, *, archive=False):
@@ -164,6 +166,7 @@ class GiteaSource:
return check
def successful_run(self, row):
require(positive(self._runner_id), "registered_runner_identity_required")
run = self.run(row["id"])
require((run["run_number"], run["head_sha"], run["run_attempt"]) ==
(row["number"], row["sha"], row["attempt"]), "qualified_run_changed")
@@ -175,7 +178,8 @@ class GiteaSource:
require(job.get("run_id") == run["id"] and job.get("head_sha") == run["head_sha"]
and job.get("head_branch") == "master" and job.get("run_attempt") == run["run_attempt"]
and job.get("name") == "qualify" and job.get("labels") == ["nodedc-node22-build"]
and job.get("runner_id") == 1 and job.get("status") == "completed"
and type(job.get("runner_id")) is int and job["runner_id"] == self._runner_id
and job.get("runner_name") == "synology-cms-build" and job.get("status") == "completed"
and job.get("conclusion") == "success", "qualification_job_mismatch")
steps = job.get("steps")
require(isinstance(steps, list) and all(isinstance(s, dict) for s in steps) and [s.get("name") for s in steps] ==