@@ -31,13 +31,9 @@ def verify_job(run_id, plan, repo):
|
||||
guard = [job for job in jobs if job.get('name') == 'guard' and job.get('conclusion') == 'success']
|
||||
cd.require(len(guard) == 1 and type(guard[0].get('id')) is int, 'candidate guard did not succeed')
|
||||
# Gitea logs are plaintext and may prefix each line with a timestamp.
|
||||
from urllib.request import ProxyHandler, build_opener
|
||||
from urllib.request import Request
|
||||
token = os.environ['KG_CANDIDATE_READ_TOKEN']
|
||||
request = Request(cd.FORGE + candidate.API + f'/actions/jobs/{guard[0]["id"]}/logs',
|
||||
headers={'Authorization': 'token ' + token})
|
||||
with build_opener(ProxyHandler({}), cd.NoRedirect()).open(request, timeout=15) as response:
|
||||
lines = response.read(2**20).decode().splitlines()
|
||||
raw = coordinator.hfx.forge('GET', candidate.API + f'/actions/jobs/{guard[0]["id"]}/logs', raw=True)
|
||||
cd.require(len(raw) <= 2**20, 'candidate guard log exceeded the read limit')
|
||||
lines = raw.decode().splitlines()
|
||||
cd.require(sum(line.strip().endswith(candidate.proof(plan, 'prepare')) for line in lines) == 1,
|
||||
'candidate input does not match Gitea guard proof')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user