|
22 | 22 | if args[:2] == ["run", "list"]: |
23 | 23 | runs = json.loads(os.environ["FAKE_RUNS"]) |
24 | 24 | try: |
25 | | - status = args[args.index("--status") + 1] |
26 | 25 | limit = int(args[args.index("--limit") + 1]) |
27 | 26 | except (ValueError, IndexError): |
28 | | - print("run list requires --status and --limit", file=sys.stderr) |
| 27 | + print("run list requires --limit", file=sys.stderr) |
29 | 28 | raise SystemExit(2) |
30 | | - if status == "success": |
31 | | - runs = [run for run in runs if run["conclusion"] == "success"] |
32 | | - elif status == "completed": |
33 | | - runs = [run for run in runs if run["status"] == "completed"] |
34 | | - else: |
35 | | - print(f"unsupported status filter: {status}", file=sys.stderr) |
| 29 | + if "--status" in args: |
| 30 | + print("status filters are intentionally unsupported", file=sys.stderr) |
36 | 31 | raise SystemExit(2) |
| 32 | + if "--jq" in args: |
| 33 | + try: |
| 34 | + jq_filter = args[args.index("--jq") + 1] |
| 35 | + except IndexError: |
| 36 | + print("run list --jq requires a value", file=sys.stderr) |
| 37 | + raise SystemExit(2) |
| 38 | + if jq_filter == 'map(select(.status == "completed"))': |
| 39 | + runs = [run for run in runs if run["status"] == "completed"] |
| 40 | + else: |
| 41 | + print(f"unsupported jq filter: {jq_filter}", file=sys.stderr) |
| 42 | + raise SystemExit(2) |
37 | 43 | print(json.dumps(runs[:limit])) |
38 | 44 | raise SystemExit(0) |
39 | 45 |
|
| 46 | +if args[:2] == ["run", "view"]: |
| 47 | + print(json.dumps({"url": "https://example.invalid/runs/view"})) |
| 48 | + raise SystemExit(0) |
| 49 | +
|
40 | 50 | if args[:1] == ["api"]: |
41 | 51 | if "--paginate" not in args or "--jq" not in args: |
42 | 52 | print("artifact lookup must be paginated and filtered", file=sys.stderr) |
|
60 | 70 | """ |
61 | 71 |
|
62 | 72 |
|
63 | | -def _run(run_id, created_at, *, branch="12.9.x", workflow="CI", conclusion="success"): |
| 73 | +def _run( |
| 74 | + run_id, |
| 75 | + created_at, |
| 76 | + *, |
| 77 | + branch="12.9.x", |
| 78 | + workflow="CI", |
| 79 | + conclusion="success", |
| 80 | + event="push", |
| 81 | + status="completed", |
| 82 | +): |
64 | 83 | return { |
65 | 84 | "databaseId": run_id, |
66 | 85 | "workflowName": workflow, |
67 | | - "status": "completed", |
| 86 | + "status": status, |
68 | 87 | "conclusion": conclusion, |
69 | 88 | "headSha": f"sha-{run_id}", |
70 | 89 | "headBranch": branch, |
| 90 | + "event": event, |
71 | 91 | "createdAt": created_at, |
72 | 92 | "url": f"https://example.invalid/runs/{run_id}", |
73 | 93 | } |
@@ -104,14 +124,14 @@ def _lookup(fake_gh, runs, artifacts, *args, workflow="CI"): |
104 | 124 |
|
105 | 125 | @pytest.mark.agent_authored(model="gpt-5.6") |
106 | 126 | class TestBranchLookup: |
107 | | - def test_filters_successful_runs_before_applying_limit(self, fake_gh): |
| 127 | + def test_filters_successful_runs_without_status_filter(self, fake_gh): |
108 | 128 | runs = [ |
109 | 129 | _run( |
110 | 130 | run_id, |
111 | 131 | "2026-08-13T12:00:00Z", |
112 | 132 | conclusion="failure", |
113 | 133 | ) |
114 | | - for run_id in range(200, 100, -1) |
| 134 | + for run_id in range(200, 190, -1) |
115 | 135 | ] |
116 | 136 | runs.append(_run(50, "2026-08-12T12:00:00Z")) |
117 | 137 |
|
@@ -237,3 +257,18 @@ def test_propagates_artifact_api_failures(self, fake_gh): |
237 | 257 |
|
238 | 258 | assert result.returncode == 1 |
239 | 259 | assert "Failed to list artifacts for run 100" in result.stderr |
| 260 | + |
| 261 | + |
| 262 | +@pytest.mark.agent_authored(model="gpt-5.6") |
| 263 | +class TestTagLookup: |
| 264 | + def test_filters_completed_runs_without_status_filter(self, fake_gh): |
| 265 | + runs = [ |
| 266 | + _run(300, "2026-08-13T12:00:00Z", branch="HEAD", status="in_progress"), |
| 267 | + _run(200, "2026-08-12T12:00:00Z", branch="HEAD"), |
| 268 | + _run(100, "2026-08-11T12:00:00Z", branch="HEAD"), |
| 269 | + ] |
| 270 | + |
| 271 | + result = _lookup(fake_gh, runs, {}, "HEAD") |
| 272 | + |
| 273 | + assert result.returncode == 0, result.stderr |
| 274 | + assert result.stdout.strip() == "200" |
0 commit comments