Skip to content
Draft
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
94 changes: 14 additions & 80 deletions apps/worker/database/enums.py
Original file line number Diff line number Diff line change
@@ -1,80 +1,14 @@
from enum import Enum


class Decoration(Enum):
standard = "standard"
upgrade = "upgrade"
upload_limit = "upload_limit"
passing_empty_upload = "passing_empty_upload"
failing_empty_upload = "failing_empty_upload"
processing_upload = "processing_upload"


class Notification(Enum):
comment = "comment"
status_changes = "status_changes"
status_patch = "status_patch"
status_project = "status_project"
checks_changes = "checks_changes"
checks_patch = "checks_patch"
checks_project = "checks_project"
slack = "slack"
webhook = "webhook"
gitter = "gitter"
irc = "irc"
hipchat = "hipchat"
codecov_slack_app = "codecov_slack_app"


notification_type_status_or_checks = {
Notification.status_changes,
Notification.status_patch,
Notification.status_project,
Notification.checks_changes,
Notification.checks_patch,
Notification.checks_project,
}


class NotificationState(Enum):
pending = "pending"
success = "success"
error = "error"


class CompareCommitState(Enum):
pending = "pending"
processed = "processed"
error = "error"


class CompareCommitError(Enum):
missing_base_report = "missing_base_report"
missing_head_report = "missing_head_report"
provider_client_error = "provider_client_error"


class CommitErrorTypes(Enum):
INVALID_YAML = "invalid_yaml"
YAML_CLIENT_ERROR = "yaml_client_error"
YAML_UNKNOWN_ERROR = "yaml_unknown_error"
REPO_BOT_INVALID = "repo_bot_invalid"


class TrialStatus(Enum):
NOT_STARTED = "not_started"
ONGOING = "ongoing"
EXPIRED = "expired"
CANNOT_TRIAL = "cannot_trial"


class ReportType(Enum):
COVERAGE = "coverage"
TEST_RESULTS = "test_results"
BUNDLE_ANALYSIS = "bundle_analysis"


class FlakeSymptomType(Enum):
FAILED_IN_DEFAULT_BRANCH = "failed_in_default_branch"
CONSECUTIVE_DIFF_OUTCOMES = "consecutive_diff_outcomes"
UNRELATED_MATCHING_FAILURES = "unrelated_matching_failures"
# Re-export all enums from the shared location for backward compatibility.
# New code should import directly from shared.django_apps.enums.
from shared.django_apps.enums import ( # noqa: F401
CommitErrorTypes,
CompareCommitError,
CompareCommitState,
Decoration,
FlakeSymptomType,
Notification,
NotificationState,
ReportType,
TrialStatus,
notification_type_status_or_checks,
)
7 changes: 6 additions & 1 deletion apps/worker/database/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@

import database.models
from database.base import CodecovBaseModel, MixinBaseClass, MixinBaseClassNoExternalID
from database.enums import Decoration, Notification, NotificationState, ReportType
from database.utils import ArchiveField
from shared.django_apps.enums import (
Decoration,
Notification,
NotificationState,
ReportType,
)
from shared.django_apps.utils.config import should_write_data_to_storage_config_check
from shared.helpers.github_apps import is_configured
from shared.plan.constants import DEFAULT_FREE_PLAN, PlanName
Expand Down
3 changes: 2 additions & 1 deletion apps/worker/database/tests/factories/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import factory
from factory import Factory

from database import enums, models
from database import models
from services.encryption import encryptor
from shared.django_apps import enums
from shared.django_apps.codecov_auth.models import Plan, Tier
from shared.plan.constants import DEFAULT_FREE_PLAN, TierName

Expand Down
2 changes: 1 addition & 1 deletion apps/worker/helpers/tests/unit/test_commit_error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from database.enums import CommitErrorTypes
from database.tests.factories import CommitFactory
from helpers.save_commit_error import save_commit_error
from shared.django_apps.enums import CommitErrorTypes


class TestSaveCommitError:
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/services/bundle_analysis/comparison.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from functools import cached_property

from database.enums import ReportType
from database.models.core import Commit, Repository
from database.models.reports import CommitReport
from services.bundle_analysis.exceptions import (
Expand All @@ -14,6 +13,7 @@
BundleAnalysisComparison,
BundleAnalysisReportLoader,
)
from shared.django_apps.enums import ReportType


class ComparisonLoader:
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/services/bundle_analysis/notify/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from pathlib import Path

from database.enums import ReportType
from database.models.core import Commit, Repository
from database.models.reports import CommitReport
from database.tests.factories.core import CommitFactory, PullFactory
from services.repository import EnrichedPull
from shared.api_archive.archive import ArchiveService
from shared.bundle_analysis.storage import get_bucket_name
from shared.django_apps.enums import ReportType

