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

Bundle Analysis: Display comparison for file paths on PR comments #952

Merged
merged 10 commits into from
Dec 17, 2024

Conversation

JerrySentry
Copy link
Contributor

@JerrySentry JerrySentry commented Dec 6, 2024

Looks like this

Screenshot 2024-12-10 at 12 28 57 PM

codecov/engineering-team#3031

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.

Copy link

github-actions bot commented Dec 6, 2024

This PR includes changes to shared. Please review them here: codecov/shared@8c5de3f...2262286

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.98%. Comparing base (6b72a1c) to head (c622488).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #952      +/-   ##
==========================================
- Coverage   97.99%   97.98%   -0.01%     
==========================================
  Files         443      443              
  Lines       35793    35823      +30     
==========================================
+ Hits        35075    35102      +27     
- Misses        718      721       +3     
Flag Coverage Δ
integration 42.17% <29.03%> (-0.02%) ⬇️
unit 90.63% <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.

@codecov-notifications
Copy link

codecov-notifications bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link

github-actions bot commented Dec 6, 2024

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

requirements.in Outdated
@@ -1,5 +1,5 @@
https://github.com/codecov/test-results-parser/archive/c840502d1b4dd7d05b2efc2c1328affaf2acd27c.tar.gz#egg=test-results-parser
https://github.com/codecov/shared/archive/8c5de3fadd3c987304043c6cfd64864f372d674f.tar.gz#egg=shared
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be updated once shared PR is merged.

@JerrySentry JerrySentry marked this pull request as ready for review December 6, 2024 22:54
@@ -184,3 +197,46 @@ def _create_bundle_rows(
)

return bundle_rows

