Skip to content

Commit 7113125

Browse files
authored
[ci] remove buildkite env vars from test env (ray-project#50227)
printing info in post-command directly, and removing commit related github links that are generated from test results. these changes are required for cacheable test results Signed-off-by: Lonnie Liu <[email protected]>
1 parent 27e5850 commit 7113125

File tree

3 files changed

+11
-41
lines changed

3 files changed

+11
-41
lines changed

.buildkite/hooks/post-command

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ if [ -d "/tmp/artifacts/test-summaries" ] && [ "$(ls -A /tmp/artifacts/test-summ
1616
# Only upload annotations if there are at least 2 files in the directory:
1717
# 1 header and 1 failed test.
1818
if [ "$(find /tmp/artifacts/test-summaries -maxdepth 1 -name '*.txt' | wc -l)" -ge 2 ]; then
19+
echo "Test summaries for ${BUILDKITE_JOB_ID} ${BUILDKITE_LABEL}" | buildkite-agent annotate --job "${BUILDKITE_JOB_ID}" --style error --context "${BUILDKITE_JOB_ID}"
1920
cat /tmp/artifacts/test-summaries/*.txt | head -n 20 | buildkite-agent annotate --job "${BUILDKITE_JOB_ID}" --append --style error --context "${BUILDKITE_JOB_ID}"
2021
fi
2122

ci/run/bazel_export_options

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ event_json_flag=--build_event_json_file=$(mktemp /tmp/bazel_event_logs/bazel_log
1010
logs_archive_flag=--test_env=RAY_TEST_FAILURE_LOGS_ARCHIVE_DIR="${artifact_mount_path}"/failed_test_logs
1111
summary_directory_flag=--test_env=RAY_TEST_SUMMARY_DIR="${artifact_mount_path}"/test-summaries
1212
summary_directory_host_flag=--test_env=RAY_TEST_SUMMARY_DIR_HOST=/tmp/artifacts/test-summaries
13-
buildkite_env_vars="--test_env=BUILDKITE_COMMIT --test_env=BUILDKITE_LABEL --test_env=BUILDKITE_JOB_ID"
1413
mujoco_env_var="--test_env=LD_LIBRARY_PATH=/root/.mujoco/mujoco210/bin"
1514

16-
echo "${event_json_flag} ${logs_archive_flag} ${summary_directory_flag} ${summary_directory_host_flag} ${buildkite_env_vars} ${mujoco_env_var}"
15+
echo "${event_json_flag} ${logs_archive_flag} ${summary_directory_flag} ${summary_directory_host_flag} ${mujoco_env_var}"

python/ray/tests/conftest.py

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from contextlib import contextmanager
1515
from pathlib import Path
1616
from tempfile import gettempdir
17-
from typing import List, Optional, Tuple
17+
from typing import List, Optional
1818
from unittest import mock
1919
import psutil
2020
import 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-
13161286
def create_ray_logs_for_failed_test(rep):
13171287
"""Creates artifact zip of /tmp/ray/session_latest/logs for failed tests"""
13181288

0 commit comments

Comments
 (0)