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

Commit 30dfe70

Browse files
Merge branch 'main' of https://github.com/codecov/codecov-api into rvinnakota/update-ai-repo
2 parents de1f3de + cfb316b commit 30dfe70

Some content is hidden

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

42 files changed

+2837
-1319
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ jobs:
4949
test:
5050
name: Test
5151
needs: [build]
52-
uses: codecov/gha-workflows/.github/workflows/[email protected].27
52+
uses: codecov/gha-workflows/.github/workflows/run-tests-split[email protected].30
5353
secrets: inherit
5454
with:
55+
run_integration: false
5556
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
5657

5758
build-self-hosted:

.test_durations

Lines changed: 2755 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ test:
3434
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 -o junit_family=legacy
37+
@if [ -n "$(GROUP)" ]; then \
38+
COVERAGE_CORE=sysmon python -m pytest --splits ${SPLIT} --group $(GROUP) --cov=./ -m "not integration" --cov-report=xml:unit.$(GROUP).coverage.xml --junitxml=unit.$(GROUP).junit.xml -o junit_family=legacy; \
39+
else \
40+
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml -o junit_family=legacy; \
41+
fi
3842

3943
test.integration:
40-
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml -o junit_family=legacy
44+
@if [ -n "$(GROUP)" ]; then \
45+
COVERAGE_CORE=sysmon python -m pytest --splits ${SPLIT} --group $(GROUP) --cov=./ -m "integration" --cov-report=xml:integration.$(GROUP).coverage.xml --junitxml=integration.$(GROUP).junit.xml -o junit_family=legacy; \
46+
else \
47+
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml -o junit_family=legacy; \
48+
fi
4149

4250
lint:
4351
make lint.install
@@ -197,37 +205,30 @@ test_env.install_cli:
197205

198206
test_env.container_prepare:
199207
apt-get -y install git build-essential netcat-traditional
200-
make test_env.install_cli
201-
git config --global --add safe.directory /app
208+
git config --global --add safe.directory /app || true
202209

203210
test_env.container_check_db:
204211
while ! nc -vz postgres 5432; do sleep 1; echo "waiting for postgres"; done
205212
while ! nc -vz timescale 5432; do sleep 1; echo "waiting for timescale"; done
206213

207214
test_env.run_unit:
208-
docker-compose exec api make test.unit
215+
@if [ -n "$(GROUP)" ]; then \
216+
docker-compose exec api make test.unit SPLIT=${SPLIT} GROUP=${GROUP}; \
217+
else \
218+
docker-compose exec api make test.unit; \
219+
fi
209220

210221
test_env.run_integration:
211-
#docker-compose exec api make test.integration
222+
# @if [ -n "$(GROUP)" ]; then \
223+
# docker-compose exec api make test.integration SPLIT=${SPLIT} GROUP=${GROUP}; \
224+
# else \
225+
# docker-compose exec api make test.integration; \
226+
# fi
212227
echo "Skipping. No Tests"
213228

214229
test_env.check-for-migration-conflicts:
215230
docker-compose exec api python manage.py check_for_migration_conflicts
216231