def _create_bundle_route_data(
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we use this computation/stats elsewhere in the code, like in GQL for example? In case it makes sense for this to live in Shared

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, these computations are really for PR comments as it figures out the icons to use and how to display the size (eg bytes, MB, etc). On the app side these are taken care of by gazebo

Copy link
Contributor

@adrian-codecov adrian-codecov left a comment

Choose a reason for hiding this comment

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

Lgtm!

@codecov-qa
Copy link

codecov-qa bot commented Dec 11, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1662 1 1661 1
View the top 1 failed tests by shortest run time
services/bundle_analysis/notify/messages/tests/test_comment.py::TestCommentMesage::test_build_message_from_samples
Stack Traces | 0.811s run time
self = <worker.services.bundle_analysis.notify.messages.tests.test_comment.TestCommentMesage object at 0x7fc36f7060f0>
dbsession = <sqlalchemy.orm.session.Session object at 0x7fc35d7ba6f0>
mocker = <pytest_mock.plugin.MockFixture object at 0x7fc35d888110>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7fc35e656840>

    def test_build_message_from_samples(self, dbsession, mocker, mock_storage):
        head_commit, base_commit = get_commit_pair(dbsession)
        repository = head_commit.repository
        head_commit_report, base_commit_report = get_report_pair(
            dbsession, (head_commit, base_commit)
        )
        save_mock_bundle_analysis_report(
            repository, head_commit_report, mock_storage, sample_report_number=2
        )
        save_mock_bundle_analysis_report(
            repository, base_commit_report, mock_storage, sample_report_number=1
        )
        enriched_pull = get_enriched_pull_setting_up_mocks(
            dbsession, mocker, (head_commit, base_commit)
        )
        user_yaml = UserYaml.from_dict(PATCH_CENTRIC_DEFAULT_CONFIG)
        builder = BundleAnalysisPRCommentContextBuilder().initialize(
            head_commit, user_yaml, GITHUB_APP_INSTALLATION_DEFAULT_NAME
        )
    
        context = builder.build_context().get_result()
>       message = BundleAnalysisCommentMarkdownStrategy().build_message(context)

.../messages/tests/test_comment.py:53: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../notify/messages/comment.py:70: in build_message
    return self.build_default_message(context)
.../local/lib/python3.12........./site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
.../notify/messages/comment.py:82: in build_default_message
    bundle_route_data = self._create_bundle_route_data(
.../notify/messages/comment.py:209: in _create_bundle_route_data
    changes_dict = comparison.bundle_routes_changes()
.../local/lib/python3.12........./site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
.../local/lib/python3.12.../shared/bundle_analysis/comparison.py:417: in bundle_routes_changes
    ).size_changes()
.../local/lib/python3.12........./site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <shared.bundle_analysis.comparison.BundleRoutesComparison object at 0x7fc35e390bc0>

    @sentry_sdk.trace
    def size_changes(self) -> List[RouteChange]:
        """
        Returns a list of changes for each unique route that exists between the base and head.
        If a route exists on base but not head that is considered "removed" and -100% percentage delta
        If a route exists on head but not base that is considered "added" and +100% percentage delta
        Otherwise it is considered "changed" and percentage delta = (diff_size / base_size) * 100
        """
        base_sizes = self.base_report.get_sizes()
>       head_sizes = self.head_report.get_sizes()
E       AttributeError: 'NoneType' object has no attribute 'get_sizes'

.../local/lib/python3.12.../shared/bundle_analysis/comparison.py:215: AttributeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1662 1 1661 1
View the top 1 failed tests by shortest run time
services/bundle_analysis/notify/messages/tests/test_comment.py::TestCommentMesage::test_build_message_from_samples
Stack Traces | 0.811s run time
self = <worker.services.bundle_analysis.notify.messages.tests.test_comment.TestCommentMesage object at 0x7fc36f7060f0>
dbsession = <sqlalchemy.orm.session.Session object at 0x7fc35d7ba6f0>
mocker = <pytest_mock.plugin.MockFixture object at 0x7fc35d888110>
mock_storage = <shared.storage.memory.MemoryStorageService object at 0x7fc35e656840>

    def test_build_message_from_samples(self, dbsession, mocker, mock_storage):
        head_commit, base_commit = get_commit_pair(dbsession)
        repository = head_commit.repository
        head_commit_report, base_commit_report = get_report_pair(
            dbsession, (head_commit, base_commit)
        )
        save_mock_bundle_analysis_report(
            repository, head_commit_report, mock_storage, sample_report_number=2
        )
        save_mock_bundle_analysis_report(
            repository, base_commit_report, mock_storage, sample_report_number=1
        )
        enriched_pull = get_enriched_pull_setting_up_mocks(
            dbsession, mocker, (head_commit, base_commit)
        )
        user_yaml = UserYaml.from_dict(PATCH_CENTRIC_DEFAULT_CONFIG)
        builder = BundleAnalysisPRCommentContextBuilder().initialize(
            head_commit, user_yaml, GITHUB_APP_INSTALLATION_DEFAULT_NAME
        )
    
        context = builder.build_context().get_result()
>       message = BundleAnalysisCommentMarkdownStrategy().build_message(context)

.../messages/tests/test_comment.py:53: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../notify/messages/comment.py:70: in build_message
    return self.build_default_message(context)
.../local/lib/python3.12........./site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
.../notify/messages/comment.py:82: in build_default_message
    bundle_route_data = self._create_bundle_route_data(
.../notify/messages/comment.py:209: in _create_bundle_route_data
    changes_dict = comparison.bundle_routes_changes()
.../local/lib/python3.12........./site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
.../local/lib/python3.12.../shared/bundle_analysis/comparison.py:417: in bundle_routes_changes
    ).size_changes()
.../local/lib/python3.12........./site-packages/sentry_sdk/tracing_utils.py:673: in func_with_tracing
    return func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <shared.bundle_analysis.comparison.BundleRoutesComparison object at 0x7fc35e390bc0>

    @sentry_sdk.trace
    def size_changes(self) -> List[RouteChange]:
        """
        Returns a list of changes for each unique route that exists between the base and head.
        If a route exists on base but not head that is considered "removed" and -100% percentage delta
        If a route exists on head but not base that is considered "added" and +100% percentage delta
        Otherwise it is considered "changed" and percentage delta = (diff_size / base_size) * 100
        """
        base_sizes = self.base_report.get_sizes()
>       head_sizes = self.head_report.get_sizes()
E       AttributeError: 'NoneType' object has no attribute 'get_sizes'

.../local/lib/python3.12.../shared/bundle_analysis/comparison.py:215: AttributeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@JerrySentry JerrySentry added this pull request to the merge queue Dec 17, 2024
Merged via the queue into main with commit 2904ca0 Dec 17, 2024
20 of 27 checks passed
@JerrySentry JerrySentry deleted the dec_06_ba_pr_comment branch December 17, 2024 16:20
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