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

Commit 66d10cf

Browse files
Merge branch 'main' into rvinnakota/add-ip-address-sentry
2 parents 263a518 + e8a5caf commit 66d10cf

File tree

355 files changed

+12985
-5266
lines changed

Some content is hidden

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

355 files changed

+12985
-5266
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ permissions:
1919
jobs:
2020
lint:
2121
name: Run Lint
22-
uses: codecov/gha-workflows/.github/workflows/[email protected].23
22+
uses: codecov/gha-workflows/.github/workflows/[email protected].24
2323

2424
build:
2525
name: Build API
26-
uses: codecov/gha-workflows/.github/workflows/[email protected].23
26+
uses: codecov/gha-workflows/.github/workflows/[email protected].24
2727
secrets: inherit
2828
with:
2929
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
3030

3131
codecovstartup:
3232
name: Codecov Startup
3333
needs: build
34-
uses: codecov/gha-workflows/.github/workflows/[email protected].23
34+
uses: codecov/gha-workflows/.github/workflows/[email protected].24
3535
secrets: inherit
3636

3737
# ats:
@@ -47,15 +47,15 @@ jobs:
4747
test:
4848
name: Test
4949
needs: [build]
50-
uses: codecov/gha-workflows/.github/workflows/[email protected].23
50+
uses: codecov/gha-workflows/.github/workflows/[email protected].24
5151
secrets: inherit
5252
with:
5353
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
5454

5555
build-self-hosted:
5656
name: Build Self Hosted API
5757
needs: [build, test]
58-
uses: codecov/gha-workflows/.github/workflows/[email protected].23
58+
uses: codecov/gha-workflows/.github/workflows/[email protected].24
5959
secrets: inherit
6060
with:
6161
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
@@ -64,7 +64,7 @@ jobs:
6464
name: Push Staging Image
6565
needs: [build, test]
6666
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/staging' && github.repository_owner == 'codecov' }}
67-
uses: codecov/gha-workflows/.github/workflows/[email protected].23
67+
uses: codecov/gha-workflows/.github/workflows/[email protected].24
6868
secrets: inherit
6969
with:
7070
environment: staging
@@ -74,7 +74,7 @@ jobs:
7474
name: Push Production Image
7575
needs: [build, test]
7676
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
77-
uses: codecov/gha-workflows/.github/workflows/[email protected].23
77+
uses: codecov/gha-workflows/.github/workflows/[email protected].24
7878
secrets: inherit
7979
with:
8080
environment: production
@@ -85,7 +85,7 @@ jobs:
8585
needs: [build-self-hosted, test]
8686
secrets: inherit
8787
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
88-
uses: codecov/gha-workflows/.github/workflows/[email protected].23
88+
uses: codecov/gha-workflows/.github/workflows/[email protected].24
8989
with:
9090
push_rolling: true
9191
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ coverage.xml
4949
*.cover
5050
.hypothesis/
5151
.pytest_cache/
52+
*.coverage.xml
53+
*junit.xml
5254

5355
# Translations
5456
*.mo
@@ -129,5 +131,6 @@ dmypy.json
129131

130132
# PyCharm stuff
131133
.idea
134+
.run
132135

133136
*.pem

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ check-for-migration-conflicts:
3131
python manage.py check_for_migration_conflicts
3232

3333
test:
34-
COVERAGE_CORE=sysmon python -m pytest --cov=./ --junitxml=junit.xml
34+
COVERAGE_CORE=sysmon python -m pytest --cov=./ --junitxml=junit.xml -o junit_family=legacy
3535

3636
test.unit:
37-
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml
37+
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml -o junit_family=legacy
3838

3939
test.integration:
40-
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml
40+
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml -o junit_family=legacy
4141

4242
lint:
4343
make lint.install
@@ -178,6 +178,9 @@ push.self-hosted-rolling:
178178
docker push ${DOCKERHUB_REPO}:rolling_no_dependencies
179179
docker push ${DOCKERHUB_REPO}:rolling
180180

181+
shell:
182+
docker-compose exec api bash
183+
181184
test_env.up:
182185
env | grep GITHUB > .testenv; true
183186
TIMESERIES_ENABLED=${TIMESERIES_ENABLED} docker-compose up -d

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Do not change `requirements.txt` directly.
7979

8080
### Formatting
8181

82-
This project uses `black` for formatting.
82+
This project uses `ruff` for formatting.
8383
You can run the linter using the command `make lint`.
8484

8585
### Migrations

VERSION

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

api/internal/commit/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import logging
22

3+
import shared.reports.api_report_service as report_service
34
from rest_framework import serializers
45
from shared.reports.types import TOTALS_MAP
56

6-
import services.report as report_service
77
from api.internal.owner.serializers import OwnerSerializer
88
from api.shared.commit.serializers import CommitTotalsSerializer
99
from core.models import Commit

api/internal/coverage/views.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from typing import Any
2+
3+
from django.http import HttpRequest
14
from rest_framework import viewsets
25
from rest_framework.decorators import action
36
from rest_framework.exceptions import NotFound
@@ -13,7 +16,7 @@
1316
class CoverageViewSet(viewsets.ViewSet, RepoPropertyMixin):
1417
permission_classes = [RepositoryArtifactPermissions]
1518

