Skip to content

Commit

Permalink
Update test-results-parser (#524)
Browse files Browse the repository at this point in the history
* Update test-results-parser

This will include the new formatted comment

* 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.
  • Loading branch information
michelletran-codecov authored Oct 9, 2024
1 parent 5fb28a6 commit a22eaf0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 30 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion codecov_cli/commands/process_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
24 changes: 1 addition & 23 deletions tests/commands/test_process_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<details><summary>View the full list of failed tests</summary>\n\n| **Test Description** | **Failure message** |\n| :-- | :-- |\n| <pre>Testsuite:<br>api.temp.calculator.test_calculator::test_divide<br><br>Test name:<br>pytest<br></pre> | <pre>def<br> test_divide():<br> &amp;gt; assert Calculator.divide(1, 2) == 0.5<br> E assert 1.0 == 0.5<br> E + where 1.0 = &amp;lt;function Calculator.divide at 0x104c9eb90&amp;gt;(1, 2)<br> E + where &amp;lt;function Calculator.divide at 0x104c9eb90&amp;gt; = Calculator.divide<br> .../temp/calculator/test_calculator.py:30: AssertionError</pre> |",
"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):
Expand Down

0 comments on commit a22eaf0

Please sign in to comment.