mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 22:06:31 +00:00
fix(ci): read every page of the job listing before reporting failed roles
report_failures asked `gh api --paginate` for the run's jobs with the jq
filter `[.jobs[] | {name, conclusion}]`. gh applies that filter to each page
and prints one array per page, so a run with more jobs than one page holds
produced two JSON documents, and json.loads stopped with "Extra data: line 2
column 1". Main run 38218402254 (113 jobs) failed its "Report main role
failures" job that way, and no issue was opened for its failed roles.
The listing now emits one job object per line and parses the lines one by
one, the same way logs/download/github.py lists jobs.
Verified: the old parse of the real output of run 38218402254 raises the
same "Extra data: line 2 column 1 (char 8491)" as CI; list_jobs on that run
returns all 113 jobs, 16 of them failed, grouped into 12 failed roles.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
fe0f6c16d9
commit
f7987679dd
2 files changed
+29
-12
No files matched your search
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from cli.meta.ci.report_failures import (
|
||||
Failure,
|
||||
@@ -10,6 +11,7 @@ from cli.meta.ci.report_failures import (
|
||||
decisive_excerpt,
|
||||
failed_roles,
|
||||
issue_body,
|
||||
list_jobs,
|
||||
)
|
||||
|
||||
|
||||
@@ -80,6 +82,19 @@ class TestReportFailures(unittest.TestCase):
|
||||
artifact_name("web-app-x", Failure("compose", "0", True, "fedora", "zfs")),
|
||||
)
|
||||
|
||||
def test_list_jobs_reads_one_job_per_line_across_pages(self) -> None:
|
||||
pages = (
|
||||
'{"name": "deploy a", "conclusion": "success"}\n'
|
||||
'{"name": "deploy b", "conclusion": "failure"}\n'
|
||||
)
|
||||
with patch("cli.meta.ci.report_failures._gh", return_value=pages):
|
||||
jobs = list_jobs("1", "owner/repo")
|
||||
self.assertEqual([job["name"] for job in jobs], ["deploy a", "deploy b"])
|
||||
|
||||
def test_list_jobs_of_an_empty_listing_is_empty(self) -> None:
|
||||
with patch("cli.meta.ci.report_failures._gh", return_value=""):
|
||||
self.assertEqual(list_jobs("1", "owner/repo"), [])
|
||||
|
||||
def test_issue_body_lists_failures_and_run(self) -> None:
|
||||
body = issue_body(
|
||||
"web-app-xwiki",
|
||||
|
||||
Reference in new issue
Block a user