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

Commit a16a695

Browse files
committed
Merge branch 'main' of github.com:codecov/codecov-api
2 parents aba332e + e5a743b commit a16a695

File tree

17 files changed

+175
-142
lines changed

17 files changed

+175
-142
lines changed

.github/workflows/upload-overwatch.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ jobs:
2424
run: |
2525
pip install mypy==1.15.0
2626
pip install ruff==0.9.6
27-
- name: Install Build Dependencies
28-
run: |
29-
sudo apt-get update
30-
# Install libssl1.1 from Ubuntu 20.04 repositories
31-
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
32-
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
3327
- name: Install Overwatch CLI
3428
run: |
3529
curl -o overwatch-cli https://overwatch.codecov.dev/linux/cli
@@ -40,4 +34,4 @@ jobs:
4034
--auth-token ${{ secrets.SENTRY_AUTH_TOKEN }} \
4135
--organization-slug codecov \
4236
python \
43-
--python-path $(which python3)
37+
--python-path $(which python3)

api/internal/tests/views/test_compare_viewset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ def setUp(self):
9191
self.base_file = ReportFile(
9292
name=self.file_name, totals=[46, 46, 0, 0, 100, 0, 0, 0, 1, 0, 0, 0]
9393
)
94-
self.base_file._lines = [[1, "", [[1, 1, 0, 0, 0]], 0, 0]] * 46
94+
self.base_file._parsed_lines = [[1, "", [[1, 1, 0, 0, 0]], 0, 0]] * 46
9595
self.base_report = MockSerializableReport()
9696
self.base_report.mocked_files = {self.file_name: self.base_file}
9797

9898
self.head_file = ReportFile(
9999
name=self.file_name, totals=[6, 6, 0, 0, 100, 0, 0, 0, 1, 0, 0, 0]
100100
)
101-
self.head_file._lines = [[1, "", [[1, 1, 0, 0, 0]], 0, 0]] * 6
101+
self.head_file._parsed_lines = [[1, "", [[1, 1, 0, 0, 0]], 0, 0]] * 6
102102
self.head_file.totals.diff = ReportTotals.default_totals()
103103
self.head_report = MockSerializableReport()
104104
self.head_report.mocked_files = {self.file_name: self.head_file}

api/public/v2/tests/test_api_compare_viewset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,14 @@ def setUp(self):
259259
self.base_file = ReportFile(
260260
name=self.file_name, totals=[46, 46, 0, 0, 100, 0, 0, 0, 1, 0, 0, 0]
261261
)
262-
self.base_file._lines = [[1, "", [[1, 1, 0, 0, 0]], 0, 0]] * 46
262+
self.base_file._parsed_lines = [[1, "", [[1, 1, 0, 0, 0]], 0, 0]] * 46
263263
self.base_report = MockSerializableReport()
264264
self.base_report.mocked_files = {self.file_name: self.base_file}
265265

266266
self.head_file = ReportFile(
267267
name=self.file_name, totals=[6, 6, 0, 0, 100, 0, 0, 0, 1, 0, 0, 0]
268268
)
269-
self.head_file._lines = [[1, "", [[1, 1, 0, 0, 0]], 0, 0]] * 6
269+
self.head_file._parsed_lines = [[1, "", [[1, 1, 0, 0, 0]], 0, 0]] * 6
270270
self.head_file.totals.diff = ReportTotals.default_totals()
271271
self.head_report = MockSerializableReport()
272272
self.head_report.mocked_files = {self.file_name: self.head_file}

