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

Commit a68172f

Browse files
authored
Bundle analysis: [GQL] Add asset routes to BundleAsset type (#1010)
1 parent 022c44b commit a68172f

File tree

8 files changed

+173
-36
lines changed

8 files changed

+173
-36
lines changed

graphql_api/tests/test_commit.py

Lines changed: 156 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,7 +3267,7 @@ def test_bundle_analysis_asset_routes(self, get_storage_service):
32673267
)
32683268

32693269
with open(
3270-
"./services/tests/samples/bundle_with_assets_and_modules.sqlite", "rb"
3270+
"./services/tests/samples/bundle_with_asset_routes.sqlite", "rb"
32713271
) as f:
32723272
storage_path = StoragePaths.bundle_report.path(
32733273
repo_key=ArchiveService.get_archive_hash(self.repo),
@@ -3285,8 +3285,8 @@ def test_bundle_analysis_asset_routes(self, get_storage_service):
32853285
bundleAnalysisReport {
32863286
__typename
32873287
... on BundleAnalysisReport {
3288-
bundle(name: "b5") {
3289-
asset(name: "assets/LazyComponent-fcbb0922.js") {
3288+
bundle(name: "@codecov/example-sveltekit-app-client-esm") {
3289+
assets {
32903290
name
32913291
normalizedName
32923292
routes
@@ -3310,18 +3310,151 @@ def test_bundle_analysis_asset_routes(self, get_storage_service):
33103310
data = self.gql_request(query, variables=variables)
33113311
commit = data["owner"]["repository"]["commit"]
33123312

3313-
asset_report = commit["bundleAnalysis"]["bundleAnalysisReport"]["bundle"][
3314-
"asset"
3313+
asset_reports = commit["bundleAnalysis"]["bundleAnalysisReport"]["bundle"][
3314+
"assets"
33153315
]
33163316

3317-
assert asset_report is not None
3318-
assert asset_report["name"] == "assets/LazyComponent-fcbb0922.js"
3319-
assert asset_report["normalizedName"] == "assets/LazyComponent-*.js"
3320-
assert asset_report["routes"] == [
3321-
"/",
3322-
"/about",
3323-
"/login",
3324-
"/super/long/url/path",
3317+
assert asset_reports == [
3318+
{
3319+
"name": "_app/immutable/assets/svelte-welcome.VNiyy3gC.png",
3320+
"normalizedName": "_app/immutable/assets/svelte-welcome.*.png",
3321+
"routes": [],
3322+
},
3323+
{
3324+
"name": "_app/immutable/assets/svelte-welcome.0pIiHnVF.webp",
3325+
"normalizedName": "_app/immutable/assets/svelte-welcome.*.webp",
3326+
"routes": [],
3327+
},
3328+
{
3329+
"name": "_app/immutable/assets/fira-mono-all-400-normal.B2mvLtSD.woff",
3330+
"normalizedName": "_app/immutable/assets/fira-mono-all-400-normal.*.woff",
3331+
"routes": [],
3332+
},
3333+
{
3334+
"name": "_app/immutable/chunks/entry.BaWB2kHj.js",
3335+
"normalizedName": "_app/immutable/chunks/entry.*.js",
3336+
"routes": [],
3337+
},
3338+
{
3339+
"name": "_app/immutable/nodes/4.CcjRtXvw.js",
3340+
"normalizedName": "_app/immutable/nodes/4.*.js",
3341+
"routes": ["/sverdle"],
3342+
},
3343+
{
3344+
"name": "_app/immutable/assets/fira-mono-latin-400-normal.DKjLVgQi.woff2",
3345+
"normalizedName": "_app/immutable/assets/fira-mono-latin-400-normal.*.woff2",
3346+
"routes": [],
3347+
},
3348+
{
3349+
"name": "_app/immutable/assets/fira-mono-cyrillic-ext-400-normal.B04YIrm4.woff2",
3350+
"normalizedName": "_app/immutable/assets/fira-mono-cyrillic-ext-400-normal.*.woff2",
3351+
"routes": [],
3352+
},
3353+
{
3354+
"name": "_app/immutable/assets/fira-mono-latin-ext-400-normal.D6XfiR-_.woff2",
3355+
"normalizedName": "_app/immutable/assets/fira-mono-latin-ext-400-normal.D6XfiR-_.woff2",
3356+
"routes": [],
3357+
},
3358+
{
3359+
"name": "_app/immutable/assets/fira-mono-greek-400-normal.C3zng6O6.woff2",
3360+
"normalizedName": "_app/immutable/assets/fira-mono-greek-400-normal.*.woff2",
3361+
"routes": [],
3362+
},
3363+
{
3364+
"name": "_app/immutable/assets/fira-mono-cyrillic-400-normal.36-45Uyg.woff2",
3365+
"normalizedName": "_app/immutable/assets/fira-mono-cyrillic-400-normal.*.woff2",
3366+
"routes": [],
3367+
},
3368+
{
3369+
"name": "_app/immutable/nodes/0.CL_S-12h.js",
3370+
"normalizedName": "_app/immutable/nodes/0.CL_S-12h.js",
3371+
"routes": ["/"],
3372+
},
3373+
{
3374+
"name": "_app/immutable/assets/fira-mono-greek-ext-400-normal.CsqI23CO.woff2",
3375+
"normalizedName": "_app/immutable/assets/fira-mono-greek-ext-400-normal.*.woff2",
3376+
"routes": [],
3377+
},
3378+
{
3379+
"name": "_app/immutable/chunks/index.DDRweiI9.js",
3380+
"normalizedName": "_app/immutable/chunks/index.*.js",
3381+
"routes": [],
3382+
},
3383+
{
3384+
"name": "_app/immutable/entry/app.Dd9ByE1Q.js",
3385+
"normalizedName": "_app/immutable/entry/app.*.js",
3386+
"routes": [],
3387+
},
3388+
{
3389+
"name": "_app/immutable/nodes/2.BMQFqo-e.js",
3390+
"normalizedName": "_app/immutable/nodes/2.*.js",
3391+
"routes": ["/"],
3392+
},
3393+
{
3394+
"name": "_app/immutable/assets/0.CT0x_Q5c.css",
3395+
"normalizedName": "_app/immutable/assets/0.CT0x_Q5c.css",
3396+
"routes": [],
3397+
},
3398+
{
3399+
"name": "_app/immutable/assets/4.DOkkq0IA.css",
3400+
"normalizedName": "_app/immutable/assets/4.*.css",
3401+
"routes": [],
3402+
},
3403+
{
3404+
"name": "_app/immutable/nodes/5.CwxmUzn6.js",
3405+
"normalizedName": "_app/immutable/nodes/5.*.js",
3406+
"routes": ["/sverdle/how-to-play"],
3407+
},
3408+
{
3409+
"name": "_app/immutable/chunks/scheduler.Dk-snqIU.js",
3410+
"normalizedName": "_app/immutable/chunks/scheduler.*.js",
3411+
"routes": [],
3412+
},
3413+
{
3414+
"name": "_app/immutable/nodes/3.BqQOub2U.js",
3415+
"normalizedName": "_app/immutable/nodes/3.*.js",
3416+
"routes": ["/about"],
3417+
},
3418+
{
3419+
"name": "_app/immutable/assets/2.Cs8KR-Bb.css",
3420+
"normalizedName": "_app/immutable/assets/2.*.css",
3421+
"routes": [],
3422+
},
3423+
{
3424+
"name": "_app/immutable/nodes/1.stWWSe4n.js",
3425+
"normalizedName": "_app/immutable/nodes/1.*.js",
3426+
"routes": [],
3427+
},
3428+
{
3429+
"name": "_app/immutable/assets/5.CU6psp88.css",
3430+
"normalizedName": "_app/immutable/assets/5.*.css",
3431+
"routes": [],
3432+
},
3433+
{
3434+
"name": "_app/immutable/chunks/index.Ice1EKvx.js",
3435+
"normalizedName": "_app/immutable/chunks/index.*.js",
3436+
"routes": [],
3437+
},
3438+
{
3439+
"name": "_app/immutable/chunks/stores.BrqGIpx3.js",
3440+
"normalizedName": "_app/immutable/chunks/stores.*.js",
3441+
"routes": [],
3442+
},
3443+
{
3444+
"name": "_app/immutable/entry/start.B1Q1eB84.js",
3445+
"normalizedName": "_app/immutable/entry/start.*.js",
3446+
"routes": [],
3447+
},
3448+
{
3449+
"name": "_app/immutable/chunks/index.R8ovVqwX.js",
3450+
"normalizedName": "_app/immutable/chunks/index.*.js",
3451+
"routes": [],
3452+
},
3453+
{
3454+
"name": "_app/version.json",
3455+
"normalizedName": "_app/version.json",
3456+
"routes": [],
3457+
},
33253458
]
33263459

33273460
@patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
@@ -3355,12 +3488,12 @@ def test_bundle_analysis_report_info(self, get_storage_service):
33553488
bundle(name: "b5") {
33563489
info {
33573490
version
3358-
plugin_name
3359-
plugin_version
3360-
built_at
3491+
pluginName
3492+
pluginVersion
3493+
builtAt
33613494
duration
3362-
bundler_name
3363-
bundler_version
3495+
bundlerName
3496+
bundlerVersion
33643497
}
33653498
}
33663499
}
@@ -3384,9 +3517,9 @@ def test_bundle_analysis_report_info(self, get_storage_service):
33843517
bundle_info = commit["bundleAnalysis"]["bundleAnalysisReport"]["bundle"]["info"]
33853518

33863519
assert bundle_info["version"] == "1"
3387-
assert bundle_info["plugin_name"] == "codecov-vite-bundle-analysis-plugin"
3388-
assert bundle_info["plugin_version"] == "1.0.0"
3389-
assert bundle_info["built_at"] == "2023-12-01 17:17:28.604000"
3520+
assert bundle_info["pluginName"] == "codecov-vite-bundle-analysis-plugin"
3521+
assert bundle_info["pluginVersion"] == "1.0.0"
3522+
assert bundle_info["builtAt"] == "2023-12-01 17:17:28.604000"
33903523
assert bundle_info["duration"] == 331
3391-
assert bundle_info["bundler_name"] == "rollup"
3392-
assert bundle_info["bundler_version"] == "3.29.4"
3524+
assert bundle_info["bundlerName"] == "rollup"
3525+
assert bundle_info["bundlerVersion"] == "3.29.4"

graphql_api/types/bundle_analysis/base.graphql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ type BundleAsset {
6060

6161
type BundleReportInfo {
6262
version: String!
63-
plugin_name: String!
64-
plugin_version: String!
65-
built_at: String!
63+
pluginName: String!
64+
pluginVersion: String!
65+
builtAt: String!
6666
duration: Int!
67-
bundler_name: String!
68-
bundler_version: String!
67+
bundlerName: String!
68+
bundlerVersion: String!
6969
}
7070

7171
type BundleReport {

graphql_api/types/bundle_analysis/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def resolve_asset_report_measurements(
164164
def resolve_routes(
165165
bundle_asset: AssetReport, info: GraphQLResolveInfo
166166
) -> Optional[List[str]]:
167-
return ["/", "/about", "/login", "/super/long/url/path"]
167+
return bundle_asset.routes
168168

169169

170170
# ============= Bundle Report Bindable =============
@@ -390,21 +390,21 @@ def resolve_bundle_report_info_version(
390390
return bundle_report_info.version
391391

392392

393-
@bundle_report_info_bindable.field("plugin_name")
393+
@bundle_report_info_bindable.field("pluginName")
394394
def resolve_bundle_report_info_plugin_name(
395395
bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo
396396
) -> str:
397397
return bundle_report_info.plugin_name
398398

399399

400-
@bundle_report_info_bindable.field("plugin_version")
400+
@bundle_report_info_bindable.field("pluginVersion")
401401
def resolve_bundle_report_info_plugin_version(
402402
bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo
403403
) -> str:
404404
return bundle_report_info.plugin_version
405405

406406

407-
@bundle_report_info_bindable.field("built_at")
407+
@bundle_report_info_bindable.field("builtAt")
408408
def resolve_bundle_report_info_built_at(
409409
bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo
410410
) -> str:
@@ -418,14 +418,14 @@ def resolve_bundle_report_info_duration(
418418
return bundle_report_info.duration
419419

420420

421-
@bundle_report_info_bindable.field("bundler_name")
421+
@bundle_report_info_bindable.field("bundlerName")
422422
def resolve_bundle_report_info_bundler_name(
423423
bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo
424424
) -> str:
425425
return bundle_report_info.bundler_name
426426

427427

428-
@bundle_report_info_bindable.field("bundler_version")
428+
@bundle_report_info_bindable.field("bundlerVersion")
429429
def resolve_bundle_report_info_bundler_version(
430430
bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo
431431
) -> str:

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ factory-boy
2020
fakeredis
2121
freezegun
2222
https://github.com/codecov/opentelem-python/archive/refs/tags/v0.0.4a1.tar.gz#egg=codecovopentelem
23-
https://github.com/codecov/shared/archive/c481846ba657aee3fc15a613a0fd2c18ac1eabd2.tar.gz#egg=shared
23+
https://github.com/codecov/shared/archive/00e90bb2085d3a54709328e9b3a39d578feb9992.tar.gz#egg=shared
2424
google-cloud-pubsub
2525
gunicorn>=22.0.0
2626
https://github.com/photocrowd/django-cursor-pagination/archive/f560902696b0c8509e4d95c10ba0d62700181d84.tar.gz

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ sentry-sdk[celery]==2.13.0
412412
# shared
413413
setproctitle==1.1.10
414414
# via -r requirements.in
415-
shared @ https://github.com/codecov/shared/archive/c481846ba657aee3fc15a613a0fd2c18ac1eabd2.tar.gz
415+
shared @ https://github.com/codecov/shared/archive/00e90bb2085d3a54709328e9b3a39d578feb9992.tar.gz
416416
# via -r requirements.in
417417
simplejson==3.17.2
418418
# via -r requirements.in

services/bundle_analysis.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ def modules(self) -> List[ModuleReport]:
242242
def module_extensions(self) -> List[str]:
243243
return list(set([module.extension for module in self.modules]))
244244

245+
@cached_property
246+
def routes(self) -> Optional[List[str]]:
247+
return self.asset.routes()
248+
245249

246250
@dataclass
247251
class BundleReport(object):
80 KB
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)