From 93c034581295edb6dcacb48315e40b3bb199d336 Mon Sep 17 00:00:00 2001 From: joseph-sentry <136376984+joseph-sentry@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:23:43 -0400 Subject: [PATCH] fix: test results flow success event (#513) Signed-off-by: joseph-sentry --- helpers/checkpoint_logger/flows.py | 2 +- .../notifiers/mixins/message/__init__.py | 2 +- .../notifiers/mixins/message/helpers.py | 4 ++-- tasks/tests/unit/test_upload_task.py | 18 +++++++++--------- tasks/upload.py | 2 ++ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/helpers/checkpoint_logger/flows.py b/helpers/checkpoint_logger/flows.py index 5e156e9c7..a4ad37f2c 100644 --- a/helpers/checkpoint_logger/flows.py +++ b/helpers/checkpoint_logger/flows.py @@ -58,7 +58,7 @@ class UploadFlow(BaseFlow): @failure_events("TEST_RESULTS_ERROR") -@success_events("TEST_RESULTS_BEGIN") +@success_events("TEST_RESULTS_NOTIFY") @subflows( ("test_results_notification_latency", "TEST_RESULTS_BEGIN", "TEST_RESULTS_NOTIFY"), ("flake_notification_latency", "TEST_RESULTS_BEGIN", "FLAKE_DETECTION_NOTIFY"), diff --git a/services/notification/notifiers/mixins/message/__init__.py b/services/notification/notifiers/mixins/message/__init__.py index 1fa34b4a7..a1b0505b8 100644 --- a/services/notification/notifiers/mixins/message/__init__.py +++ b/services/notification/notifiers/mixins/message/__init__.py @@ -219,7 +219,7 @@ async def write_section_to_msg( for line in await section_writer.write_section( comparison, diff, changes, links, behind_by=behind_by ): - wrote_something |= line != None + wrote_something |= line is not None write(line) if wrote_something: write("") diff --git a/services/notification/notifiers/mixins/message/helpers.py b/services/notification/notifiers/mixins/message/helpers.py index 8b6556f91..81ab6f166 100644 --- a/services/notification/notifiers/mixins/message/helpers.py +++ b/services/notification/notifiers/mixins/message/helpers.py @@ -17,10 +17,10 @@ def has_project_status(yaml: UserYaml) -> bool: project_status_details = read_yaml_field( yaml, ("coverage", "status", "project"), False ) - if type(project_status_details) == bool: + if isinstance(project_status_details, bool): return project_status_details # If it's not a bool, it has to be a dict - if type(project_status_details) == dict: + if isinstance(project_status_details, dict): if "enabled" in project_status_details: return project_status_details["enabled"] return True diff --git a/tasks/tests/unit/test_upload_task.py b/tasks/tests/unit/test_upload_task.py index 9d52eeb01..7eb278926 100644 --- a/tasks/tests/unit/test_upload_task.py +++ b/tasks/tests/unit/test_upload_task.py @@ -23,7 +23,7 @@ from database.tests.factories import CommitFactory, OwnerFactory, RepositoryFactory from database.tests.factories.core import ReportFactory from helpers.checkpoint_logger import CheckpointLogger, _kwargs_key -from helpers.checkpoint_logger.flows import UploadFlow +from helpers.checkpoint_logger.flows import TestResultsFlow, UploadFlow from helpers.exceptions import RepositoryWithoutValidBotError from services.archive import ArchiveService from services.report import NotReadyToBuildReportYetError, ReportService @@ -335,16 +335,16 @@ def test_upload_task_call_test_results( report_code=None, ), ) - - notify_sig = test_results_finisher_task.signature( - kwargs=dict( - repoid=commit.repoid, - commitid=commit.commitid, - commit_yaml={"codecov": {"max_report_age": "1y ago"}}, - checkpoints_TestResultsFlow=None, - ) + kwargs = dict( + repoid=commit.repoid, + commitid=commit.commitid, + commit_yaml={"codecov": {"max_report_age": "1y ago"}}, + checkpoints_TestResultsFlow=None, ) + kwargs[_kwargs_key(TestResultsFlow)] = mocker.ANY + notify_sig = test_results_finisher_task.signature(kwargs=kwargs) + chord.assert_called_with([processor_sig], notify_sig) def test_upload_task_call_no_jobs( diff --git a/tasks/upload.py b/tasks/upload.py index bf5cb53f1..24d56156e 100644 --- a/tasks/upload.py +++ b/tasks/upload.py @@ -417,6 +417,8 @@ def run_impl_within_lock( log.warning( "CheckpointLogger failed to log/submit", extra=dict(error=e) ) + elif report_type == ReportType.TEST_RESULTS: + checkpoints = checkpoints_from_kwargs(TestResultsFlow, kwargs) commit = None commits = db_session.query(Commit).filter(