Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit fb936bb

Browse files
Merge branch 'main' of https://github.com/codecov/codecov-api into rvinnakota/indirect-misses
2 parents ec522e0 + 7749e0b commit fb936bb

File tree

138 files changed

+4610
-4919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+4610
-4919
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@ concurrency:
1515
permissions:
1616
contents: "read"
1717
id-token: "write"
18+
issues: "write"
19+
pull-requests: "write"
1820

1921
jobs:
2022
lint:
2123
name: Run Lint
22-
uses: codecov/gha-workflows/.github/workflows/[email protected].24
24+
uses: codecov/gha-workflows/.github/workflows/[email protected].26
2325

2426
build:
2527
name: Build API
26-
uses: codecov/gha-workflows/.github/workflows/[email protected].24
28+
uses: codecov/gha-workflows/.github/workflows/[email protected].26
2729
secrets: inherit
2830
with:
2931
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
3032

3133
codecovstartup:
3234
name: Codecov Startup
3335
needs: build
34-
uses: codecov/gha-workflows/.github/workflows/[email protected].24
36+
uses: codecov/gha-workflows/.github/workflows/[email protected].26
3537
secrets: inherit
3638

3739
# ats:
@@ -47,15 +49,15 @@ jobs:
4749
test:
4850
name: Test
4951
needs: [build]
50-
uses: codecov/gha-workflows/.github/workflows/[email protected].24
52+
uses: codecov/gha-workflows/.github/workflows/[email protected].26
5153
secrets: inherit
5254
with:
5355
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
5456

5557
build-self-hosted:
5658
name: Build Self Hosted API
5759
needs: [build, test]
58-
uses: codecov/gha-workflows/.github/workflows/[email protected].24
60+
uses: codecov/gha-workflows/.github/workflows/[email protected].26
5961
secrets: inherit
6062
with:
6163
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
@@ -64,7 +66,7 @@ jobs:
6466
name: Push Staging Image
6567
needs: [build, test]
6668
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/staging' && github.repository_owner == 'codecov' }}
67-
uses: codecov/gha-workflows/.github/workflows/[email protected].24
69+
uses: codecov/gha-workflows/.github/workflows/[email protected].26
6870
secrets: inherit
6971
with:
7072
environment: staging
@@ -74,7 +76,7 @@ jobs:
7476
name: Push Production Image
7577
needs: [build, test]
7678
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
77-
uses: codecov/gha-workflows/.github/workflows/[email protected].24
79+
uses: codecov/gha-workflows/.github/workflows/[email protected].26
7880
secrets: inherit
7981
with:
8082
environment: production
@@ -85,7 +87,7 @@ jobs:
8587
needs: [build-self-hosted, test]
8688
secrets: inherit
8789
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
88-
uses: codecov/gha-workflows/.github/workflows/[email protected].24
90+
uses: codecov/gha-workflows/.github/workflows/[email protected].26
8991
with:
9092
push_rolling: true
9193
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24.11.1
1+
24.12.2

api/internal/coverage/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_object(self) -> ReportPaths:
4343
component_paths = []
4444
if components:
4545
all_components = components_service.commit_components(commit, self.owner)
46-
filtered_components = components_service.filter_components_by_name(
46+
filtered_components = components_service.filter_components_by_name_or_id(
4747
all_components, components
4848
)
4949

api/internal/owner/serializers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
from django.conf import settings
77
from rest_framework import serializers
88
from rest_framework.exceptions import PermissionDenied
9-
10-
from codecov_auth.models import Owner
11-
from plan.constants import (
9+
from shared.plan.constants import (
1210
PAID_PLANS,
1311
SENTRY_PAID_USER_PLAN_REPRESENTATIONS,
1412
TEAM_PLAN_MAX_USERS,
1513
TEAM_PLAN_REPRESENTATIONS,
1614
)
17-
from plan.service import PlanService
15+
from shared.plan.service import PlanService
16+
17+
from codecov_auth.models import Owner
1818
from services.billing import BillingService
1919
from services.sentry import send_user_webhook as send_sentry_webhook
2020

api/internal/tests/views/test_account_viewset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
OwnerFactory,
1515
UserFactory,
1616
)
17+
from shared.plan.constants import PlanName, TrialStatus
1718
from stripe import StripeError
1819

1920
from api.internal.tests.test_utils import GetAdminProviderAdapter
2021
from codecov_auth.models import Service
21-
from plan.constants import PlanName, TrialStatus
2222
from utils.test_utils import APIClient
2323

2424
curr_path = os.path.dirname(__file__)

api/public/v2/owner/serializers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ class Meta:
3131
model = Owner
3232
fields = ("username", "name", "has_active_session", "expiry_date")
3333
read_only_fields = fields
34+
35+
36+
class UserUpdateActivationSerializer(serializers.ModelSerializer):
37+
activated = serializers.BooleanField()
38+
39+
class Meta:
40+
model = Owner
41+
fields = ("activated",)

api/public/v2/owner/views.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,34 @@
33
from django.db.models import Q, QuerySet
44
from drf_spectacular.utils import extend_schema
55
from rest_framework import mixins, viewsets
6-
from rest_framework.exceptions import NotFound
6+
from rest_framework.exceptions import APIException, NotFound
77
from rest_framework.permissions import IsAuthenticated
88
from rest_framework.request import Request
99
from rest_framework.response import Response
1010

11-
from api.public.v2.schema import owner_parameters, service_parameter
11+
from api.public.v2.schema import (
12+
owner_parameters,
13+
service_parameter,
14+
)
1215
from api.shared.owner.mixins import (
1316
OwnerViewSetMixin,
1417
UserSessionViewSetMixin,
1518
UserViewSetMixin,
1619
)
1720
from codecov_auth.models import Owner, Service
1821

19-
from .serializers import OwnerSerializer, UserSerializer, UserSessionSerializer
22+
from .serializers import (
23+
OwnerSerializer,
24+
UserSerializer,
25+
UserSessionSerializer,
26+
UserUpdateActivationSerializer,
27+
)
28+
29+
30+
class NotEnoughSeatsLeft(APIException):
31+
status_code = 400
32+
default_detail = "Cannot activate user -- not enough seats left."
33+
default_code = "no_seats_left"
2034

2135

2236
@extend_schema(parameters=owner_parameters, tags=["Users"])
@@ -53,6 +67,31 @@ def retrieve(self, request: Request, *args: Any, **kwargs: Any) -> Owner:
5367
"""
5468
return super().retrieve(request, *args, **kwargs)
5569

70+
@extend_schema(summary="Update a user", request=UserUpdateActivationSerializer)
71+
def partial_update(self, request: Request, *args: Any, **kwargs: Any) -> Response:
72+
"""
73+
Updates a user for the specified owner_username or ownerid
74+
75+
Allowed fields
76+
- activated: boolean value to activate or deactivate the user
77+
"""
78+
instance = self.get_object()
79+
serializer = UserUpdateActivationSerializer(
80+
instance,
81+
data=request.data,
82+
)
83+
serializer.is_valid(raise_exception=True)
84+
85+
if serializer.validated_data["activated"]:
86+
if self.owner.can_activate_user(instance):
87+
self.owner.activate_user(instance)
88+
else:
89+
raise NotEnoughSeatsLeft()
90+
else:
91+
self.owner.deactivate_user(instance)
92+
93+
return super().retrieve(request, *args, **kwargs)
94+
5695

5796
@extend_schema(parameters=owner_parameters, tags=["Users"])
5897
class UserSessionViewSet(UserSessionViewSetMixin, mixins.ListModelMixin):

0 commit comments

Comments
 (0)