@@ -467,6 +467,62 @@ def mark_test_failed(db, test, repository, message: str) -> None:
467467 f"test is in inconsistent state!" )
468468
469469
470+ def _diagnose_missing_artifact (repository , commit_sha : str , platform , log ) -> str :
471+ """
472+ Diagnose why an artifact was not found for a commit.
473+
474+ Checks the workflow run status to provide a more helpful error message.
475+
476+ :param repository: GitHub repository object
477+ :param commit_sha: The commit SHA to check
478+ :param platform: The platform (TestPlatform.linux or TestPlatform.windows)
479+ :param log: Logger instance
480+ :return: A descriptive error message
481+ """
482+ from collections import defaultdict
483+
484+ if platform == TestPlatform .linux :
485+ expected_workflow = Workflow_builds .LINUX
486+ else :
487+ expected_workflow = Workflow_builds .WINDOWS
488+
489+ try :
490+ # Build workflow name lookup
491+ workflow = defaultdict (lambda : None )
492+ for active_workflow in repository .get_workflows ():
493+ workflow [active_workflow .id ] = active_workflow .name
494+
495+ # Check workflow runs for this commit
496+ workflow_found = False
497+ for workflow_run in repository .get_workflow_runs (head_sha = commit_sha ):
498+ workflow_run_name = workflow [workflow_run .workflow_id ]
499+ if workflow_run_name != expected_workflow :
500+ continue
501+
502+ workflow_found = True
503+ if workflow_run .status != "completed" :
504+ return (f"Build still in progress: '{ expected_workflow } ' is { workflow_run .status } . "
505+ f"Please wait for the build to complete and retry." )
506+ elif workflow_run .conclusion != "success" :
507+ return (f"Build failed: '{ expected_workflow } ' finished with conclusion '{ workflow_run .conclusion } '. "
508+ f"Check the GitHub Actions logs for details." )
509+ else :
510+ # Build succeeded but artifact not found - may have expired
511+ return (f"Artifact not found: '{ expected_workflow } ' completed successfully, "
512+ f"but no artifact was found. The artifact may have expired (GitHub deletes "
513+ f"artifacts after a retention period) or was not uploaded properly." )
514+
515+ if not workflow_found :
516+ return (f"No workflow run found: '{ expected_workflow } ' has not run for commit { commit_sha [:7 ]} . "
517+ f"This may indicate the workflow was not triggered or is queued." )
518+
519+ except Exception as e :
520+ log .warning (f"Failed to diagnose missing artifact: { e } " )
521+ return f"No build artifact found for this commit (diagnostic check failed: { e } )"
522+
523+ return "No build artifact found for this commit"
524+
525+
470526def start_test (compute , app , db , repository : Repository .Repository , test , bot_token ) -> None :
471527 """
472528 Start a VM instance and run the tests.
@@ -603,10 +659,10 @@ def start_test(compute, app, db, repository: Repository.Repository, test, bot_to
603659 artifact = find_artifact_for_commit (repository , test .commit , test .platform , log )
604660
605661 if artifact is None :
606- log . critical ( f"Test { test . id } : Could not find artifact for commit { test . commit [: 8 ] } " )
607- mark_test_failed ( db , test , repository ,
608- f"No build artifact found for commit { test .commit [:8 ]} . "
609- "The artifact may have expired or the build may have failed." )
662+ # Use diagnostic function to provide detailed error message
663+ error_detail = _diagnose_missing_artifact ( repository , test . commit , test . platform , log )
664+ log . critical ( f"Test { test . id } : Could not find artifact for commit { test .commit [:8 ]} : { error_detail } " )
665+ mark_test_failed ( db , test , repository , error_detail )
610666 return
611667
612668 log .info (f"Test { test .id } : Found artifact '{ artifact .name } ' (ID: { artifact .id } )" )
0 commit comments