From 418a59eafcc11ad10827f4d6a14174c22d71b558 Mon Sep 17 00:00:00 2001 From: Michelle Tran Date: Fri, 4 Oct 2024 11:21:11 -0400 Subject: [PATCH] Remove writing to GitHub Actions Summary To have feature parity with the existing Test Analytics, we don't actually want to publish to the GitHub Actions Summary. --- codecov_cli/commands/process_test_results.py | 14 ------ tests/commands/test_process_test_results.py | 48 -------------------- 2 files changed, 62 deletions(-) diff --git a/codecov_cli/commands/process_test_results.py b/codecov_cli/commands/process_test_results.py index 9348dfce..aa48cafc 100644 --- a/codecov_cli/commands/process_test_results.py +++ b/codecov_cli/commands/process_test_results.py @@ -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: diff --git a/tests/commands/test_process_test_results.py b/tests/commands/test_process_test_results.py index 6a713386..9ef89adc 100644 --- a/tests/commands/test_process_test_results.py +++ b/tests/commands/test_process_test_results.py @@ -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( @@ -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, }, ) @@ -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, }, ) @@ -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, }, ) @@ -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( @@ -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: @@ -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, }, ) @@ -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