codecov/settings_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@
7676
TEMPLATES = [
7777
{
7878
"BACKEND": "django.template.backends.django.DjangoTemplates",
79-
"DIRS": [],
79+
"DIRS": [
80+
"templates",
81+
],
8082
"APP_DIRS": True,
8183
"OPTIONS": {
8284
"context_processors": [

codecov/settings_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
ALLOWED_HOSTS = ["localhost"]
66
CORS_ALLOWED_ORIGINS = ["http://localhost:9000", "http://localhost"]
7+
SHELTER_ENABLED = True
78
SHELTER_PUBSUB_PROJECT_ID = "test-project-id"
89
SHELTER_PUBSUB_SYNC_REPO_TOPIC_ID = "test-topic-id"
910

graphql_api/tests/test_test_analytics.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
get_results,
2222
)
2323
from services.redis_configuration import get_redis_connection
24+
from utils.test_results import dedup_table
2425

2526
from .helper import GraphQLTestHelper
2627

@@ -171,21 +172,23 @@ def store_in_redis(repository):
171172

172173
@pytest.fixture
173174
def store_in_storage(repository, mock_storage):
175+
from django.conf import settings
176+
174177
try:
175-
mock_storage.create_root_storage("codecov")
178+
mock_storage.create_root_storage(settings.GCS_BUCKET_NAME)
176179
except BucketAlreadyExistsError:
177180
pass
178181

179182
mock_storage.write_file(
180-
"codecov",
183+
settings.GCS_BUCKET_NAME,
181184
f"test_results/rollups/{repository.repoid}/{repository.branch}/30",
182185
test_results_table.write_ipc(None).getvalue(),
183186
)
184187

185188
yield
186189

187190
mock_storage.delete_file(
188-
"codecov",
191+
settings.GCS_BUCKET_NAME,
189192
f"test_results/rollups/{repository.repoid}/{repository.branch}/30",
190193
)
191194

@@ -218,7 +221,8 @@ def test_get_test_results(
218221
):
219222
results = get_results(repository.repoid, repository.branch, 30)
220223
assert results is not None
221-
assert results.equals(test_results_table)
224+
225+
assert results.equals(dedup_table(test_results_table))
222226

223227
def test_get_test_results_no_storage(
224228
self, transactional_db, repository, mock_storage
@@ -231,7 +235,7 @@ def test_get_test_results_no_redis(
231235
m = mocker.patch("services.task.TaskService.cache_test_results_redis")
232236
results = get_results(repository.repoid, repository.branch, 30)
233237
assert results is not None
234-
assert results.equals(test_results_table)
238+
assert results.equals(dedup_table(test_results_table))
235239

236240
m.assert_called_once_with(repository.repoid, repository.branch)
237241

graphql_api/types/test_analytics/test_analytics.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -215,37 +215,6 @@ def generate_test_results(
215215
},
216216
)
217217

218-
failure_rate_expr = (
219-
pl.col("failure_rate")
220-
* (pl.col("total_fail_count") + pl.col("total_pass_count"))
221-
).sum() / (pl.col("total_fail_count") + pl.col("total_pass_count")).sum()
222-
223-
flake_rate_expr = (
224-
pl.col("flake_rate") * (pl.col("total_fail_count") + pl.col("total_pass_count"))
225-
).sum() / (pl.col("total_fail_count") + pl.col("total_pass_count")).sum()
226-
227-
avg_duration_expr = (
228-
pl.col("avg_duration")
229-
* (pl.col("total_pass_count") + pl.col("total_fail_count"))
230-
).sum() / (pl.col("total_pass_count") + pl.col("total_fail_count")).sum()
231-
232-
# dedup
233-
table = table.group_by("name").agg(
234-
pl.col("test_id").first().alias("test_id"),
235-
pl.col("testsuite").alias("testsuite"),
236-
pl.col("flags").explode().unique().alias("flags"),
237-
failure_rate_expr.alias("failure_rate"),
238-
flake_rate_expr.alias("flake_rate"),
239-
pl.col("updated_at").max().alias("updated_at"),
240-
avg_duration_expr.alias("avg_duration"),
241-
pl.col("total_fail_count").sum().alias("total_fail_count"),
242-
pl.col("total_flaky_fail_count").sum().alias("total_flaky_fail_count"),
243-
pl.col("total_pass_count").sum().alias("total_pass_count"),
244-
pl.col("total_skip_count").sum().alias("total_skip_count"),
245-
pl.col("commits_where_fail").sum().alias("commits_where_fail"),
246-
pl.col("last_duration").max().alias("last_duration"),
247-
)
248-
249218
if term:
250219
table = table.filter(pl.col("name").str.contains(term))
251220

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ dev-dependencies = [
7474
]
7575

7676
[tool.uv.sources]
77-
shared = { git = "https://github.com/codecov/shared", rev = "284b92c74f0bc7ca5c4f6f139f3b26fe64fe9c1a" }
77+
shared = { git = "https://github.com/codecov/shared", rev = "290557e977c4ff60d5d9dcb9ee54afea1c1df83f" }

services/activation.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,24 @@ def try_auto_activate(org: Owner, owner: Owner) -> bool:
7676
activator = _get_activator(org, owner)
7777

7878
if activator.is_autoactivation_enabled():
79-
log.info(f"Attemping to auto-activate user {owner.ownerid} in {org.ownerid}")
79+
log.info(
80+
"Attemping to auto-activate user",
81+
extra=dict(
82+
owner_id=owner.ownerid,
83+
org_id=org.ownerid
84+
),
85+
)
8086
if activator.can_activate_user():
8187
activator.activate_user()
8288
return True
8389
else:
84-
log.info("Auto-activation failed -- not enough seats remaining")
90+
log.info(
91+
"Auto-activation failed -- not enough seats remaining",
92+
extra=dict(
93+
owner_id=owner.ownerid,
94+
org_id=org.ownerid
95+
),
96+
)
8597
return False
8698

8799

services/tests/test_comparison.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ def test_lines(self):
569569
}
570570
src = [first_line_val, "this is an added line", last_line_val]
571571

572-
self.file_comparison.head_file._lines = head_lines
573-
self.file_comparison.base_file._lines = base_lines
572+
self.file_comparison.head_file._parsed_lines = head_lines
573+
self.file_comparison.base_file._parsed_lines = base_lines
574574
self.file_comparison.diff_data = {"segments": [segment]}
575575
self.file_comparison.src = src
576576

@@ -665,8 +665,8 @@ def test_change_summary(self):
665665
}
666666
src = [first_line_val, "this is an added line", last_line_val]
667667

668-
self.file_comparison.head_file._lines = head_lines
669-
self.file_comparison.base_file._lines = base_lines
668+
self.file_comparison.head_file._parsed_lines = head_lines
669+
self.file_comparison.base_file._parsed_lines = base_lines
670670
self.file_comparison.diff_data = {"segments": [segment]}
671671
self.file_comparison.src = src
672672

@@ -1311,10 +1311,10 @@ def setUp(self):
13111311

13121312
def test_single_segment(self):
13131313
self.file_comparison.src = self._src(12)
1314-
self.file_comparison.head_file._lines = self._report_lines(
1314+
self.file_comparison.head_file._parsed_lines = self._report_lines(
13151315
[1 for _ in range(12)]
13161316
)
1317-
self.file_comparison.base_file._lines = self._report_lines(
1317+
self.file_comparison.base_file._parsed_lines = self._report_lines(
13181318
[
13191319
1,
13201320
1, # first line of segment
@@ -1341,10 +1341,10 @@ def test_single_segment(self):
13411341

13421342
def test_multiple_segments(self):
13431343
self.file_comparison.src = self._src(25)
1344-
self.file_comparison.head_file._lines = self._report_lines(
1344+
self.file_comparison.head_file._parsed_lines = self._report_lines(
13451345
[1 for _ in range(25)]
13461346
)
1347-
self.file_comparison.base_file._lines = self._report_lines(
1347+
self.file_comparison.base_file._parsed_lines = self._report_lines(
13481348
[
13491349
1,
13501350
1, # first line of segment 1

0 commit comments

Comments
 (0)