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: compare with stored compareSha if applicable #754

Merged
merged 6 commits into from
Aug 22, 2024

Conversation

JerrySentry
Copy link
Contributor

@JerrySentry JerrySentry commented Aug 15, 2024

When doing a comparison, try to find the base commit of the head commit based on the stored custom compareSha in the bundle report first, if not found default back to using commit.parent.

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.

requirements.in Outdated
@@ -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/1482593343604028ffee5902da080696eb8c14d4.tar.gz#egg=shared
https://github.com/codecov/shared/archive/c2dc0c175fcd0d0040083a85c4b7d4a3b796e7cd.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 commit is merged to main

@JerrySentry JerrySentry marked this pull request as ready for review August 15, 2024 22:05
@JerrySentry JerrySentry requested a review from a team as a code owner August 15, 2024 22:05
@codecov-staging
Copy link

codecov-staging bot commented Aug 15, 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!

@codecov-qa
Copy link

codecov-qa bot commented Aug 15, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2263 1 2262 6
View the top 1 failed tests by shortest run time
graphql_api.tests.test_commit.TestCommit�test_bundle_analysis_compare_with_compare_sha
Stack Traces | 0.335s run time
self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_compare_with_compare_sha>
get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139805424024272'>

@patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
def test_bundle_analysis_compare_with_compare_sha(self, get_storage_service):
"""
This tests creates 3 commits C1 -> C2 -> C3
C1 uses Report1, C2 and C3 uses Report2
Normally when doing a compare of C3, it would select C2 as its parent
then it would show no change, as expected
However the difference is that in C3's Report2 it has the compareSha set to C1.commitid
Now when doing comparison of C3, it would now select C1 as the parent
therefore show correct comparison in numbers between Report1 and Report2
"""
storage = MemoryStorageService({})
get_storage_service.return_value = storage

commit_1 = CommitFactory(
repository=self.repo,
commitid="6ca727b0142bf5625bb82af2555d308862063222",
)
commit_2 = CommitFactory(
repository=self.repo, parent_commit_id=commit_1.commitid
)
commit_3 = CommitFactory(
repository=self.repo, parent_commit_id=commit_2.commitid
)

commit_report_1 = CommitReportFactory(
commit=commit_1,
report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
)

commit_report_2 = CommitReportFactory(
commit=commit_2,
report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
)

commit_report_3 = CommitReportFactory(
commit=commit_3,
report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
)

with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
storage_path = StoragePaths.bundle_report.path(
repo_key=ArchiveService.get_archive_hash(self.repo),
report_key=commit_report_1.external_id,
)
storage.write_file(get_bucket_name(), storage_path, f)

with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
storage_path = StoragePaths.bundle_report.path(
repo_key=ArchiveService.get_archive_hash(self.repo),
report_key=commit_report_2.external_id,
)
storage.write_file(get_bucket_name(), storage_path, f)

> with open(
"..../tests/samples/head_bundle_report_with_compare_sha_6ca727b0142bf5625bb82af2555d308862063222.sqlite",
"rb",
) as f:
E FileNotFoundError: [Errno 2] No such file or directory: '..../tests/samples/head_bundle_report_with_compare_sha_6ca727b0142bf5625bb82af2555d308862063222.sqlite'

graphql_api/tests/test_commit.py:950: FileNotFoundError

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Copy link

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

❌ Failed Test Results:

Completed 2269 tests with 1 failed, 2262 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: graphql_api.tests.test_commit.TestCommit
    Test name: test_bundle_analysis_compare_with_compare_sha

    self = <graphql_api.tests.test_commit.TestCommit testMethod=test_bundle_analysis_compare_with_compare_sha>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139805424024272'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_compare_with_compare_sha(self, get_storage_service):
    """
    This tests creates 3 commits C1 -> C2 -> C3
    C1 uses Report1, C2 and C3 uses Report2
    Normally when doing a compare of C3, it would select C2 as its parent
    then it would show no change, as expected
    However the difference is that in C3's Report2 it has the compareSha set to C1.commitid
    Now when doing comparison of C3, it would now select C1 as the parent
    therefore show correct comparison in numbers between Report1 and Report2
    """
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    commit_1 = CommitFactory(
    repository=self.repo,
    commitid="6ca727b0142bf5625bb82af2555d308862063222",
    )
    commit_2 = CommitFactory(
    repository=self.repo, parent_commit_id=commit_1.commitid
    )
    commit_3 = CommitFactory(
    repository=self.repo, parent_commit_id=commit_2.commitid
    )

    commit_report_1 = CommitReportFactory(
    commit=commit_1,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )

    commit_report_2 = CommitReportFactory(
    commit=commit_2,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )

    commit_report_3 = CommitReportFactory(
    commit=commit_3,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=commit_report_1.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=commit_report_2.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    > with open(
    "..../tests/samples/head_bundle_report_with_compare_sha_6ca727b0142bf5625bb82af2555d308862063222.sqlite",
    "rb",
    ) as f:
    E FileNotFoundError: [Errno 2] No such file or directory: '..../tests/samples/head_bundle_report_with_compare_sha_6ca727b0142bf5625bb82af2555d308862063222.sqlite'

    graphql_api/tests/test_commit.py:950: FileNotFoundError

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.16%. Comparing base (c84212a) to head (baf0eff).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##               main       #754   +/-   ##
===========================================
  Coverage   96.16000   96.16000           
===========================================
  Files           814        814           
  Lines         18424      18425    +1     
===========================================
+ Hits          17717      17718    +1     
  Misses          707        707           
Flag Coverage Δ
unit 91.91% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 91.91% <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.

@@ -107,8 +107,12 @@ def resolve_bundle_analysis_compare_with_base(
head_commit_sha = pull.head if pull.head else pull.compared_to

bundle_analysis_comparison = load_bundle_analysis_comparison(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This never had a filter by repo ugh.

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

Once we finish the coding side of things, it might be useful documenting this with some diagrams or something so that it's pretty clear how the BA comparison logic would differ from the coverage logic.

@JerrySentry JerrySentry added this pull request to the merge queue Aug 22, 2024
Merged via the queue into main with commit f460e8d Aug 22, 2024
18 checks passed
@JerrySentry JerrySentry deleted the aug_15_pcm_comp branch August 22, 2024 16:43
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