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: get repo service for specific commit #479

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

giovanni-guidini
Copy link
Contributor

@giovanni-guidini giovanni-guidini commented May 31, 2024

Change the repository service so we have a function that
checks whether a commit has been pinned to a specific app
and returns the TorngitAdapter with said app.

Note on services.repository._is_repo_using_integration: this function has become effectively obsolete since the introduction of get_adapter_auth_information because we can tell if we are using the installation by the presence of "installation_info" or not.

👀 This is PR 3/4 in the pinning commits to apps endeavour

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.

@giovanni-guidini giovanni-guidini requested a review from a team May 31, 2024 08:35
@codecov-notifications
Copy link

codecov-notifications bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #479   +/-   ##
=======================================
  Coverage   97.26%   97.26%           
=======================================
  Files         412      412           
  Lines       34187    34150   -37     
=======================================
- Hits        33252    33217   -35     
+ Misses        935      933    -2     
Flag Coverage Δ
integration 97.26% <100.00%> (+<0.01%) ⬆️
latest-uploader-overall 97.26% <100.00%> (+<0.01%) ⬆️
unit 97.26% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 94.37% <100.00%> (-0.01%) ⬇️
OutsideTasks 97.52% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
services/github.py 94.73% <100.00%> (+0.29%) ⬆️
services/repository.py 96.29% <100.00%> (+0.08%) ⬆️
services/tests/test_github.py 100.00% <100.00%> (ø)
services/tests/test_repository_service.py 99.77% <100.00%> (+<0.01%) ⬆️

... and 4 files with indirect coverage changes

@codecov-qa
Copy link

codecov-qa bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.26%. Comparing base (4a0347d) to head (c72b550).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #479   +/-   ##
=======================================
  Coverage   97.26%   97.26%           
=======================================
  Files         412      412           
  Lines       34187    34150   -37     
=======================================
- Hits        33252    33217   -35     
+ Misses        935      933    -2     
Flag Coverage Δ
integration 97.26% <100.00%> (+<0.01%) ⬆️
latest-uploader-overall 97.26% <100.00%> (+<0.01%) ⬆️
unit 97.26% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 94.37% <100.00%> (-0.01%) ⬇️
OutsideTasks 97.52% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
services/github.py 94.73% <100.00%> (+0.29%) ⬆️
services/repository.py 96.29% <100.00%> (+0.08%) ⬆️
services/tests/test_github.py 100.00% <100.00%> (ø)
services/tests/test_repository_service.py 99.77% <100.00%> (+<0.01%) ⬆️

... and 4 files with indirect coverage changes

Copy link

codecov-public-qa bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.26%. Comparing base (4a0347d) to head (c72b550).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #479   +/-   ##
=======================================
  Coverage   97.26%   97.26%           
=======================================
  Files         412      412           
  Lines       34187    34150   -37     
=======================================
- Hits        33252    33217   -35     
+ Misses        935      933    -2     
Flag Coverage Δ
integration 97.26% <100.00%> (+<0.01%) ⬆️
latest-uploader-overall 97.26% <100.00%> (+<0.01%) ⬆️
unit 97.26% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 94.37% <100.00%> (-0.01%) ⬇️
OutsideTasks 97.52% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
services/github.py 94.73% <100.00%> (+0.29%) ⬆️
services/repository.py 96.29% <100.00%> (+0.08%) ⬆️
services/tests/test_github.py 100.00% <100.00%> (ø)
services/tests/test_repository_service.py 99.77% <100.00%> (+<0.01%) ⬆️

... and 4 files with indirect coverage changes

Copy link

codecov bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.30%. Comparing base (4a0347d) to head (c72b550).
Report is 1 commits behind head on main.

Changes have been made to critical files, which contain lines commonly executed in production. Learn more

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #479      +/-   ##
==========================================
+ Coverage   97.29%   97.30%   +0.01%     
==========================================
  Files         443      443              
  Lines       34916    35102     +186     