217-
test_env.upload:
218-
docker-compose exec api make test_env.container_upload CODECOV_UPLOAD_TOKEN=${CODECOV_UPLOAD_TOKEN} CODECOV_URL=${CODECOV_URL}
219-
docker-compose exec api make test_env.container_upload_test_results CODECOV_UPLOAD_TOKEN=${CODECOV_UPLOAD_TOKEN} CODECOV_URL=${CODECOV_URL}
220-
221-
test_env.container_upload:
222-
codecovcli -u ${CODECOV_URL} upload-process --flag unit-latest-uploader --flag unit \
223-
--coverage-files-search-exclude-folder=graphql_api/types/** \
224-
--coverage-files-search-exclude-folder=api/internal/tests/unit/views/cassetes/**
225-
226-
test_env.container_upload_test_results:
227-
codecovcli -u ${CODECOV_URL} do-upload --report-type "test_results" \
228-
--files-search-exclude-folder=graphql_api/types/** \
229-
--files-search-exclude-folder=api/internal/tests/unit/views/cassetes/** || true
230-
231232
test_env.static_analysis:
232233
docker-compose exec api make test_env.container_static_analysis CODECOV_STATIC_TOKEN=${CODECOV_STATIC_TOKEN}
233234

codecov/settings_base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"core",
4141
"graphql_api",
4242
"labelanalysis",
43-
"profiling",
4443
"reports",
4544
"staticanalysis",
4645
"timeseries",

codecov/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
path("webhooks/", include("webhook_handlers.urls")),
2121
path("graphql/", include("graphql_api.urls")),
2222
path("", include("codecov_auth.urls")),
23-
path("profiling/", include("profiling.urls")),
2423
path(f"{settings.DJANGO_ADMIN_URL}/", admin.site.urls),
2524
path("staticanalysis/", include("staticanalysis.urls")),
2625
path("labels/", include("labelanalysis.urls")),

core/commands/repository/interactors/tests/test_get_repository_token.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def setUp(self):
2626
self.user = OwnerFactory(organizations=[self.org.ownerid])
2727
RepositoryTokenFactory(repository=self.active_repo, key="random")
2828

29-
def execute(self, owner, repo, token_type="profiling"):
29+
def execute(self, owner, repo, token_type="upload"):
3030
return GetRepositoryTokenInteractor(owner, "github").execute(
3131
repository=repo, token_type=token_type
3232
)
@@ -44,11 +44,6 @@ async def test_when_repo_has_no_token(self):
4444
assert token is not None
4545
assert len(token) == 40
4646

47-
async def test_get_profiling_token(self):
48-
token = await self.execute(owner=self.user, repo=self.active_repo)
49-
assert token is not None
50-
assert token == "random"
51-
5247
async def test_get_static_analysis_token(self):
5348
token = await self.execute(
5449
owner=self.user, repo=self.active_repo, token_type="static_analysis"

core/commands/repository/interactors/tests/test_regenerate_repository_token.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def execute(self, owner, repo):
3434
return RegenerateRepositoryTokenInteractor(owner, "github").execute(
3535
repo_name=repo.name,
3636
owner_username=self.org.username,
37-
token_type="profiling",
37+
token_type="upload",
3838
)
3939

4040
async def test_when_validation_error_repo_not_active(self):
@@ -44,14 +44,3 @@ async def test_when_validation_error_repo_not_active(self):
4444
async def test_when_validation_error_repo_not_viewable(self):
4545
with pytest.raises(ValidationError):
4646
await self.execute(owner=self.random_user, repo=self.active_repo)
47-
48-
async def test_regenerate_profiling_token_repo_has_no_token(self):
49-
token = await self.execute(owner=self.user, repo=self.repo_with_no_token)
50-
assert token is not None
51-
assert len(token) == 40
52-
53-
async def test_regenerate_profiling_token(self):
54-
token = await self.execute(owner=self.user, repo=self.active_repo)
55-
assert token is not None
56-
assert token != "random"
57-
assert len(token) == 40

graphql_api/tests/mutation/test_regenerate_repository_token.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,6 @@ def test_when_validation_error_repo_not_viewable(self):
6161
== "ValidationError"
6262
)
6363

64-
def test_when_authenticated_regenerate_profiling_token(self):
65-
user = OwnerFactory(
66-
organizations=[self.org.ownerid], permission=[self.repo.repoid]
67-
)
68-
RepositoryTokenFactory(repository=self.repo, key="random")
69-
data = self.gql_request(
70-
query,
71-
owner=user,
72-
variables={
73-
"input": {
74-
"owner": "codecov",
75-
"repoName": "gazebo",
76-
"tokenType": "PROFILING",
77-
}
78-
},
79-
)
80-
newToken = data["regenerateRepositoryToken"]["token"]
81-
assert newToken != "random"
82-
assert len(newToken) == 40
83-
8464
def test_when_authenticated_regenerate_staticanalysis_token(self):
8565
user = OwnerFactory(
8666
organizations=[self.org.ownerid], permission=[self.repo.repoid]

graphql_api/tests/test_branch.py

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from shared.reports.types import ReportTotals
1212

1313
from services.components import Component
14-
from services.profiling import CriticalFile
1514

1615
from .helper import GraphQLTestHelper
1716

@@ -347,11 +346,8 @@ def test_fetch_path_contents_with_no_report(self, report_mock):
347346
}
348347
}
349348

350-
@patch(
351-
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
352-
)
353349
@patch("shared.reports.api_report_service.build_report_from_commit")
354-
def test_fetch_path_contents_with_files(self, report_mock, critical_files):
350+
def test_fetch_path_contents_with_files(self, report_mock):
355351
variables = {
356352
"org": self.org.username,
357353
"repo": self.repo.name,
@@ -365,7 +361,6 @@ def test_fetch_path_contents_with_files(self, report_mock, critical_files):
365361
},
366362
}
367363
report_mock.return_value = MockReport()
368-
critical_files.return_value = [CriticalFile("fileA.py")]
369364

370365
data = self.gql_request(query_files, variables=variables)
371366
assert data == {
@@ -406,7 +401,7 @@ def test_fetch_path_contents_with_files(self, report_mock, critical_files):
406401
"partials": 0,
407402
"lines": 10,
408403
"percentCovered": 80.0,
409-
"isCriticalFile": True,
404+
"isCriticalFile": False,
410405
},
411406
],
412407
}
@@ -416,12 +411,10 @@ def test_fetch_path_contents_with_files(self, report_mock, critical_files):
416411
}
417412
}
418413

419-
@patch(
420-
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
421-
)
422414
@patch("shared.reports.api_report_service.build_report_from_commit")
423415
def test_fetch_path_contents_with_files_and_path_prefix(
424-
self, report_mock, critical_files
416+
self,
417+
report_mock,
425418
):
426419
variables = {
427420
"org": self.org.username,
@@ -436,7 +429,6 @@ def test_fetch_path_contents_with_files_and_path_prefix(
436429
},
437430
}
438431
report_mock.return_value = MockReport()
439-
critical_files.return_value = [CriticalFile("folder/fileB.py")]
440432

441433
data = self.gql_request(query_files, variables=variables)
442434

@@ -457,7 +449,7 @@ def test_fetch_path_contents_with_files_and_path_prefix(
457449
"partials": 0,
458450
"lines": 10,
459451
"percentCovered": 80.0,
460-
"isCriticalFile": True,
452+
"isCriticalFile": False,
461453
},
462454
{
463455
"__typename": "PathContentDir",
@@ -477,12 +469,10 @@ def test_fetch_path_contents_with_files_and_path_prefix(
477469
}
478470
}
479471

480-
@patch(
481-
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
482-
)
483472
@patch("shared.reports.api_report_service.build_report_from_commit")
484473
def test_fetch_path_contents_with_files_and_search_value_case_insensitive(
485-
self, report_mock, critical_files
474+
self,
475+
report_mock,
486476
):
487477
variables = {
488478
"org": self.org.username,
@@ -494,7 +484,6 @@ def test_fetch_path_contents_with_files_and_search_value_case_insensitive(
494484
},
495485
}
496486
report_mock.return_value = MockReport()
497-
critical_files.return_value = [CriticalFile("folder/fileB.py")]
498487

499488
data = self.gql_request(query_files, variables=variables)
500489

@@ -526,7 +515,7 @@ def test_fetch_path_contents_with_files_and_search_value_case_insensitive(
526515
"partials": 0,
527516
"lines": 10,
528517
"percentCovered": 80.0,
529-
"isCriticalFile": True,
518+
"isCriticalFile": False,
530519
},
531520
],
532521
}
@@ -1147,13 +1136,9 @@ def test_fetch_path_contents_component_flags_filters(
11471136
}
11481137
}
11491138

1150-
@patch(
1151-
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
1152-
)
11531139
@patch("shared.reports.api_report_service.build_report_from_commit")
1154-
def test_fetch_path_contents_deprecated(self, report_mock, critical_files_mock):
1140+
def test_fetch_path_contents_deprecated(self, report_mock):
11551141
report_mock.return_value = MockReport()
1156-
critical_files_mock.return_value = []
11571142

11581143
variables = {
11591144
"org": self.org.username,
@@ -1212,15 +1197,12 @@ def test_fetch_path_contents_deprecated(self, report_mock, critical_files_mock):
12121197
}
12131198
}
12141199

1215-
@patch(
1216-
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
1217-
)
12181200
@patch("shared.reports.api_report_service.build_report_from_commit")
12191201
def test_fetch_path_contents_deprecated_paginated(
1220-
self, report_mock, critical_files_mock
1202+
self,
1203+
report_mock,
12211204
):
12221205
report_mock.return_value = MockReport()
1223-
critical_files_mock.return_value = []
12241206

12251207
variables = {
12261208
"org": self.org.username,

0 commit comments

Comments
 (0)