Skip to content

Commit

Permalink
Remove writing to GitHub Actions Summary
Browse files Browse the repository at this point in the history
To have feature parity with the existing Test Analytics, we don't
actually want to publish to the GitHub Actions Summary.
  • Loading branch information
michelletran-codecov committed Oct 4, 2024
1 parent 6ea5f75 commit 418a59e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
14 changes: 0 additions & 14 deletions codecov_cli/commands/process_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,9 @@ def maybe_write_to_github_action(
# If no token is passed, then we will assume users are not running in a GitHub Action
return

maybe_write_to_github_summary(message)
maybe_write_to_github_comment(message, github_token, args)


def maybe_write_to_github_summary(message: str) -> None:
summary_file_path = os.getenv("GITHUB_STEP_SUMMARY")
if summary_file_path is None:
raise click.ClickException(
"Error getting step summary file path from environment. "
"Can't find GITHUB_STEP_SUMMARY environment variable."
)

# write to step summary file
with open(summary_file_path, "w") as f:
f.write(message)


def maybe_write_to_github_comment(
message: str, github_token: str, args: Dict[str, str]
) -> None:
Expand Down
48 changes: 0 additions & 48 deletions tests/commands/test_process_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def test_process_test_results(
{
"GITHUB_REPOSITORY": "fake/repo",
"GITHUB_REF": "pull/fake/pull",
"GITHUB_STEP_SUMMARY": tmp_file.dirname + tmp_file.basename,
},
)
mocked_post = mocker.patch(
Expand Down Expand Up @@ -57,7 +56,6 @@ def test_process_test_results_create_github_message(
{
"GITHUB_REPOSITORY": "fake/repo",
"GITHUB_REF": "pull/fake/123",
"GITHUB_STEP_SUMMARY": tmp_file.dirname + tmp_file.basename,
},
)

Expand Down Expand Up @@ -105,7 +103,6 @@ def test_process_test_results_update_github_message(
{
"GITHUB_REPOSITORY": "fake/repo",
"GITHUB_REF": "pull/fake/123",
"GITHUB_STEP_SUMMARY": tmp_file.dirname + tmp_file.basename,
},
)

Expand Down Expand Up @@ -177,7 +174,6 @@ def test_process_test_results_errors_getting_comments(
{
"GITHUB_REPOSITORY": "fake/repo",
"GITHUB_REF": "pull/fake/123",
"GITHUB_STEP_SUMMARY": tmp_file.dirname + tmp_file.basename,
},
)

Expand Down Expand Up @@ -222,7 +218,6 @@ def test_process_test_results_non_existent_file(mocker, tmpdir):
{
"GITHUB_REPOSITORY": "fake/repo",
"GITHUB_REF": "pull/fake/pull",
"GITHUB_STEP_SUMMARY": tmp_file.dirname + tmp_file.basename,
},
)
mocked_post = mocker.patch(
Expand Down Expand Up @@ -259,7 +254,6 @@ def test_process_test_results_missing_repo(mocker, tmpdir):
os.environ,
{
"GITHUB_REF": "pull/fake/pull",
"GITHUB_STEP_SUMMARY": tmp_file.dirname + tmp_file.basename,
},
)
if "GITHUB_REPOSITORY" in os.environ:
Expand Down Expand Up @@ -300,7 +294,6 @@ def test_process_test_results_missing_ref(mocker, tmpdir):
os.environ,
{
"GITHUB_REPOSITORY": "fake/repo",
"GITHUB_STEP_SUMMARY": tmp_file.dirname + tmp_file.basename,
},
)

Expand Down Expand Up @@ -333,44 +326,3 @@ def test_process_test_results_missing_ref(mocker, tmpdir):
]
for log in expected_logs:
assert log in result.output


def test_process_test_results_missing_step_summary(mocker, tmpdir):
tmp_file = tmpdir.mkdir("folder").join("summary.txt")

mocker.patch.dict(
os.environ,
{
"GITHUB_REPOSITORY": "fake/repo",
"GITHUB_REF": "pull/fake/pull",
},
)
if "GITHUB_STEP_SUMMARY" in os.environ:
del os.environ["GITHUB_STEP_SUMMARY"]
mocked_post = mocker.patch(
"codecov_cli.commands.process_test_results.send_post_request",
return_value=RequestResult(
status_code=200, error=None, warnings=[], text="yay it worked"
),
)
runner = CliRunner()
result = runner.invoke(
cli,
[
"process-test-results",
"--github-token",
"whatever",
"--file",
"samples/junit.xml",
"--disable-search",
],
obj={},
)

assert result.exit_code == 1
expected_logs = [
"ci service found",
"Error: Error getting step summary file path from environment. Can't find GITHUB_STEP_SUMMARY environment variable.",
]
for log in expected_logs:
assert log in result.output

0 comments on commit 418a59e

Please sign in to comment.