==========================================
+ Hits        33972    34157     +185     
- Misses        944      945       +1     
Flag Coverage Δ
integration 97.26% <100.00%> (+<0.01%) ⬆️
latest-uploader-overall 97.26% <100.00%> (+<0.01%) ⬆️
unit 97.26% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 94.44% <100.00%> (+<0.01%) ⬆️
OutsideTasks 97.52% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
services/github.py 100.00% <100.00%> (ø)
services/repository.py Critical 96.29% <100.00%> (+0.08%) ⬆️
services/tests/test_github.py 100.00% <100.00%> (ø)
services/tests/test_repository_service.py 99.77% <100.00%> (+<0.01%) ⬆️

... and 4 files with indirect coverage changes

Related Entrypoints
run/app.tasks.upload.Upload
run/app.tasks.status.SetError
run/app.tasks.notify.Notify
run/app.tasks.pulls.Sync
run/app.tasks.compute_comparison.ComputeComparison
run/app.tasks.upload.UploadFinisher
run/app.tasks.upload.UploadProcessor
run/app.tasks.commit_update.CommitUpdate
run/app.tasks.upload.PreProcessUpload
run/app.tasks.bundle_analysis.BundleAnalysisNotify
run/app.tasks.test_results.TestResultsFinisherTask
run/app.tasks.sync_repo_languages.SyncLanguages
run/app.tasks.label_analysis.process_request

@giovanni-guidini giovanni-guidini force-pushed the gio/pin-commits/repo-service-for-commit branch from ccc968c to 1ed190e Compare May 31, 2024 09:15
Change the repository service so we have a function that
checks whether a commit has been pinned to a specific app
and returns the TorngitAdapter with said app.
@giovanni-guidini giovanni-guidini force-pushed the gio/pin-commits/repo-service-for-commit branch from 1ed190e to b8dcb6f Compare May 31, 2024 12:30
if installation_for_commit is None:
return get_repo_provider_service(repository, fallback_installation_name)

ghapp_details = get_specific_github_app_details(
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the logic inside here,

, can you still use your app ifit is not configured?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nop

Copy link
Contributor

@michelletran-codecov michelletran-codecov left a comment

Choose a reason for hiding this comment

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

Generally LGTM. I'm a bit confused/concerned about all the GitHub specific stuff in the repository, but it appears that other functions in that file is referring to GitHub specific stuff, so I'll let it go. Just a few comments/questions.

commit: Commit,
fallback_installation_name: str = GITHUB_APP_INSTALLATION_DEFAULT_NAME,
) -> torngit.base.TorngitBaseAdapter:
"""Gets a Torngit adapter (potentially) using a specific github app as the authentication source.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Gets a Torngit adapter (potentially) using a specific github app as the authentication source.
"""Gets a Torngit adapter (potentially) using a specific GitHub app as the authentication source.

@@ -65,7 +97,9 @@ def get_repo_provider_service(
data = TorngitInstanceData(
repo=RepoInfo(
name=repository.name,
using_integration=_is_repo_using_integration(repository),
using_integration=(
adapter_auth_info["selected_installation_info"] is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

This will raise a KeyError if selected_installation_info is not found. If we don't want to error, then adapter_auth_info.get("selected_installation_info") is safer.

if installation_for_commit is None:
return get_repo_provider_service(repository, fallback_installation_name)

ghapp_details = get_specific_github_app_details(
Copy link
Contributor

Choose a reason for hiding this comment

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

We do a check in get_repo_provider_service to ensure that the repo is a GitHub repo. Should we do a check here as well? This will save us a database read to the GitHub App Installation table I think.

In fact, many parts of this function is GitHub specific... can we skip some more steps below if it's not a GitHub commit?

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 check is in get_github_app_for_commit.

From the docstring: "If the commit doesn't have a particular app assigned to it, return regular get_repo_provider_service choice".
Because apps only exist for GitHub it follows that only if it's a GitHub repo the code would get to this point.

@giovanni-guidini giovanni-guidini added this pull request to the merge queue Jun 3, 2024
Merged via the queue into main with commit 2ff1c1d Jun 3, 2024
29 of 30 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/pin-commits/repo-service-for-commit branch June 3, 2024 10:19
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.

None yet

3 participants