Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion api/internal/tests/views/test_coverage_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
OwnerFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from services.components import Component
Expand Down
2 changes: 1 addition & 1 deletion api/public/v2/report/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def filter_report(
# empty report since the path is not part of the component
return Report()

component_flags = component.get_matching_flags(report.flags.keys())
component_flags = component.get_matching_flags(report.get_flag_names())
if flag and len(component.flag_regexes) > 0 and flag not in component_flags:
# empty report since the flag is not part of the component
return Report()
Expand Down
4 changes: 2 additions & 2 deletions api/public/v2/tests/test_api_compare_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
RepositoryFactory,
)
from shared.reports.api_report_service import SerializableReport
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.types import ReportTotals
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine, ReportTotals
from shared.utils.merge import LineType
from shared.utils.sessions import Session

Expand Down
3 changes: 2 additions & 1 deletion api/public/v2/tests/test_api_component_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
OwnerFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from services.components import Component
Expand Down
3 changes: 2 additions & 1 deletion api/public/v2/tests/test_file_report_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
OwnerFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from core.models import Branch
Expand Down
3 changes: 2 additions & 1 deletion api/public/v2/tests/test_flag_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
OwnerFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from reports.tests.factories import RepositoryFlagFactory
Expand Down
3 changes: 2 additions & 1 deletion api/public/v2/tests/test_report_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
OwnerFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from utils.test_utils import APIClient
Expand Down
3 changes: 2 additions & 1 deletion api/public/v2/tests/test_report_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
CommitFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from services.components import Component
Expand Down
3 changes: 2 additions & 1 deletion api/public/v2/tests/test_totals_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
OwnerFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from services.components import Component
Expand Down
7 changes: 3 additions & 4 deletions compare/commands/compare/interactors/fetch_impacted_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def _apply_filters(
components_flags = []

head_commit_report = comparison.head_report_without_applied_diff
report_flags = head_commit_report and head_commit_report.get_flag_names()
if components_filter:
all_components = components.commit_components(
comparison.head_commit, comparison.user
Expand All @@ -50,9 +51,7 @@ def _apply_filters(
)
for component in filtered_components:
components_paths.extend(component.paths)
components_flags.extend(
component.get_matching_flags(head_commit_report.flags.keys())
)
components_flags.extend(component.get_matching_flags(report_flags))

# Flags & Components intersection
if components_flags:
Expand All @@ -62,7 +61,7 @@ def _apply_filters(
flags_filter = components_flags

if flags_filter:
if set(flags_filter) & set(head_commit_report.flags):
if set(flags_filter) & set(report_flags):
files = files_belonging_to_flags(
commit_report=head_commit_report, flags=flags_filter
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
PullFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from compare.commands.compare.interactors.fetch_impacted_files import (
Expand Down
3 changes: 2 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import pytest
import vcr
from django.conf import settings
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

# we need to enable this in the test environment since we're often creating
Expand Down
6 changes: 6 additions & 0 deletions graphql_api/tests/test_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def __iter__(self):
for name in self.files:
yield MockFile(name)

def get_flag_names(self):
return ["flag_a"]

@property
def flags(self):
return {"flag-a": MockFlag()}
Expand All @@ -199,6 +202,9 @@ def __init__(self):
def flags(self):
return None

def get_flag_names(self):
return []


class TestBranch(GraphQLTestHelper, TransactionTestCase):
def setUp(self):
Expand Down
5 changes: 2 additions & 3 deletions graphql_api/tests/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ def get(self, file, _else):
def filter(self, **kwargs):
return self

@property
def flags(self):
return {"flag_a": True, "flag_b": True}
def get_flag_names(self):
return ["flag_a", "flag_b"]


class EmptyReport(MockReport):
Expand Down
3 changes: 2 additions & 1 deletion graphql_api/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
PullFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from compare.models import CommitComparison
Expand Down
3 changes: 2 additions & 1 deletion graphql_api/tests/test_impacted_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
PullFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.torngit.exceptions import (
TorngitClientGeneralError,
TorngitObjectNotFoundError,
Expand Down
4 changes: 2 additions & 2 deletions graphql_api/tests/test_path_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.test import TransactionTestCase
from shared.django_apps.core.tests.factories import CommitFactory
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.types import ReportTotals
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine, ReportTotals
from shared.utils.sessions import Session

from services.path import Dir, File
Expand Down
14 changes: 7 additions & 7 deletions graphql_api/types/commit/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def get_sorted_path_contents(
component_paths = []
component_flags = []

report_flags = report.get_flag_names()

if component_filter:
all_components = components_service.commit_components(commit, current_owner)
filtered_components = components_service.filter_components_by_name_or_id(
Expand All @@ -173,18 +175,16 @@ def get_sorted_path_contents(

for component in filtered_components:
component_paths.extend(component.paths)
if report.flags:
component_flags.extend(
component.get_matching_flags(report.flags.keys())
)
if report_flags:
component_flags.extend(component.get_matching_flags(report_flags))

if component_flags:
if flags_filter:
flags_filter = list(set(flags_filter) & set(component_flags))
else:
flags_filter = component_flags

if flags_filter and not report.flags:
if flags_filter and not report_flags:
return UnknownFlags(f"No coverage with chosen flags: {flags_filter}")

report_paths = ReportPaths(
Expand Down Expand Up @@ -325,8 +325,8 @@ def resolve_coverage_totals(
@sentry_sdk.trace
@commit_coverage_analytics_bindable.field("flagNames")
@sync_to_async
def resolve_coverage_flags(commit: Commit, info: GraphQLResolveInfo) -> List[str]:
return commit.full_report.flags.keys()
def resolve_coverage_flags(commit: Commit, info: GraphQLResolveInfo) -> list[str]:
return commit.full_report.get_flag_names()


@sentry_sdk.trace
Expand Down
4 changes: 3 additions & 1 deletion graphql_api/types/comparison/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def resolve_impacted_files(

if filters and comparison:
flags = filters.get("flags", [])
if flags and set(flags).isdisjoint(set(comparison.head_report.flags)):
if flags and set(flags).isdisjoint(
set(comparison.head_report.get_flag_names())
):
return UnknownFlags()

return {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ dev-dependencies = [
]

[tool.uv.sources]
shared = { git = "https://github.com/codecov/shared", rev = "4755e7f77efc711c6ca34c2fb284edce71836402" }
shared = { git = "https://github.com/codecov/shared", rev = "079d368c402758bc7ccb47572425237a9ebd9f9b" }
2 changes: 1 addition & 1 deletion services/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def component_filtered_report(
"""
flags, paths = [], []
for component in components:
flags.extend(component.get_matching_flags(report.flags.keys()))
flags.extend(component.get_matching_flags(report.get_flag_names()))
paths.extend(component.paths)
filtered_report = report.filter(flags=flags, paths=paths)
return filtered_report
Expand Down
3 changes: 2 additions & 1 deletion services/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
OwnerFactory,
RepositoryFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session
from shared.yaml.user_yaml import UserYaml

Expand Down
4 changes: 2 additions & 2 deletions services/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from django.test import TestCase
from shared.django_apps.core.tests.factories import CommitFactory, OwnerFactory
from shared.reports.api_report_service import SerializableReport
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.types import ReportTotals
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine, ReportTotals
from shared.torngit.exceptions import TorngitClientGeneralError
from shared.utils.sessions import Session

Expand Down
3 changes: 2 additions & 1 deletion services/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
build_report,
build_report_from_commit,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.storage.exceptions import FileNotInStorageError
from shared.utils.sessions import Session

Expand Down
3 changes: 2 additions & 1 deletion timeseries/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
DatasetFactory,
MeasurementFactory,
)
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.reports.resources import Report, ReportFile
from shared.reports.types import ReportLine
from shared.utils.sessions import Session

from timeseries.helpers import (
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading