diff --git a/graphql_api/tests/test_commit.py b/graphql_api/tests/test_commit.py index 50db27a7b8..c41177a627 100644 --- a/graphql_api/tests/test_commit.py +++ b/graphql_api/tests/test_commit.py @@ -3267,7 +3267,7 @@ def test_bundle_analysis_asset_routes(self, get_storage_service): ) with open( - "./services/tests/samples/bundle_with_assets_and_modules.sqlite", "rb" + "./services/tests/samples/bundle_with_asset_routes.sqlite", "rb" ) as f: storage_path = StoragePaths.bundle_report.path( repo_key=ArchiveService.get_archive_hash(self.repo), @@ -3285,8 +3285,8 @@ def test_bundle_analysis_asset_routes(self, get_storage_service): bundleAnalysisReport { __typename ... on BundleAnalysisReport { - bundle(name: "b5") { - asset(name: "assets/LazyComponent-fcbb0922.js") { + bundle(name: "@codecov/example-sveltekit-app-client-esm") { + assets { name normalizedName routes @@ -3310,18 +3310,151 @@ def test_bundle_analysis_asset_routes(self, get_storage_service): data = self.gql_request(query, variables=variables) commit = data["owner"]["repository"]["commit"] - asset_report = commit["bundleAnalysis"]["bundleAnalysisReport"]["bundle"][ - "asset" + asset_reports = commit["bundleAnalysis"]["bundleAnalysisReport"]["bundle"][ + "assets" ] - assert asset_report is not None - assert asset_report["name"] == "assets/LazyComponent-fcbb0922.js" - assert asset_report["normalizedName"] == "assets/LazyComponent-*.js" - assert asset_report["routes"] == [ - "/", - "/about", - "/login", - "/super/long/url/path", + assert asset_reports == [ + { + "name": "_app/immutable/assets/svelte-welcome.VNiyy3gC.png", + "normalizedName": "_app/immutable/assets/svelte-welcome.*.png", + "routes": [], + }, + { + "name": "_app/immutable/assets/svelte-welcome.0pIiHnVF.webp", + "normalizedName": "_app/immutable/assets/svelte-welcome.*.webp", + "routes": [], + }, + { + "name": "_app/immutable/assets/fira-mono-all-400-normal.B2mvLtSD.woff", + "normalizedName": "_app/immutable/assets/fira-mono-all-400-normal.*.woff", + "routes": [], + }, + { + "name": "_app/immutable/chunks/entry.BaWB2kHj.js", + "normalizedName": "_app/immutable/chunks/entry.*.js", + "routes": [], + }, + { + "name": "_app/immutable/nodes/4.CcjRtXvw.js", + "normalizedName": "_app/immutable/nodes/4.*.js", + "routes": ["/sverdle"], + }, + { + "name": "_app/immutable/assets/fira-mono-latin-400-normal.DKjLVgQi.woff2", + "normalizedName": "_app/immutable/assets/fira-mono-latin-400-normal.*.woff2", + "routes": [], + }, + { + "name": "_app/immutable/assets/fira-mono-cyrillic-ext-400-normal.B04YIrm4.woff2", + "normalizedName": "_app/immutable/assets/fira-mono-cyrillic-ext-400-normal.*.woff2", + "routes": [], + }, + { + "name": "_app/immutable/assets/fira-mono-latin-ext-400-normal.D6XfiR-_.woff2", + "normalizedName": "_app/immutable/assets/fira-mono-latin-ext-400-normal.D6XfiR-_.woff2", + "routes": [], + }, + { + "name": "_app/immutable/assets/fira-mono-greek-400-normal.C3zng6O6.woff2", + "normalizedName": "_app/immutable/assets/fira-mono-greek-400-normal.*.woff2", + "routes": [], + }, + { + "name": "_app/immutable/assets/fira-mono-cyrillic-400-normal.36-45Uyg.woff2", + "normalizedName": "_app/immutable/assets/fira-mono-cyrillic-400-normal.*.woff2", + "routes": [], + }, + { + "name": "_app/immutable/nodes/0.CL_S-12h.js", + "normalizedName": "_app/immutable/nodes/0.CL_S-12h.js", + "routes": ["/"], + }, + { + "name": "_app/immutable/assets/fira-mono-greek-ext-400-normal.CsqI23CO.woff2", + "normalizedName": "_app/immutable/assets/fira-mono-greek-ext-400-normal.*.woff2", + "routes": [], + }, + { + "name": "_app/immutable/chunks/index.DDRweiI9.js", + "normalizedName": "_app/immutable/chunks/index.*.js", + "routes": [], + }, + { + "name": "_app/immutable/entry/app.Dd9ByE1Q.js", + "normalizedName": "_app/immutable/entry/app.*.js", + "routes": [], + }, + { + "name": "_app/immutable/nodes/2.BMQFqo-e.js", + "normalizedName": "_app/immutable/nodes/2.*.js", + "routes": ["/"], + }, + { + "name": "_app/immutable/assets/0.CT0x_Q5c.css", + "normalizedName": "_app/immutable/assets/0.CT0x_Q5c.css", + "routes": [], + }, + { + "name": "_app/immutable/assets/4.DOkkq0IA.css", + "normalizedName": "_app/immutable/assets/4.*.css", + "routes": [], + }, + { + "name": "_app/immutable/nodes/5.CwxmUzn6.js", + "normalizedName": "_app/immutable/nodes/5.*.js", + "routes": ["/sverdle/how-to-play"], + }, + { + "name": "_app/immutable/chunks/scheduler.Dk-snqIU.js", + "normalizedName": "_app/immutable/chunks/scheduler.*.js", + "routes": [], + }, + { + "name": "_app/immutable/nodes/3.BqQOub2U.js", + "normalizedName": "_app/immutable/nodes/3.*.js", + "routes": ["/about"], + }, + { + "name": "_app/immutable/assets/2.Cs8KR-Bb.css", + "normalizedName": "_app/immutable/assets/2.*.css", + "routes": [], + }, + { + "name": "_app/immutable/nodes/1.stWWSe4n.js", + "normalizedName": "_app/immutable/nodes/1.*.js", + "routes": [], + }, + { + "name": "_app/immutable/assets/5.CU6psp88.css", + "normalizedName": "_app/immutable/assets/5.*.css", + "routes": [], + }, + { + "name": "_app/immutable/chunks/index.Ice1EKvx.js", + "normalizedName": "_app/immutable/chunks/index.*.js", + "routes": [], + }, + { + "name": "_app/immutable/chunks/stores.BrqGIpx3.js", + "normalizedName": "_app/immutable/chunks/stores.*.js", + "routes": [], + }, + { + "name": "_app/immutable/entry/start.B1Q1eB84.js", + "normalizedName": "_app/immutable/entry/start.*.js", + "routes": [], + }, + { + "name": "_app/immutable/chunks/index.R8ovVqwX.js", + "normalizedName": "_app/immutable/chunks/index.*.js", + "routes": [], + }, + { + "name": "_app/version.json", + "normalizedName": "_app/version.json", + "routes": [], + }, ] @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service") @@ -3355,12 +3488,12 @@ def test_bundle_analysis_report_info(self, get_storage_service): bundle(name: "b5") { info { version - plugin_name - plugin_version - built_at + pluginName + pluginVersion + builtAt duration - bundler_name - bundler_version + bundlerName + bundlerVersion } } } @@ -3384,9 +3517,9 @@ def test_bundle_analysis_report_info(self, get_storage_service): bundle_info = commit["bundleAnalysis"]["bundleAnalysisReport"]["bundle"]["info"] assert bundle_info["version"] == "1" - assert bundle_info["plugin_name"] == "codecov-vite-bundle-analysis-plugin" - assert bundle_info["plugin_version"] == "1.0.0" - assert bundle_info["built_at"] == "2023-12-01 17:17:28.604000" + assert bundle_info["pluginName"] == "codecov-vite-bundle-analysis-plugin" + assert bundle_info["pluginVersion"] == "1.0.0" + assert bundle_info["builtAt"] == "2023-12-01 17:17:28.604000" assert bundle_info["duration"] == 331 - assert bundle_info["bundler_name"] == "rollup" - assert bundle_info["bundler_version"] == "3.29.4" + assert bundle_info["bundlerName"] == "rollup" + assert bundle_info["bundlerVersion"] == "3.29.4" diff --git a/graphql_api/types/bundle_analysis/base.graphql b/graphql_api/types/bundle_analysis/base.graphql index 31cdedd780..6bbe8f40af 100644 --- a/graphql_api/types/bundle_analysis/base.graphql +++ b/graphql_api/types/bundle_analysis/base.graphql @@ -60,12 +60,12 @@ type BundleAsset { type BundleReportInfo { version: String! - plugin_name: String! - plugin_version: String! - built_at: String! + pluginName: String! + pluginVersion: String! + builtAt: String! duration: Int! - bundler_name: String! - bundler_version: String! + bundlerName: String! + bundlerVersion: String! } type BundleReport { diff --git a/graphql_api/types/bundle_analysis/base.py b/graphql_api/types/bundle_analysis/base.py index 6617fb39aa..2c4b29431e 100644 --- a/graphql_api/types/bundle_analysis/base.py +++ b/graphql_api/types/bundle_analysis/base.py @@ -164,7 +164,7 @@ def resolve_asset_report_measurements( def resolve_routes( bundle_asset: AssetReport, info: GraphQLResolveInfo ) -> Optional[List[str]]: - return ["/", "/about", "/login", "/super/long/url/path"] + return bundle_asset.routes # ============= Bundle Report Bindable ============= @@ -390,21 +390,21 @@ def resolve_bundle_report_info_version( return bundle_report_info.version -@bundle_report_info_bindable.field("plugin_name") +@bundle_report_info_bindable.field("pluginName") def resolve_bundle_report_info_plugin_name( bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo ) -> str: return bundle_report_info.plugin_name -@bundle_report_info_bindable.field("plugin_version") +@bundle_report_info_bindable.field("pluginVersion") def resolve_bundle_report_info_plugin_version( bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo ) -> str: return bundle_report_info.plugin_version -@bundle_report_info_bindable.field("built_at") +@bundle_report_info_bindable.field("builtAt") def resolve_bundle_report_info_built_at( bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo ) -> str: @@ -418,14 +418,14 @@ def resolve_bundle_report_info_duration( return bundle_report_info.duration -@bundle_report_info_bindable.field("bundler_name") +@bundle_report_info_bindable.field("bundlerName") def resolve_bundle_report_info_bundler_name( bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo ) -> str: return bundle_report_info.bundler_name -@bundle_report_info_bindable.field("bundler_version") +@bundle_report_info_bindable.field("bundlerVersion") def resolve_bundle_report_info_bundler_version( bundle_report_info: BundleReportInfo, info: GraphQLResolveInfo ) -> str: diff --git a/requirements.in b/requirements.in index 1e345b46a5..a7f9d71a15 100644 --- a/requirements.in +++ b/requirements.in @@ -20,7 +20,7 @@ factory-boy fakeredis freezegun https://github.com/codecov/opentelem-python/archive/refs/tags/v0.0.4a1.tar.gz#egg=codecovopentelem -https://github.com/codecov/shared/archive/c481846ba657aee3fc15a613a0fd2c18ac1eabd2.tar.gz#egg=shared +https://github.com/codecov/shared/archive/00e90bb2085d3a54709328e9b3a39d578feb9992.tar.gz#egg=shared google-cloud-pubsub gunicorn>=22.0.0 https://github.com/photocrowd/django-cursor-pagination/archive/f560902696b0c8509e4d95c10ba0d62700181d84.tar.gz diff --git a/requirements.txt b/requirements.txt index d8bdc0b42b..25fdbff72e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -412,7 +412,7 @@ sentry-sdk[celery]==2.13.0 # shared setproctitle==1.1.10 # via -r requirements.in -shared @ https://github.com/codecov/shared/archive/c481846ba657aee3fc15a613a0fd2c18ac1eabd2.tar.gz +shared @ https://github.com/codecov/shared/archive/00e90bb2085d3a54709328e9b3a39d578feb9992.tar.gz # via -r requirements.in simplejson==3.17.2 # via -r requirements.in diff --git a/services/bundle_analysis.py b/services/bundle_analysis.py index 0feaa66a40..a1dd751618 100644 --- a/services/bundle_analysis.py +++ b/services/bundle_analysis.py @@ -242,6 +242,10 @@ def modules(self) -> List[ModuleReport]: def module_extensions(self) -> List[str]: return list(set([module.extension for module in self.modules])) + @cached_property + def routes(self) -> Optional[List[str]]: + return self.asset.routes() + @dataclass class BundleReport(object): diff --git a/services/tests/samples/bundle_with_asset_routes.sqlite b/services/tests/samples/bundle_with_asset_routes.sqlite new file mode 100644 index 0000000000..3ca73ee44d Binary files /dev/null and b/services/tests/samples/bundle_with_asset_routes.sqlite differ diff --git a/services/tests/samples/head_bundle_report.sqlite b/services/tests/samples/head_bundle_report.sqlite index a56a92bbf3..787dc78853 100644 Binary files a/services/tests/samples/head_bundle_report.sqlite and b/services/tests/samples/head_bundle_report.sqlite differ