From 2f2b98445e1fd2319fe2456de170fcdf27f9af8f Mon Sep 17 00:00:00 2001 From: core-be Date: Wed, 10 Jun 2026 18:42:21 +0000 Subject: [PATCH] fix(ci): use fresh relative ts in conductor-snapshot tests (#2550) The 4 conductor-snapshot tests hardcoded ts="2026-06-10T12:00:00Z". load_conductor_snapshot() only honors a snapshot within a 10-minute freshness window, so once wall-clock passed 12:10Z the frozen snapshot was dropped as stale -> self-fetch with empty OWNER/NAME -> /repos/// crash. This turned the required context "Ops Scripts Tests / Ops scripts (unittest)" permanently RED on every core PR (continue-on-error masks the workflow green but the commit-status context still posts failure). Fix: default _make_snapshot / the inline snapshot dicts to a now()-based ts (_fresh_ts), matching the already-correct relative-ts approach in test_load_conductor_snapshot_ignores_stale_snapshot. Tests wanting a STALE snapshot still pass ts= explicitly. Test-only; no production script change. Fixes #2550. Co-Authored-By: Claude Fable 5 --- .gitea/scripts/tests/test_gitea_merge_queue.py | 16 ++++++++++++++-- .gitea/scripts/tests/test_status_reaper_api.py | 12 ++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitea/scripts/tests/test_gitea_merge_queue.py b/.gitea/scripts/tests/test_gitea_merge_queue.py index 6e5517d35..3a0ba2d9f 100644 --- a/.gitea/scripts/tests/test_gitea_merge_queue.py +++ b/.gitea/scripts/tests/test_gitea_merge_queue.py @@ -1789,8 +1789,20 @@ import os import tempfile -def _make_snapshot(prs, ts="2026-06-10T12:00:00Z"): - return {"ts": ts, "repo": "molecule-ai/molecule-core", "prs": prs} +def _fresh_ts(): + # Conductor snapshots are only honored within a 10-minute freshness window + # (load_conductor_snapshot in gitea-merge-queue.py). A frozen literal ts + # goes stale the moment wall-clock passes that window, silently dropping the + # snapshot and self-fetching -> empty OWNER/NAME -> "/repos///" crash. Default + # to NOW so the snapshot is fresh whenever the suite runs. Tests that want a + # STALE snapshot pass ts= explicitly (test_load_conductor_snapshot_ignores_stale_snapshot). + from datetime import datetime, timezone + return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + + +def _make_snapshot(prs, ts=None): + return {"ts": ts if ts is not None else _fresh_ts(), + "repo": "molecule-ai/molecule-core", "prs": prs} def test_list_candidate_issues_uses_snapshot_when_present(monkeypatch): diff --git a/.gitea/scripts/tests/test_status_reaper_api.py b/.gitea/scripts/tests/test_status_reaper_api.py index df9c64dbb..e2d02aeb4 100644 --- a/.gitea/scripts/tests/test_status_reaper_api.py +++ b/.gitea/scripts/tests/test_status_reaper_api.py @@ -175,6 +175,14 @@ def test_reap_preserves_failed_pr_context_without_push_success(monkeypatch): import os import tempfile +from datetime import datetime, timezone + + +def _fresh_ts(): + # See test_gitea_merge_queue._fresh_ts: snapshots are only honored within a + # 10-minute freshness window; a frozen literal ts goes stale and triggers a + # self-fetch -> "/repos///" crash. Default to NOW. + return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") def test_get_combined_status_uses_snapshot_when_sha_matches(monkeypatch): @@ -183,7 +191,7 @@ def test_get_combined_status_uses_snapshot_when_sha_matches(monkeypatch): mod = load_reaper() head_sha = "a" * 40 snapshot = { - "ts": "2026-06-10T12:00:00Z", + "ts": _fresh_ts(), "repo": "molecule-ai/molecule-core", "prs": [ { @@ -217,7 +225,7 @@ def test_get_combined_status_self_fetches_when_sha_not_in_snapshot(monkeypatch): """If the SHA is not in the snapshot, get_combined_status falls back to API.""" mod = load_reaper() snapshot = { - "ts": "2026-06-10T12:00:00Z", + "ts": _fresh_ts(), "repo": "molecule-ai/molecule-core", "prs": [ {"number": 1, "head_sha": "b" * 40, "labels": [], -- 2.52.0