99import typing as t
1010from textwrap import dedent
1111
12+ import yaml
1213from artifacts_handler import ArtifactType
1314from gitlab import GitlabUpdateError
1415from gitlab_api import Gitlab
@@ -321,6 +322,7 @@ def __init__(
321322 self .failed_apps_report_file = 'failed_apps.html'
322323 self .built_apps_report_file = 'built_apps.html'
323324 self .skipped_apps_report_file = 'skipped_apps.html'
325+ self .app_presigned_urls_dict : t .Dict [str , t .Dict [str , str ]] = {}
324326
325327 @staticmethod
326328 def custom_sort (item : AppWithMetricsInfo ) -> t .Tuple [int , t .Any ]:
@@ -408,6 +410,11 @@ def get_built_apps_report_parts(self) -> t.List[str]:
408410 sections = []
409411
410412 if new_test_related_apps :
413+ for app in new_test_related_apps :
414+ for artifact_type in [ArtifactType .BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES , ArtifactType .MAP_AND_ELF_FILES ]:
415+ url = self ._uploader .get_app_presigned_url (app , artifact_type )
416+ self .app_presigned_urls_dict .setdefault (app .build_path , {})[artifact_type .value ] = url
417+
411418 new_test_related_apps_table_section = self .create_table_section (
412419 title = self .report_titles_map ['new_test_related_apps' ],
413420 items = new_test_related_apps ,
@@ -430,20 +437,25 @@ def get_built_apps_report_parts(self) -> t.List[str]:
430437 (
431438 'Bin Files with Build Log (without map and elf)' ,
432439 lambda app : self .get_download_link_for_url (
433- self ._uploader . get_app_presigned_url ( app , ArtifactType .BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES )
440+ self .app_presigned_urls_dict [ app . build_path ][ ArtifactType .BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES . value ]
434441 ),
435442 ),
436443 (
437444 'Map and Elf Files' ,
438445 lambda app : self .get_download_link_for_url (
439- self ._uploader . get_app_presigned_url ( app , ArtifactType .MAP_AND_ELF_FILES )
446+ self .app_presigned_urls_dict [ app . build_path ][ ArtifactType .MAP_AND_ELF_FILES . value ]
440447 ),
441448 ),
442449 ],
443450 )
444451 sections .extend (new_test_related_apps_table_section )
445452
446453 if built_test_related_apps :
454+ for app in built_test_related_apps :
455+ for artifact_type in [ArtifactType .BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES , ArtifactType .MAP_AND_ELF_FILES ]:
456+ url = self ._uploader .get_app_presigned_url (app , artifact_type )
457+ self .app_presigned_urls_dict .setdefault (app .build_path , {})[artifact_type .value ] = url
458+
447459 built_test_related_apps = self ._sort_items (
448460 built_test_related_apps ,
449461 key = 'metrics.binary_size.difference_percentage' ,
@@ -488,13 +500,13 @@ def get_built_apps_report_parts(self) -> t.List[str]:
488500 (
489501 'Bin Files with Build Log (without map and elf)' ,
490502 lambda app : self .get_download_link_for_url (
491- self ._uploader . get_app_presigned_url ( app , ArtifactType .BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES )
503+ self .app_presigned_urls_dict [ app . build_path ][ ArtifactType .BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES . value ]
492504 ),
493505 ),
494506 (
495507 'Map and Elf Files' ,
496508 lambda app : self .get_download_link_for_url (
497- self ._uploader . get_app_presigned_url ( app , ArtifactType .MAP_AND_ELF_FILES )
509+ self .app_presigned_urls_dict [ app . build_path ][ ArtifactType .MAP_AND_ELF_FILES . value ]
498510 ),
499511 ),
500512 ],
@@ -601,6 +613,11 @@ def get_built_apps_report_parts(self) -> t.List[str]:
601613
602614 self .additional_info += self ._generate_top_n_apps_by_size_table ()
603615
616+ # also generate a yaml file that includes the apps and the presigned urls
617+ # for helping debugging locally
618+ with open (self .apps_presigned_url_filepath , 'w' ) as fw :
619+ yaml .dump (self .app_presigned_urls_dict , fw )
620+
604621 return sections
605622
606623 def get_failed_apps_report_parts (self ) -> t .List [str ]:
0 commit comments