16-
def get_object(self):
19+
def get_object(self) -> ReportPaths:
1720
commit_sha = self.request.query_params.get("sha")
1821
if not commit_sha:
1922
branch_name = self.request.query_params.get("branch", self.repo.branch)
@@ -39,9 +42,7 @@ def get_object(self):
3942
components = self.request.query_params.getlist("components")
4043
component_paths = []
4144
if components:
42-
all_components = components_service.commit_components(
43-
commit, self.request.user
44-
)
45+
all_components = components_service.commit_components(commit, self.owner)
4546
filtered_components = components_service.filter_components_by_name(
4647
all_components, components
4748
)
@@ -62,7 +63,7 @@ def get_object(self):
6263
return paths
6364

6465
@action(detail=False, methods=["get"], url_path="tree")
65-
def tree(self, request, *args, **kwargs):
66+
def tree(self, request: HttpRequest, *args: Any, **kwargs: Any) -> Response:
6667
paths = self.get_object()
6768
serializer = TreeSerializer(paths.single_directory(), many=True)
6869
return Response(serializer.data)

api/internal/owner/serializers.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,15 @@ def get_scheduled_phase(self, schedule):
230230
return StripeScheduledPhaseSerializer(schedule["phases"][-1]).data
231231
else:
232232
# This error represents the phases object not having 2 phases; we are interested in the 2nd entry within phases
233-
# since it represents the scheduled phase
233+
# since it represents the scheduled phase.
234+
# It should not be possible for a schedule to have one phase, but we have seen certain cases where this is true
235+
# after manual intervention on a subscription.
234236
log.error(
235237
"Expecting schedule object to have 2 phases, returning None",
236238
extra=dict(
237-
ownerid=schedule.metadata.obo_organization,
238-
requesting_user_id=schedule.metadata.obo,
239+
ownerid=schedule.metadata.get("obo_organization"),
240+
requesting_user_id=schedule.metadata.get("obo"),
241+
phases=schedule.get("phases", "no phases"),
239242
),
240243
)
241244
return None

api/internal/tests/test_charts.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from pytz import UTC
1414
from rest_framework.exceptions import ValidationError
1515
from rest_framework.reverse import reverse
16+
from shared.django_apps.core.tests.factories import OwnerFactory, RepositoryFactory
1617

1718
from api.internal.chart.filters import apply_default_filters, apply_simple_filters
1819
from api.internal.chart.helpers import (
@@ -23,7 +24,6 @@
2324
)
2425
from codecov.tests.base_test import InternalAPITest
2526
from core.models import Commit
26-
from core.tests.factories import OwnerFactory, RepositoryFactory
2727
from utils.test_utils import Client
2828

2929
fake = faker.Faker()
@@ -56,7 +56,7 @@ def generate_random_totals(
5656
def setup_commits(
5757
repo,
5858
num_commits,
59-
branch="master",
59+
branch="main",
6060
start_date=None,
6161
meets_default_filters=True,
6262
**kwargs,
@@ -251,7 +251,7 @@ def test_apply_simple_filters(self):
251251
end_date = datetime.now()
252252
data = {
253253
"owner_username": self.org1.username,
254-
"branch": "master",
254+
"branch": "main",
255255
"start_date": start_date.isoformat(),
256256
"end_date": end_date.isoformat(),
257257
"repositories": [self.repo1_org1.name, self.repo2_org1.name],
@@ -318,7 +318,7 @@ def test_apply_simple_filters_branch_filtering(self):
318318
for commit in queryset:
319319
assert (
320320
commit.repository.name == self.repo1_org1.name
321-
and commit.branch == "master"
321+
and commit.branch == "main"
322322
) or (
323323
commit.repository.name == branch_test.name and commit.branch == "main"
324324
)
@@ -860,7 +860,7 @@ def setUp(self):
860860

861861
def test_no_permissions(self, mocked_get_permissions):
862862
data = {
863-
"branch": "master",
863+
"branch": "main",
864864
"start_date": timezone.now() - timedelta(7),
865865
"end_date": timezone.now(),
866866
"grouping_unit": "commit",
@@ -879,7 +879,7 @@ def test_no_permissions(self, mocked_get_permissions):
879879
@pytest.mark.skip(reason="flaky, skipping until re write")
880880
def test_get_commits_no_time_grouping(self, mocked_get_permissions):
881881
data = {
882-
"branch": "master",
882+
"branch": "main",
883883
"start_date": timezone.now() - timedelta(7),
884884
"end_date": timezone.now(),
885885
"grouping_unit": "commit",
@@ -897,7 +897,7 @@ def test_get_commits_no_time_grouping(self, mocked_get_permissions):
897897

898898
def test_get_commits_with_time_grouping(self, mocked_get_permissions):
899899
data = {
900-
"branch": "master",
900+
"branch": "main",
901901
"start_date": timezone.now() - timedelta(7),
902902
"end_date": timezone.now(),
903903
"grouping_unit": "day",
@@ -917,7 +917,7 @@ def test_get_commits_with_time_grouping(self, mocked_get_permissions):
917917

918918
def test_get_commits_with_coverage_change(self, mocked_get_permissions):
919919
data = {
920-
"branch": "master",
920+
"branch": "main",
921921
"start_date": timezone.now() - timedelta(7),
922922
"end_date": timezone.now(),
923923
"grouping_unit": "day",

api/internal/tests/test_feature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import pytest
44
from django.urls import reverse
55
from rest_framework.test import APITestCase
6+
from shared.django_apps.core.tests.factories import OwnerFactory
67
from shared.django_apps.rollouts.models import (
78
FeatureFlag,
89
FeatureFlagVariant,
910
RolloutUniverse,
1011
)
1112

12-
from codecov_auth.tests.factories import OwnerFactory
1313
from utils.test_utils import Client
1414

1515

0 commit comments

Comments
 (0)