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

Commit 8174946

Browse files
authored
Bundle Analysis: add a getter for cache config (#1148)
1 parent d39b6b1 commit 8174946

File tree

10 files changed

+30
-4
lines changed

10 files changed

+30
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def test_update_bundles_successfully(self):
7676
)
7777

7878
assert res == [
79-
{"bundle_name": "bundle1", "is_cached": False},
80-
{"bundle_name": "bundle2", "is_cached": True},
79+
{"bundle_name": "bundle1", "is_cached": False, "cache_config": False},
80+
{"bundle_name": "bundle2", "is_cached": True, "cache_config": True},
8181
]
8282

8383
assert len(CacheConfig.objects.all()) == 2

core/commands/repository/interactors/update_bundle_cache_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def execute(
5757
{
5858
"bundle_name": bundle_name,
5959
"is_cached": is_caching,
60+
"cache_config": is_caching,
6061
}
6162
)
6263
return results

graphql_api/tests/mutation/test_update_bundle_cache_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
results {
3131
bundleName
3232
isCached
33+
cacheConfig
3334
}
3435
error {
3536
__typename

graphql_api/tests/test_commit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ def test_bundle_analysis_report(self, get_storage_service):
12021202
}
12031203
}
12041204
isCached
1205+
cacheConfig
12051206
}
12061207
bundleData {
12071208
loadTime {
@@ -1263,6 +1264,7 @@ def test_bundle_analysis_report(self, get_storage_service):
12631264
},
12641265
},
12651266
"isCached": False,
1267+
"cacheConfig": False,
12661268
},
12671269
{
12681270
"name": "b2",
@@ -1285,6 +1287,7 @@ def test_bundle_analysis_report(self, get_storage_service):
12851287
},
12861288
},
12871289
"isCached": False,
1290+
"cacheConfig": False,
12881291
},
12891292
{
12901293
"name": "b3",
@@ -1307,6 +1310,7 @@ def test_bundle_analysis_report(self, get_storage_service):
13071310
},
13081311
},
13091312
"isCached": False,
1313+
"cacheConfig": False,
13101314
},
13111315
{
13121316
"name": "b5",
@@ -1329,6 +1333,7 @@ def test_bundle_analysis_report(self, get_storage_service):
13291333
},
13301334
},
13311335
"isCached": False,
1336+
"cacheConfig": False,
13321337
},
13331338
],
13341339
"bundleData": {

graphql_api/types/bundle_analysis/base.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ type BundleReport {
9393
before: String
9494
): AssetConnection
9595
info: BundleReportInfo!
96+
cacheConfig: Boolean!
9697
}
9798

9899
type BundleAnalysisMeasurements{

graphql_api/types/bundle_analysis/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@ def resolve_bundle_report_is_cached(
372372
return bundle_report.is_cached
373373

374374

375+
@bundle_report_bindable.field("cacheConfig")
376+
def resolve_bundle_report_cache_config(
377+
bundle_report: BundleReport, info: GraphQLResolveInfo
378+
) -> bool:
379+
return bundle_report.cache_config(info.context["commit"].repository.pk)
380+
381+
375382
@bundle_report_bindable.field("info")
376383
def resolve_bundle_report_info(
377384
bundle_report: BundleReport, info: GraphQLResolveInfo

graphql_api/types/mutation/update_bundle_cache_config/update_bundle_cache_config.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ union UpdateBundleCacheConfigError = UnauthenticatedError | ValidationError
33
type UpdateBundleCacheConfigResult {
44
bundleName: String
55
isCached: Boolean
6+
cacheConfig: Boolean
67
}
78

89
type UpdateBundleCacheConfigPayload {

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ freezegun
2525
google-cloud-pubsub
2626
gunicorn>=22.0.0
2727
https://github.com/codecov/opentelem-python/archive/refs/tags/v0.0.4a1.tar.gz#egg=codecovopentelem
28-
https://github.com/codecov/shared/archive/986a0971a633eac2a3005947102cb5f4d9119989.tar.gz#egg=shared
28+
https://github.com/codecov/shared/archive/69b736859ab71e1e3e91018439a6cb6b792502f3.tar.gz#egg=shared
2929
https://github.com/photocrowd/django-cursor-pagination/archive/f560902696b0c8509e4d95c10ba0d62700181d84.tar.gz
3030
idna>=3.7
3131
minio

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ sentry-sdk[celery]==2.13.0
416416
# shared
417417
setproctitle==1.1.10
418418
# via -r requirements.in
419-
shared @ https://github.com/codecov/shared/archive/986a0971a633eac2a3005947102cb5f4d9119989.tar.gz
419+
shared @ https://github.com/codecov/shared/archive/69b736859ab71e1e3e91018439a6cb6b792502f3.tar.gz
420420
# via -r requirements.in
421421
simplejson==3.17.2
422422
# via -r requirements.in

services/bundle_analysis.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
from shared.bundle_analysis import BundleReport as SharedBundleReport
1919
from shared.bundle_analysis import ModuleReport as SharedModuleReport
2020
from shared.bundle_analysis.models import AssetType
21+
from shared.django_apps.bundle_analysis.service.bundle_analysis import (
22+
BundleAnalysisCacheConfigService,
23+
)
2124
from shared.storage import get_appropriate_storage_service
2225

26+
from codecov.db import sync_to_async
2327
from core.models import Commit, Repository
2428
from graphql_api.actions.measurements import (
2529
measurements_by_ids,
@@ -306,6 +310,12 @@ def is_cached(self) -> bool:
306310
def info(self) -> dict:
307311
return self.report.info()
308312

313+
@sync_to_async
314+
def cache_config(self, repo_id: int) -> bool:
315+
return BundleAnalysisCacheConfigService.get_cache_option(
316+
repo_id=repo_id, name=self.report.name
317+
)
318+
309319

310320
@dataclass
311321
class BundleReportInfo(object):

0 commit comments

Comments
 (0)