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

Joseph/ta error #979

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions database/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,3 @@ class FlakeSymptomType(Enum):
FAILED_IN_DEFAULT_BRANCH = "failed_in_default_branch"
CONSECUTIVE_DIFF_OUTCOMES = "consecutive_diff_outcomes"
UNRELATED_MATCHING_FAILURES = "unrelated_matching_failures"


class TestResultsProcessingError(Enum):
NO_SUCCESS = "no_success"
3 changes: 3 additions & 0 deletions database/models/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ class TestResultReportTotals(CodecovBaseModel, MixinBaseClass):
passed = Column(types.Integer)
skipped = Column(types.Integer)
failed = Column(types.Integer)

# this field is no longer used in the new ta_finisher task
# TODO: thus, it will be removed in the future
error = Column(types.String(100), nullable=True)


Expand Down
9 changes: 9 additions & 0 deletions database/tests/factories/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,12 @@ class Meta:

key = ""
value = ""


class UploadErrorFactory(Factory):
class Meta:
model = models.UploadError

report_upload = factory.SubFactory(UploadFactory)
error_code = "error"
error_params = {"error_message": "error message"}
24 changes: 22 additions & 2 deletions database/tests/factories/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

import factory

from database.models.reports import CompareFlag, Flake, RepositoryFlag, Test
from database.tests.factories.core import CompareCommitFactory, RepositoryFactory
from database.models.reports import (
CompareFlag,
Flake,
RepositoryFlag,
Test,
TestResultReportTotals,
)
from database.tests.factories.core import (
CompareCommitFactory,
ReportFactory,
RepositoryFactory,
)


class RepositoryFlagFactory(factory.Factory):
Expand Down Expand Up @@ -47,3 +57,13 @@ class Meta:

start_date = dt.datetime.now()
end_date = None


class TestResultReportTotalsFactory(factory.Factory):
class Meta:
model = TestResultReportTotals

report = factory.SubFactory(ReportFactory)
passed = 0
skipped = 0
failed = 0
3 changes: 2 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
https://github.com/codecov/test-results-parser/archive/c840502d1b4dd7d05b2efc2c1328affaf2acd27c.tar.gz#egg=test-results-parser
https://github.com/codecov/test-results-parser/archive/1117e755a36abbecf5a93f3cc3a5e94d918ef895.tar.gz#egg=test-results-parser
https://github.com/codecov/shared/archive/2674ae99811767e63151590906691aed4c5ce1f9.tar.gz#egg=shared
https://github.com/codecov/timestring/archive/d37ceacc5954dff3b5bd2f887936a98a668dda42.tar.gz#egg=timestring
asgiref>=3.7.2
Expand All @@ -18,6 +18,7 @@ grpcio>=1.66.2
httpx
jinja2>=3.1.3
lxml>=5.3.0
msgpack>=1.1.0
mock
multidict>=6.1.0
openai
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ mock==4.0.3
# via -r requirements.in
monotonic==1.5
# via analytics-python
msgpack==1.1.0
# via -r requirements.in
multidict==6.1.0
# via
# -r requirements.in
Expand Down Expand Up @@ -366,7 +368,7 @@ statsd==3.3.0
# via -r requirements.in
stripe==9.6.0
# via -r requirements.in
test-results-parser @ https://github.com/codecov/test-results-parser/archive/c840502d1b4dd7d05b2efc2c1328affaf2acd27c.tar.gz#egg=test-results-parser
test-results-parser @ https://github.com/codecov/test-results-parser/archive/1117e755a36abbecf5a93f3cc3a5e94d918ef895.tar.gz#egg=test-results-parser
# via -r requirements.in
text-unidecode==1.3
# via faker
Expand Down
2 changes: 2 additions & 0 deletions rollouts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
SHOW_IMPACT_ANALYSIS_DEPRECATION_MSG = Feature(
"show_impact_analysis_deprecation_message"
)

NEW_TA_TASKS = Feature("new_ta_tasks")
18 changes: 12 additions & 6 deletions services/comparison/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from shared.torngit.exceptions import TorngitClientGeneralError
from shared.utils.sessions import SessionType

from database.enums import CompareCommitState, TestResultsProcessingError
from database.enums import CompareCommitState
from database.models import CompareCommit
from services.archive import ArchiveService
from services.comparison.changes import get_changes
Expand All @@ -27,7 +27,7 @@ class ComparisonContext(object):

repository_service: TorngitBaseAdapter | None = None
all_tests_passed: bool | None = None
test_results_error: TestResultsProcessingError | None = None
test_results_error: str | None = None
gh_app_installation_name: str | None = None
gh_is_using_codecov_commenter: bool = False
# GitLab has a "merge results pipeline" (see https://docs.gitlab.com/ee/ci/pipelines/merged_results_pipelines.html)
Expand Down Expand Up @@ -263,11 +263,17 @@ def get_behind_by(self):
]
return self._behind_by

