fix(web): Executions sorts by actual global recency, not per-repo run number
number is a per-repo/workflow counter with no meaning once the admin endpoint mixes every repo on the instance into one feed -- a rarely-run workflow's low #53 that just fired outranked a busier workflow's #142 from hours earlier, but sorting by number buried it instead. Sort by started (globally comparable) with run_id/attempt as tiebreaks; a re-run bumping started_at back to the top is correct, not a bug, under "most recent globally".
This commit is contained in:
@@ -432,50 +432,43 @@ def test_queued_run_sorts_above_started_runs(
|
||||
assert [r.status for r in view.runs] == ["queued", "success"]
|
||||
|
||||
|
||||
def test_a_rerun_does_not_jump_above_a_newer_run(
|
||||
def test_a_rerun_sorts_above_a_run_that_started_earlier(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""Re-running an old workflow bumps its ``started_at`` to now, but its
|
||||
run id/number never change -- sorting by wall-clock time would put that
|
||||
stale run above a genuinely newer one it should still trail. The Run
|
||||
column must read strictly by run, descending, not by whichever attempt
|
||||
was most recently kicked off."""
|
||||
"""Re-running an old workflow really is fresh activity -- it belongs at
|
||||
the top of a "most recent globally" feed, same as any other run that just
|
||||
started."""
|
||||
payload = [
|
||||
_run(run_id=12, number=12, attempt=1, started="2026-07-25T10:00:00Z"),
|
||||
_run(run_id=13, number=13, attempt=1, started="2026-07-25T10:05:00Z"),
|
||||
# #12 gets manually re-run after #13 already started -- its
|
||||
# started_at is now the latest timestamp of the three.
|
||||
# #12 gets manually re-run after #13 already started.
|
||||
_run(run_id=12, number=12, attempt=2, started="2026-07-25T10:10:00Z"),
|
||||
]
|
||||
_install_urlopen(monkeypatch, _admin_ok(payload))
|
||||
|
||||
view = list_executions(_make_config(tmp_path), [], token="tok", now=_NOW)
|
||||
|
||||
assert [(r.number, r.attempt) for r in view.runs] == [(13, 1), (12, 2), (12, 1)]
|
||||
assert [(r.number, r.attempt) for r in view.runs] == [(12, 2), (13, 1), (12, 1)]
|
||||
|
||||
|
||||
def test_a_lower_numbered_run_from_a_busier_workflow_does_not_land_in_between(
|
||||
def test_a_more_recent_run_from_a_quiet_workflow_sorts_above_an_older_higher_numbered_run(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""``run_id`` is instance-wide (every repo/workflow the admin endpoint
|
||||
pulls from shares one sequence), not a per-workflow counter -- a rarely
|
||||
triggered workflow's #53 can easily get a run id that falls between two
|
||||
ids from a busier workflow's #141/#142, even though 53 is nowhere near
|
||||
141 or 142. The Run column has to read by the number it shows, not by
|
||||
that shared id."""
|
||||
"""``number`` is a per-repo/workflow counter -- it cannot answer "most
|
||||
recent across the whole instance" at all once more than one repo is in
|
||||
the mix. A rarely-triggered workflow's #53 that just ran outranks a
|
||||
#141/#142 from a busier workflow that ran hours earlier."""
|
||||
payload = [
|
||||
_run(run_id=9001, number=142, started="2026-07-25T12:00:00Z"),
|
||||
# A different, rarely-run workflow's id landed between the two above
|
||||
# purely because of when it happened to fire -- not because #53 is
|
||||
# newer than #141.
|
||||
_run(run_id=9000, number=53, path=".gitea/workflows/rare.yml", started="2026-07-25T09:00:00Z"),
|
||||
_run(run_id=8000, number=141, started="2026-07-25T11:00:00Z"),
|
||||
_run(run_id=8000, number=141, started="2026-07-25T09:00:00Z"),
|
||||
_run(run_id=9001, number=142, started="2026-07-25T10:00:00Z"),
|
||||
# A different, rarely-run workflow -- but it just fired, after both.
|
||||
_run(run_id=1, number=53, path=".gitea/workflows/rare.yml", started="2026-07-25T11:00:00Z"),
|
||||
]
|
||||
_install_urlopen(monkeypatch, _admin_ok(payload))
|
||||
|
||||
view = list_executions(_make_config(tmp_path), [], token="tok", now=_NOW)
|
||||
|
||||
assert [r.number for r in view.runs] == [142, 141, 53]
|
||||
assert [r.number for r in view.runs] == [53, 142, 141]
|
||||
|
||||
|
||||
def test_same_number_and_attempt_falls_back_to_run_id(
|
||||
|
||||
Reference in New Issue
Block a user