-
Notifications
You must be signed in to change notification settings - Fork 28
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: use GithubAppInstallation in api #347
Conversation
32cbe7e
to
e0cb312
Compare
1488a57
to
ed1f9b3
Compare
e0cb312
to
a58ea09
Compare
0cb80ca
to
643a512
Compare
643a512
to
01dfbb9
Compare
Codecov ReportAttention:
Changes have been made to critical files, which contain lines commonly executed in production. Learn more
Additional details and impacted files@@ Coverage Diff @@
## main #347 +/- ##
=======================================
+ Coverage 95.71 95.74 +0.03
=======================================
Files 740 740
Lines 16720 16847 +127
=======================================
+ Hits 16002 16129 +127
Misses 718 718
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
cbf7ebe
to
7ec5900
Compare
Codecov ReportAttention:
📢 Thoughts on this report? Let us know! |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #347 +/- ##
=======================================
Coverage 96.05% 96.06%
=======================================
Files 628 628
Lines 16307 16357 +50
=======================================
+ Hits 15664 15713 +49
- Misses 643 644 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov Report
@@ Coverage Diff @@
## main #347 +/- ##
=======================================
Coverage 96.05% 96.06%
=======================================
Files 628 628
Lines 16307 16357 +50
=======================================
+ Hits 15664 15713 +49
- Misses 643 644 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
7ec5900
to
9e31fbe
Compare
Uses the gh app installation WITHOUT compromising the old usage (of `owner.integration_id`). Deprecated paths are marked so. These changes don't backfill old data, but start using the new model with webhooks. the sample data from tests (the keys) are taken from [github docs](https://docs.github.com/en/webhooks/webhook-events-and-payloads#installation) and some amount of empirical data. depends on: #346
9e31fbe
to
e2d2c92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments, otherwise lgtm
@@ -315,20 +322,45 @@ def determine_upload_pr_to_use(upload_params): | |||
return upload_params.get("pr") | |||
|
|||
|
|||
def ghapp_installation_id_to_use(repository: Repository) -> Optional[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm debating if it makes sense to keep this fn here or if it makes sense to add it to the GithubAppInstallation as a method there, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this code should live as a method of GithubAppInstallation
.
I think there's enough logic not related to GithubAppInstallation
to leave it as is.
Plus in the future we might use this function to house logic to pick one GithubAppInstallation
out of many that a user might have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me! Tyty
Considers ghapp installations when deciding if a torngit adapter is for a repo with integration or not. If a ghapp installation exist then repo is considered to be using integration if it's covered by the installation. Otherwise previous behavior is used. The test `test_get_adapter_sets_token_to_bot_when_user_not_authenticated` includes `owner` as `None` when calling `RepoProviderService.get_adapter` so I'm assuming that can happen, and changing the typehint in the function. Other functions that were typehinted with `Owner` instead of `Optional[Owner]` are also changed.
This reverts commit 86178ba. This commit caused auth issues with `/graphql` endpoint in which users were not authenticated and couldn't see source code. Revertign for now while we figure out the exact issue and fix it.
* Revert "Revert "feat: use GithubAppInstallation in api (#347)" (#355)" This reverts commit 226f73d. * fix: logged in users can't see coverage bug This bug caused a little incident in Codecov. The actual issue is that we can't make DB queries syncronously from an async context. When getting the file content we have to get an adapter, and that - since the GithubAppInstallation work - required a query to the database to get the default GithubAppInstallation for an `owner`. That was the actual error that caused the incident. Error surfacing was terrible in that endpoint so I changed the `info` log from an `exception` one so we can have a stacktrace. To actually fix the error I actually created an async version of `get_adapter`. I scanned the code, but it seems that this instance is the only place where we actually use this. * fix tests Tests for the interactor (which is async) are now marked as `async`. I believe that marking them with `@async_to_sync` instead of `pytest.mark.async` may have hidden the bug that we faced about running the DB query in the async context. Not tested this theory tho. * add more unit tests to async paths
Uses the gh app installation WITHOUT compromising
the old usage (of
owner.integration_id
).Deprecated paths are marked so.
These changes don't backfill old data, but start using
the new model with webhooks.
the sample data from tests (the keys) are taken from
github docs
and some amount of empirical data.
depends on: #346
this is PR 2 of 2