Skip to content

Commit 7eefa11

Browse files
authored
fix(preprod): send date fields to update Github check-run times (#103088)
We weren't sending the `started_at` and `completed_at` fields to Github so the time always said 0s. Processing: <img width="214" height="60" alt="Screenshot 2025-11-10 at 2 54 32 PM" src="https://github.com/user-attachments/assets/9abb4d64-41e5-4556-aa90-d70dd0de5060" /> Completed: <img width="200" height="56" alt="Screenshot 2025-11-10 at 2 55 30 PM" src="https://github.com/user-attachments/assets/d6d8f018-fb53-4c09-95ee-f531b7ce2485" /> Resolves EME-586
1 parent 64d4509 commit 7eefa11

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

bin/preprod/trigger_size_status_check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ configure()
66

77
import logging
88
import sys
9+
from datetime import timedelta
910

1011
logger = logging.getLogger(__name__)
1112

@@ -501,6 +502,12 @@ def main() -> None:
501502
head_build_config.name if head_build_config else "None",
502503
)
503504

505+
# Simulate processing time by backdating the creation timestamp
506+
# This ensures completed_at != started_at in the status check
507+
preprod_artifact.date_added = preprod_artifact.date_added - timedelta(minutes=5)
508+
preprod_artifact.save(update_fields=["date_added"])
509+
logger.info(" ✓ Backdated artifact creation by 5 minutes (simulating processing time)")
510+
504511
# Create size metrics if requested
505512
if create_metrics:
506513
create_size_metrics(preprod_artifact, build_config, metrics_state)

src/sentry/preprod/vcs/status_checks/size/tasks.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import logging
44
from abc import ABC, abstractmethod
5+
from datetime import datetime
56
from typing import Any
67

78
from sentry.constants import ObjectStatus
@@ -42,14 +43,23 @@
4243
)
4344
def create_preprod_status_check_task(preprod_artifact_id: int) -> None:
4445
try:
45-
preprod_artifact = PreprodArtifact.objects.get(id=preprod_artifact_id)
46+
preprod_artifact: PreprodArtifact | None = PreprodArtifact.objects.get(
47+
id=preprod_artifact_id
48+
)
4649
except PreprodArtifact.DoesNotExist:
4750
logger.exception(
4851
"preprod.status_checks.create.artifact_not_found",
4952
extra={"artifact_id": preprod_artifact_id},
5053
)
5154
return
5255

56+
if not preprod_artifact or not isinstance(preprod_artifact, PreprodArtifact):
57+
logger.error(
58+
"preprod.status_checks.create.artifact_not_found",
59+
extra={"artifact_id": preprod_artifact_id},
60+
)
61+
return
62+
5363
logger.info(
5464
"preprod.status_checks.create.start",
5565
extra={"artifact_id": preprod_artifact.id},
@@ -115,6 +125,10 @@ def create_preprod_status_check_task(preprod_artifact_id: int) -> None:
115125

116126
target_url = get_preprod_artifact_url(preprod_artifact)
117127

128+
completed_at: datetime | None = None
129+
if GITHUB_STATUS_CHECK_STATUS_MAPPING[status] == GitHubCheckStatus.COMPLETED:
130+
completed_at = preprod_artifact.date_updated
131+
118132
check_id = provider.create_status_check(
119133
repo=commit_comparison.head_repo_name,
120134
sha=commit_comparison.head_sha,
@@ -125,6 +139,8 @@ def create_preprod_status_check_task(preprod_artifact_id: int) -> None:
125139
summary=summary,
126140
external_id=str(preprod_artifact.id),
127141
target_url=target_url,
142+
started_at=preprod_artifact.date_added,
143+
completed_at=completed_at,
128144
)
129145
if check_id is None:
130146
logger.error(
@@ -301,6 +317,8 @@ def create_status_check(
301317
text: str | None,
302318
summary: str,
303319
external_id: str,
320+
started_at: datetime,
321+
completed_at: datetime | None = None,
304322
target_url: str | None = None,
305323
) -> str | None:
306324
"""Create a status check using provider-specific format."""
@@ -318,6 +336,8 @@ def create_status_check(
318336
text: str | None,
319337
summary: str,
320338
external_id: str,
339+
started_at: datetime,
340+
completed_at: datetime | None = None,
321341
target_url: str | None = None,
322342
) -> str | None:
323343
with self._create_scm_interaction_event().capture() as lifecycle:
@@ -373,6 +393,12 @@ def create_status_check(
373393
if mapped_conclusion:
374394
check_data["conclusion"] = mapped_conclusion.value
375395

396+
if started_at:
397+
check_data["started_at"] = started_at.isoformat()
398+
399+
if completed_at:
400+
check_data["completed_at"] = completed_at.isoformat()
401+
376402
if target_url:
377403
if target_url.startswith("http"):
378404
check_data["details_url"] = target_url

0 commit comments

Comments
 (0)