Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test results): error message PR comment if no successful parse #358

Merged
merged 6 commits into from
May 2, 2024

Conversation

joseph-sentry
Copy link
Contributor

Copy link

sentry-io bot commented Apr 3, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: tasks/test_results_finisher.py

Function Unhandled Issue
process_impl_within_lock TypeError: expected string or buffer app.tasks.te...
Event Count: 1

Did you find this useful? React with a 👍 or 👎

@codecov-notifications
Copy link

codecov-notifications bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 98.08917% with 3 lines in your changes are missing coverage. Please review.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #358   +/-   ##
=======================================
  Coverage   97.44%   97.44%           
=======================================
  Files         395      395           
  Lines       33422    33514   +92     
=======================================
+ Hits        32568    32658   +90     
- Misses        854      856    +2     
Flag Coverage Δ
integration 97.44% <98.08%> (+<0.01%) ⬆️
latest-uploader-overall 97.44% <98.08%> (+<0.01%) ⬆️
unit 97.44% <98.08%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 94.81% <93.87%> (+0.06%) ⬆️
OutsideTasks 97.52% <96.47%> (-0.03%) ⬇️
Files Coverage Δ
database/enums.py 100.00% <100.00%> (ø)
database/models/reports.py 99.38% <100.00%> (+<0.01%) ⬆️
services/comparison/__init__.py 96.77% <100.00%> (+0.05%) ⬆️
.../notification/notifiers/mixins/message/sections.py 96.94% <100.00%> (+0.03%) ⬆️
...s/notification/notifiers/mixins/message/writers.py 90.00% <100.00%> (-2.54%) ⬇️
...cation/notifiers/tests/integration/test_comment.py 93.03% <100.00%> (+0.64%) ⬆️
.../notification/notifiers/tests/unit/test_comment.py 99.19% <100.00%> (-0.81%) ⬇️
tasks/notify.py 98.55% <ø> (-0.01%) ⬇️
tasks/test_results_finisher.py 95.03% <100.00%> (+0.50%) ⬆️
tasks/tests/unit/test_notify_task.py 100.00% <ø> (ø)
... and 2 more

... and 13 files with indirect coverage changes

@codecov-qa
Copy link

codecov-qa bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 98.08917% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 97.44%. Comparing base (f64dc25) to head (0b895c4).

❗ Current head 0b895c4 differs from pull request most recent head e8b369a. Consider uploading reports for the commit e8b369a to get more accurate results

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
- Coverage   97.44%   97.44%   -0.01%     
==========================================
  Files         395      395              
  Lines       33430    33514      +84     
==========================================
+ Hits        32577    32658      +81     
- Misses        853      856       +3     
Flag Coverage Δ
integration 97.44% <98.08%> (-0.01%) ⬇️
latest-uploader-overall 97.44% <98.08%> (-0.01%) ⬇️
unit 97.44% <98.08%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 94.81% <93.87%> (+0.05%) ⬆️
OutsideTasks 97.52% <96.47%> (-0.04%) ⬇️
Files Coverage Δ
database/enums.py 100.00% <100.00%> (ø)
database/models/reports.py 99.38% <100.00%> (+<0.01%) ⬆️
services/comparison/__init__.py 96.77% <100.00%> (+0.05%) ⬆️
.../notification/notifiers/mixins/message/sections.py 96.94% <100.00%> (+0.03%) ⬆️
...s/notification/notifiers/mixins/message/writers.py 90.00% <100.00%> (-2.54%) ⬇️
...cation/notifiers/tests/integration/test_comment.py 93.03% <100.00%> (+0.64%) ⬆️
.../notification/notifiers/tests/unit/test_comment.py 99.19% <100.00%> (-0.81%) ⬇️
tasks/notify.py 98.55% <ø> (-0.01%) ⬇️
tasks/test_results_finisher.py 95.03% <100.00%> (+0.50%) ⬆️
tasks/tests/unit/test_notify_task.py 100.00% <ø> (ø)
... and 2 more

... and 17 files with indirect coverage changes

Copy link

codecov-public-qa bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 98.08917% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 97.44%. Comparing base (f64dc25) to head (0b895c4).

❗ Current head 0b895c4 differs from pull request most recent head e8b369a. Consider uploading reports for the commit e8b369a to get more accurate results

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
- Coverage   97.44%   97.44%   -0.01%     
==========================================
  Files         395      395              
  Lines       33430    33514      +84     
==========================================
+ Hits        32577    32658      +81     
- Misses        853      856       +3     
Flag Coverage Δ
integration 97.44% <98.08%> (-0.01%) ⬇️
latest-uploader-overall 97.44% <98.08%> (-0.01%) ⬇️
unit 97.44% <98.08%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 94.81% <93.87%> (+0.05%) ⬆️
OutsideTasks 97.52% <96.47%> (-0.04%) ⬇️
Files Coverage Δ
database/enums.py 100.00% <100.00%> (ø)
database/models/reports.py 99.38% <100.00%> (+<0.01%) ⬆️
services/comparison/__init__.py 96.77% <100.00%> (+0.05%) ⬆️
.../notification/notifiers/mixins/message/sections.py 96.94% <100.00%> (+0.03%) ⬆️
...s/notification/notifiers/mixins/message/writers.py 90.00% <100.00%> (-2.54%) ⬇️
...cation/notifiers/tests/integration/test_comment.py 93.03% <100.00%> (+0.64%) ⬆️
.../notification/notifiers/tests/unit/test_comment.py 99.19% <100.00%> (-0.81%) ⬇️
tasks/notify.py 98.55% <ø> (-0.01%) ⬇️
tasks/test_results_finisher.py 95.03% <100.00%> (+0.50%) ⬆️
tasks/tests/unit/test_notify_task.py 100.00% <ø> (ø)
... and 2 more

