From f8e17a3a9d1da2981a4e604dd2ab86a6584f0b8e Mon Sep 17 00:00:00 2001 From: Michelle Tran Date: Tue, 8 Oct 2024 12:50:30 -0400 Subject: [PATCH 1/2] Update test-results-parser This will include the new formatted comment --- codecov_cli/commands/process_test_results.py | 2 +- requirements.txt | 4 ++-- setup.py | 2 +- tests/commands/test_process_test_results.py | 24 +------------------- 4 files changed, 5 insertions(+), 27 deletions(-) diff --git a/codecov_cli/commands/process_test_results.py b/codecov_cli/commands/process_test_results.py index f887c5b9..d2ab1b9d 100644 --- a/codecov_cli/commands/process_test_results.py +++ b/codecov_cli/commands/process_test_results.py @@ -173,7 +173,7 @@ def generate_message_payload(upload_collection_results): try: logger.info(f"Parsing {result.get_filename()}") testruns = parse_junit_xml(result.get_content()) - for testrun in testruns: + for testrun in testruns.testruns: if ( testrun.outcome == Outcome.Failure or testrun.outcome == Outcome.Error diff --git a/requirements.txt b/requirements.txt index d40822af..781e4223 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile setup.py @@ -43,7 +43,7 @@ sniffio==1.3.0 # anyio # httpcore # httpx -test-results-parser==0.1.0 +test-results-parser==0.5.1 # via codecov-cli (setup.py) tree-sitter==0.20.2 # via codecov-cli (setup.py) diff --git a/setup.py b/setup.py index 2102345e..e3e6a86f 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ "pyyaml==6.*", "responses==0.21.*", "tree-sitter==0.20.*", - "test-results-parser==0.1.*", + "test-results-parser==0.5.*", "regex", ], entry_points={ diff --git a/tests/commands/test_process_test_results.py b/tests/commands/test_process_test_results.py index 1baf73b2..2a6a0575 100644 --- a/tests/commands/test_process_test_results.py +++ b/tests/commands/test_process_test_results.py @@ -45,29 +45,7 @@ def test_process_test_results( assert result.exit_code == 0 - mocked_post.assert_called_with( - url="https://api.github.com/repos/fake/repo/issues/pull/comments", - data={ - "body": "### :x: Failed Test Results: \nCompleted 4 tests with **`1 failed`**, 3 passed and 0 skipped.\n
View the full list of failed tests\n\n| **Test Description** | **Failure message** |\n| :-- | :-- |\n|
Testsuite:
api.temp.calculator.test_calculator::test_divide

Test name:
pytest
|
def
test_divide():
> assert Calculator.divide(1, 2) == 0.5
E assert 1.0 == 0.5
E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
.../temp/calculator/test_calculator.py:30: AssertionError
|", - "cli_args": { - "auto_load_params_from": None, - "codecov_yml_path": None, - "enterprise_url": None, - "verbose": False, - "version": f"cli-{__version__}", - "command": "process-test-results", - "provider_token": "whatever", - "disable_search": True, - "dir": os.getcwd(), - "exclude_folders": (), - }, - }, - headers={ - "Accept": "application/vnd.github+json", - "Authorization": "Bearer whatever", - "X-GitHub-Api-Version": "2022-11-28", - }, - ) + mocked_post.assert_called_once() def test_process_test_results_non_existent_file(mocker, tmpdir): From ce84dfe73c2c8480183e3e1da4c3980fe012e181 Mon Sep 17 00:00:00 2001 From: Michelle Tran Date: Wed, 9 Oct 2024 11:59:56 -0400 Subject: [PATCH 2/2] Use local version of codecov-cli for label analysis Since the tests are running on the "official" version of the CLI, it is failing for any interface changes between the official version and the version currently in review. So, changing it to also use the local CLI for running the tests. --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be24dc08..0076094a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,10 +124,12 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.12" - - name: Install CLI + - name: Install dependencies for Dogfooding run: | - pip install -r requirements.txt -r tests/requirements.txt - pip install codecov-cli + python -m pip install --upgrade pip + pip install -r requirements.txt + python -m pip install -e . + pip install -r tests/requirements.txt - name: Label Analysis run: | BASE_SHA=$(git merge-base HEAD^ origin/main)