def all_tests_passed(self):
return self.context is not None and self.context.all_tests_passed
def all_tests_passed(self) -> bool:
if self.context:
return self.context.all_tests_passed or False
else:
return False

def test_results_error(self):
return self.context is not None and self.context.test_results_error
def test_results_error(self) -> str | None:
if self.context:
return self.context.test_results_error
else:
return None

def get_existing_statuses(self):
if self._existing_statuses is None:
Expand Down
10 changes: 5 additions & 5 deletions services/notification/notifiers/mixins/message/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

log = logging.getLogger(__name__)

ALL_TESTS_PASSED_MSG = ":white_check_mark: All tests successful. No failed tests found."


def get_section_class_from_layout_name(layout_name):
if layout_name.startswith("flag"):
Expand Down Expand Up @@ -108,14 +110,12 @@ def do_write_section(self, comparison, diff, changes, links, behind_by=None):

class HeaderSectionWriter(BaseSectionWriter):
def _possibly_include_test_result_setup_confirmation(self, comparison):
if comparison.test_results_error():
if ta_error_msg := comparison.test_results_error():
yield ("")
yield (
":x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format."
)
yield (ta_error_msg)
elif comparison.all_tests_passed():
yield ""
yield (":white_check_mark: All tests successful. No failed tests found.")
yield (ALL_TESTS_PASSED_MSG)

def do_write_section(self, comparison, diff, changes, links, behind_by=None):
yaml = self.current_yaml
Expand Down
7 changes: 2 additions & 5 deletions services/notification/notifiers/mixins/message/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ def header_lines(self, comparison: ComparisonProxy, diff, settings) -> List[str]
lines.append(
"All modified and coverable lines are covered by tests :white_check_mark:"
)

hide_project_coverage = settings.get("hide_project_coverage", False)
if hide_project_coverage:
if comparison.test_results_error():
if ta_error_msg := comparison.test_results_error():
lines.append("")
lines.append(
":x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format."
)
lines.append(ta_error_msg)
elif comparison.all_tests_passed():
lines.append("")
lines.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest
from shared.reports.readonly import ReadOnlyReport

from database.enums import TestResultsProcessingError
from database.tests.factories import CommitFactory, PullFactory, RepositoryFactory
from services.comparison import ComparisonContext, ComparisonProxy
from services.comparison.types import Comparison, EnrichedPull, FullCommit
Expand Down Expand Up @@ -413,7 +412,7 @@ def test_notify_test_results_error(
):
sample_comparison.context = ComparisonContext(
all_tests_passed=False,
test_results_error=TestResultsProcessingError.NO_SUCCESS,
test_results_error=":x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format.",
)
mock_configuration._params["setup"] = {
"codecov_url": None,
Expand Down
7 changes: 3 additions & 4 deletions services/notification/notifiers/tests/unit/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from shared.validation.types import CoverageCommentRequiredChanges
from shared.yaml import UserYaml

from database.enums import TestResultsProcessingError
from database.models.core import Commit, GithubAppInstallation, Pull, Repository
from database.tests.factories import RepositoryFactory
from database.tests.factories.core import CommitFactory, OwnerFactory, PullFactory
Expand Down Expand Up @@ -3724,7 +3723,7 @@ def test_new_header_section_writer_test_results_error(
):
sample_comparison.context = ComparisonContext(
all_tests_passed=False,
test_results_error=TestResultsProcessingError.NO_SUCCESS,
test_results_error=":x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format.",
)
writer = HeaderSectionWriter(
mocker.MagicMock(),
Expand Down Expand Up @@ -3812,7 +3811,7 @@ def test_new_header_section_writer_no_project_coverage_test_results_error(
):
sample_comparison.context = ComparisonContext(
all_tests_passed=False,
test_results_error=TestResultsProcessingError.NO_SUCCESS,
test_results_error=":x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format.",
)
writer = HeaderSectionWriter(
mocker.MagicMock(),
Expand Down Expand Up @@ -4651,7 +4650,7 @@ def test_build_message_team_plan_customer_all_lines_covered_test_results_error(
mock_configuration.params["setup"]["codecov_dashboard_url"] = "test.example.br"
sample_comparison_coverage_carriedforward.context = ComparisonContext(
all_tests_passed=False,
test_results_error=TestResultsProcessingError.NO_SUCCESS,
test_results_error=":x: We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format.",
)
comparison = sample_comparison_coverage_carriedforward
comparison.repository_service.service = "github"
Expand Down
3 changes: 2 additions & 1 deletion services/processing/flake_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def process_flake_for_repo_commit(
):
uploads = ReportSession.objects.filter(
report__report_type=CommitReport.ReportType.TEST_RESULTS.value,
report__commit__repository__repoid=repo_id,
report__commit__commitid=commit_id,
state="processed",
state__in=["processed", "v2_finished"],
).all()

curr_flakes = fetch_curr_flakes(repo_id)
Expand Down
Loading
Loading