... and 17 files with indirect coverage changes

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 98.08917% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 97.47%. Comparing base (f64dc25) to head (0b895c4).

❗ Current head 0b895c4 differs from pull request most recent head e8b369a. Consider uploading reports for the commit e8b369a to get more accurate results

Changes have been made to critical files, which contain lines commonly executed in production. Learn more

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
- Coverage   97.47%   97.47%   -0.01%     
==========================================
  Files         426      426              
  Lines       34121    34205      +84     
==========================================
+ Hits        33259    33340      +81     
- Misses        862      865       +3     
Flag Coverage Δ
integration 97.44% <98.08%> (-0.01%) ⬇️
latest-uploader-overall 97.44% <98.08%> (-0.01%) ⬇️
unit 97.44% <98.08%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 94.84% <93.87%> (+0.05%) ⬆️
OutsideTasks 97.52% <96.47%> (-0.04%) ⬇️
Files Coverage Δ
database/enums.py 100.00% <100.00%> (ø)
database/models/reports.py 99.38% <100.00%> (+<0.01%) ⬆️
services/comparison/__init__.py 96.79% <100.00%> (+0.05%) ⬆️
.../notification/notifiers/mixins/message/sections.py 96.05% <100.00%> (+0.03%) ⬆️
...s/notification/notifiers/mixins/message/writers.py 90.00% <100.00%> (-2.54%) ⬇️
...cation/notifiers/tests/integration/test_comment.py 93.03% <100.00%> (+0.64%) ⬆️
.../notification/notifiers/tests/unit/test_comment.py 99.24% <100.00%> (-0.76%) ⬇️
tasks/notify.py Critical 98.55% <ø> (-0.01%) ⬇️
tasks/test_results_finisher.py 95.74% <100.00%> (+0.43%) ⬆️
tasks/tests/unit/test_notify_task.py 100.00% <ø> (ø)
... and 2 more

... and 17 files with indirect coverage changes

Related Entrypoints
run/app.tasks.notify.Notify

@joseph-sentry joseph-sentry force-pushed the joseph/test-error-comment branch 3 times, most recently from dd7aa1b to aab542a Compare April 17, 2024 17:19
@joseph-sentry joseph-sentry requested a review from a team April 17, 2024 17:26
@joseph-sentry joseph-sentry force-pushed the joseph/test-error-comment branch 2 times, most recently from 8dd6d4f to 7bf5756 Compare April 18, 2024 18:11
@@ -29,6 +29,7 @@ class NotificationContext(object):
"""Extra information not necessarily related to coverage that may affect notifications"""

all_tests_passed: bool
test_results_error: TestResultsProcessingError | None = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the default value be None? To follow the type annotation.

yield (
":white_check_mark: All tests successful. No failed tests found :relaxed:"
)
if comparison.test_results_error():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... if there are no tests then we assume all tests passed? Crazy... Can we fix that? Maybe by checking that there's at least 1 test in the "all tests passed".
I didn't realize this was a possibility before 😅

tasks/notify.py Show resolved Hide resolved
Copy link
Contributor

@giovanni-guidini giovanni-guidini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of changes here. Looks good in general.
I did leave a comment I'd like to see fixed before merging tho 🙏

@@ -47,10 +47,16 @@ def header_lines(self, comparison: ComparisonProxy, diff, settings) -> List[str]
hide_project_coverage = settings.get("hide_project_coverage", False)
if hide_project_coverage:
if comparison.all_tests_passed():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this bit follow the same logic as above? For consistency

  if comparison.test_results_error():
    ...
  elif comparison.all_tests_passed():
    ...

Signed-off-by: joseph-sentry <joseph.sawaya@sentry.io>
Signed-off-by: joseph-sentry <joseph.sawaya@sentry.io>
This commit:
- adds the TestResultsProcessingError enum
- adds the enum as a nullable field in the test results total
- in the test results finisher, when there are no succesful parses,
   it writes to the error field in the totals
- it immediately writes the error message to the comment, then
   queues up a notify
- in the notify step, it will read from the totals to check if there
  was a test result processing error, if there was, let the user know
  by displaying it in the coverage comment, similary to how we
  show succesful parsing of test results
The logic for doing this is as follows:
If there are no successful test results processing tasks this chord
then we check if there were previously test instances that were processed
for this commit.
If there are previous test instances on this commit, there is no error,
and we just exit this finisher without doing anything.
If there are no previous test instances on this commit, then we should
notify the user that there is an error. So we will begin by doing a
test results error comment which contains no info about coverage, then
we will queue up the notify task so it can create a coverage comment
that still contains this error's information.

If there are successful test results processing tasks, then we should
get rid of the error on the test results totals for this commit.

Signed-off-by: joseph-sentry <joseph.sawaya@sentry.io>
If there has been any success in processing for a given commit, it's
associated test result totals should have the error set to None,
otherwise it should be NO_SUCCESS. The condition for all_tests_passed
is: if the error is None and failed = 0 in the totals then all tests
passed. In the comment, if there's an error, show the error comment,
else if all tests passed show the all tests passed message. If neither
of these are true and the user HAS uploaded test results, then it means
that there must have been failures, or they somehow skipped all their
tests.

Signed-off-by: joseph-sentry <joseph.sawaya@sentry.io>
Signed-off-by: joseph-sentry <joseph.sawaya@sentry.io>
@joseph-sentry joseph-sentry added this pull request to the merge queue May 2, 2024
Merged via the queue into main with commit 32d2884 May 2, 2024
12 of 13 checks passed
@joseph-sentry joseph-sentry deleted the joseph/test-error-comment branch May 2, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add call to action on junit file not found
3 participants