SAMPLE_FOLDER_PATH = Path(__file__).resolve().parent / "tests" / "samples"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import sentry_sdk

from database.enums import ReportType
from database.models.core import Commit, Repository
from database.models.reports import CommitReport
from services.bundle_analysis.notify.helpers import to_BundleThreshold
Expand All @@ -14,6 +13,7 @@
)
from services.repository import get_repo_provider_service
from shared.bundle_analysis import BundleAnalysisReport, BundleAnalysisReportLoader
from shared.django_apps.enums import ReportType
from shared.torngit.base import TorngitBaseAdapter
from shared.typings.torngit import AdditionalData, UploadType
from shared.validation.types import BundleThreshold
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/services/bundle_analysis/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from sqlalchemy.dialects import postgresql
from sqlalchemy.orm import Session

from database.enums import ReportType
from database.models.core import Commit
from database.models.reports import CommitReport, Upload, UploadError
from database.models.timeseries import Measurement, MeasurementName
Expand All @@ -21,6 +20,7 @@
from shared.django_apps.bundle_analysis.service.bundle_analysis import (
BundleAnalysisCacheConfigService,
)
from shared.django_apps.enums import ReportType
from shared.metrics import Counter
from shared.reports.enums import UploadState, UploadType
from shared.storage.exceptions import FileNotInStorageError, PutRequestRateLimitError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pytest

from database.enums import ReportType
from database.models import CommitReport, MeasurementName
from database.tests.factories import CommitFactory, PullFactory, UploadFactory
from database.tests.factories.timeseries import DatasetFactory, Measurement
Expand All @@ -28,6 +27,7 @@
from shared.bundle_analysis.models import AssetType
from shared.bundle_analysis.storage import get_bucket_name
from shared.config import PATCH_CENTRIC_DEFAULT_CONFIG
from shared.django_apps.enums import ReportType
from shared.yaml import UserYaml
from tests.helpers import mock_all_plans_and_tiers

Expand Down
2 changes: 1 addition & 1 deletion apps/worker/services/comparison/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import sentry_sdk
from asgiref.sync import async_to_sync

from database.enums import CompareCommitState
from database.models import CompareCommit
from services.comparison.changes import get_changes
from services.comparison.types import Comparison, FullCommit, ReportUploadedCount
from services.repository import get_repo_provider_service
from shared.django_apps.enums import CompareCommitState
from shared.reports.changes import run_comparison_using_rust
from shared.reports.types import Change, ReportTotals
from shared.torngit.base import TorngitBaseAdapter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from database.enums import CompareCommitState
from database.tests.factories.core import CommitFactory, CompareCommitFactory
from services.comparison import get_or_create_comparison
from shared.django_apps.enums import CompareCommitState


class TestGetOrCreateComparison:
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/services/decoration.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging
from dataclasses import dataclass

from database.enums import Decoration
from database.models import Owner
from services.license import requires_license
from services.repository import EnrichedPull
from shared.config import get_config
from shared.django_apps.enums import Decoration
from shared.plan.service import PlanService
from shared.upload.utils import query_monthly_coverage_measurements

Expand Down
2 changes: 1 addition & 1 deletion apps/worker/services/lock_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from redis import Redis # type: ignore
from redis.exceptions import LockError # type: ignore

from database.enums import ReportType
from shared.celery_config import (
DEFAULT_BLOCKING_TIMEOUT_SECONDS,
DEFAULT_LOCK_TIMEOUT_SECONDS,
)
from shared.config import get_config
from shared.django_apps.enums import ReportType
from shared.helpers.redis import get_redis_connection # type: ignore

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/services/notification/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from celery.exceptions import CeleryError, SoftTimeLimitExceeded

from database.enums import notification_type_status_or_checks
from database.models.core import GITHUB_APP_INSTALLATION_DEFAULT_NAME, Owner, Repository
from services.comparison import ComparisonProxy
from services.decoration import Decoration
Expand All @@ -38,6 +37,7 @@
from services.yaml.reader import get_components_from_yaml
from shared.config import get_config
from shared.django_apps.codecov_auth.models import Plan
from shared.django_apps.enums import notification_type_status_or_checks
from shared.helpers.yaml import default_if_true
from shared.plan.constants import TierName
from shared.torngit.base import TorngitBaseAdapter
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/services/notification/commit_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from sqlalchemy.orm.session import Session

from database.enums import NotificationState
from database.models import CommitNotification, Pull
from services.comparison import ComparisonProxy
from services.notification.notifiers.base import (
AbstractBaseNotifier,
NotificationResult,
)
from shared.django_apps.enums import NotificationState

log = logging.getLogger(__name__)

Expand Down
Loading
Loading