Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add bundle analysis report breakdown for a given commit #339

Merged
merged 6 commits into from
Jan 23, 2024

Conversation

JerrySentry
Copy link
Contributor

Purpose/Motivation

What is the feature? Why is this being done?

GQL: Add a resolver in Commit type, that gets the bundle report of the commit, that displays the total size of all the bundles and size of each individual bundle

Links to relevant tickets

codecov/engineering-team#1027

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@codecov-staging
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link

codecov-public-qa bot commented Jan 15, 2024

Codecov Report

Merging #339 (1de8399) into main (8ef71e7) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #339      +/-   ##
==========================================
+ Coverage   96.03%   96.05%   +0.01%     
==========================================
  Files         626      628       +2     
  Lines       16231    16307      +76     
==========================================
+ Hits        15588    15664      +76     
  Misses        643      643              
Flag Coverage Δ
unit 96.05% <100.00%> (+0.01%) ⬆️
unit-latest-uploader 96.05% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
graphql_api/dataloader/bundle_analysis.py 100.00% <100.00%> (ø)
graphql_api/types/__init__.py 100.00% <100.00%> (ø)
...aphql_api/types/bundle_analysis_report/__init__.py 100.00% <100.00%> (ø)
...s/bundle_analysis_report/bundle_analysis_report.py 100.00% <100.00%> (ø)
graphql_api/types/commit/commit.py 100.00% <100.00%> (ø)
services/bundle_analysis.py 100.00% <100.00%> (ø)

Impacted file tree graph

@codecov-qa
Copy link

codecov-qa bot commented Jan 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8ef71e7) 96.03% compared to head (1de8399) 96.05%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #339      +/-   ##
==========================================
+ Coverage   96.03%   96.05%   +0.01%     
==========================================
  Files         626      628       +2     
  Lines       16231    16307      +76     
==========================================
+ Hits        15588    15664      +76     
  Misses        643      643              
Flag Coverage Δ
unit 96.05% <100.00%> (+0.01%) ⬆️
unit-latest-uploader 96.05% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8ef71e7) 95.71% compared to head (1de8399) 95.73%.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #339     +/-   ##
=======================================
+ Coverage   95.71   95.73   +0.02     
=======================================
  Files        741     743      +2     
  Lines      16747   16823     +76     
=======================================
+ Hits       16028   16104     +76     
  Misses       719     719             
Flag Coverage Δ
unit 96.05% <100.00%> (+0.01%) ⬆️
unit-latest-uploader 96.05% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.



@bundle_analysis_report_bindable.field("sizeTotal")
def resolve_size_total(bundles_analysis_report: BundleAnalysisReport, info):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add return types for these resolvers pls?

return bundles_analysis_report.bundles


@bundle_report_bindable.field("name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wdyt about separating bundle analysis reports and bundles into their own folders? Rn they're similar but we could eventually make that difference more pronounced, so might make sense to separate that into different folders

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see there being an entry point into bundles without going through bundle analysis though. If/when that does come up in the future, we can separate it, but for now I think the bundle analysis report and bundle analysis comparison folders separation is intuitive.

@@ -160,6 +163,12 @@ def resolve_bundle_analysis_compare_with_parent(commit: Commit, info, **kwargs):
return load_bundle_analysis_comparison(base_commit, commit)


@commit_bindable.field("bundleAnalysisReport")
@sync_to_async
def resolve_bundle_analysis_report(commit: Commit, info, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also return type here please 😬

report_type=CommitReport.ReportType.BUNDLE_ANALYSIS, commit=commit
).first()
if report is None:
return MissingHeadReport()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this fn ever load a non-head report? Trying to see if it's better to say MissingReport as opposed of the head

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't appear like we have anything more suitable. FWIW we do use MissingHeadReport on non comparison like Commits.pathContents

self.report = report
self.report_bundles = []
self.total_size = 0
for bundle in self.report.bundle_reports():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO as we spoke previously:

  1. add functionality to calculate total BundleAnalysisReport size in shared
  2. rethink how to ensure we close/start all db connections in shared as well, fine here for now
  3. replace BundleReport to use the SharedBundleReport to avoid disconnect bw data here and data from shared

(could you make an issue capturing this when you get a chance please?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov/engineering-team#1067
codecov/engineering-team#1068

Yep will refactor this code next when tackling these two tickets.

@JerrySentry JerrySentry merged commit fd02145 into main Jan 23, 2024
22 checks passed
@JerrySentry JerrySentry deleted the api_1027 branch January 23, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants