1414from contextlib import contextmanager
1515from pathlib import Path
1616from tempfile import gettempdir
17- from typing import List , Optional , Tuple
17+ from typing import List , Optional
1818from unittest import mock
1919import psutil
2020import pytest
@@ -1198,7 +1198,6 @@ def append_short_test_summary(rep):
11981198 # ":" is not legal in filenames in windows
11991199 test_name = test_name .replace (":" , "$" )
12001200
1201- header_file = os .path .join (summary_dir , "000_header.txt" )
12021201 summary_file = os .path .join (summary_dir , test_name + ".txt" )
12031202
12041203 if rep .passed and os .path .exists (summary_file ):
@@ -1219,13 +1218,6 @@ def append_short_test_summary(rep):
12191218 if not hasattr (rep .longrepr , "chain" ):
12201219 return
12211220
1222- if not os .path .exists (header_file ):
1223- with open (header_file , "wt" ) as fp :
1224- test_label = os .environ .get ("BUILDKITE_LABEL" , "Unknown" )
1225- job_id = os .environ .get ("BUILDKITE_JOB_ID" )
1226-
1227- fp .write (f"### Pytest failures for: [{ test_label } ](#{ job_id } )\n \n " )
1228-
12291221 # Use `wt` here to overwrite so we only have one result per test (exclude retries)
12301222 with open (summary_file , "wt" ) as fp :
12311223 fp .write (_get_markdown_annotation (rep ))
@@ -1244,40 +1236,31 @@ def _get_markdown_annotation(rep) -> str:
12441236 markdown += "<details>\n "
12451237 markdown += f"<summary>{ short_message } </summary>\n \n "
12461238
1247- # Add link to test definition
1239+ # Add location to the test definition
12481240 test_file , test_lineno , _test_node = rep .location
1249- test_path , test_url = _get_repo_github_path_and_link (
1250- os .path .abspath (test_file ), test_lineno
1251- )
1252- markdown += f"Link to test: [{ test_path } :{ test_lineno } ]({ test_url } )\n \n "
1241+ test_path = os .path .abspath (test_file )
1242+ markdown += f"Test location: { test_path } :{ test_lineno } \n \n "
12531243
12541244 # Print main traceback
12551245 markdown += "##### Traceback\n \n "
12561246 markdown += "```\n "
12571247 markdown += str (main_tb )
12581248 markdown += "\n ```\n \n "
12591249
1260- # Print link to test definition in github
1261- path , url = _get_repo_github_path_and_link (main_loc .path , main_loc .lineno )
1262- markdown += f"[{ path } :{ main_loc .lineno } ]({ url } )\n \n "
1250+ # Print test definition location
1251+ markdown += f"{ main_loc .path } :{ main_loc .lineno } \n \n "
12631252
12641253 # If this is a longer exception chain, users can expand the full traceback
12651254 if len (rep .longrepr .chain ) > 1 :
12661255 markdown += "<details><summary>Full traceback</summary>\n \n "
12671256
1268- # Here we just print each traceback and the link to the respective
1269- # lines in GutHub
1257+ # Here we just print each traceback and the respective lines.
12701258 for tb , loc , _ in rep .longrepr .chain :
1271- if loc :
1272- path , url = _get_repo_github_path_and_link (loc .path , loc .lineno )
1273- github_link = f"[{ path } :{ loc .lineno } ]({ url } )\n \n "
1274- else :
1275- github_link = ""
1276-
12771259 markdown += "```\n "
12781260 markdown += str (tb )
12791261 markdown += "\n ```\n \n "
1280- markdown += github_link
1262+ if loc :
1263+ markdown += f"{ loc .path } :{ loc .lineno } \n \n "
12811264
12821265 markdown += "</details>\n "
12831266
@@ -1300,19 +1283,6 @@ def _get_pip_packages() -> List[str]:
13001283 return ["invalid" ]
13011284
13021285
1303- def _get_repo_github_path_and_link (file : str , lineno : int ) -> Tuple [str , str ]:
1304- base_url = "https://github.com/ray-project/ray/blob/{commit}/{path}#L{lineno}"
1305-
1306- commit = os .environ .get ("BUILDKITE_COMMIT" )
1307-
1308- if not commit :
1309- return file , ""
1310-
1311- path = file .split ("com_github_ray_project_ray/" )[- 1 ]
1312-
1313- return path , base_url .format (commit = commit , path = path , lineno = lineno )
1314-
1315-
13161286def create_ray_logs_for_failed_test (rep ):
13171287 """Creates artifact zip of /tmp/ray/session_latest/logs for failed tests"""
13181288
0 commit comments