-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add Codecov User Resolution #90411
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
Add Codecov User Resolution #90411
Conversation
fc746b2
to
be16d8f
Compare
be16d8f
to
22cb4e8
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #90411 +/- ##
=======================================
Coverage 87.78% 87.78%
=======================================
Files 10261 10263 +2
Lines 580220 580260 +40
Branches 22636 22636
=======================================
+ Hits 509340 509378 +38
- Misses 70445 70447 +2
Partials 435 435 |
src/sentry/codecov/helper.py
Outdated
auth_token: Any | ||
|
||
|
||
def codecov_user_resolution(user_id: int, organization_id: int) -> CodecovUser | None: |
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.
maybe resolve_codecov_user
would be a better name?
22cb4e8
to
585ff51
Compare
585ff51
to
81fe2de
Compare
user_id=user_id, provider_type="github" | ||
) | ||
if identities: | ||
identity = identities[0] |
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.
Will we get many identities? And if so, why would we always choose the first? Perhaps a comment to help understand this 👌
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.
When I checked the database, there should be only one identity mapped to GitHub per user at this point. So, in practice, this is currently zero or one user. I can add a comment for this. 👍
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.
gotchaa so this will be like a one off mapping?
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.
do we still need to look up IDs for GitHub orgs that are relevant to the current Sentry context? not saying to do it in this PR, just checking whether that's still part of the plan
|
||
def resolve_codecov_user(user_id: int, organization_id: int) -> CodecovUser | None: | ||
"""Given a Sentry User, and an organization id, find the GitHub user ID and GH access_token | ||
that is linked to Codecov's user. |
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 is linked to Codecov's user" implies Codecov has its own notion of this user's identity. maybe word like "that we can provide in place of a Codecov User"?
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.
Technically, we're using the GH id to link it to Codecov's concept of a user (we are still using the owner
object in Codecov). The name of the method might be confusing? As we're technically finding the GH user to link to Codecov.
""" | ||
# Get identity from an AuthProvider if it's available. | ||
auth_provider = access_service.get_auth_provider(organization_id) | ||
if auth_provider and auth_provider.provider == "github": |
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.
are there constants/enums for auth_provider.provider
and provider_type
values?
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 haven't seen an enum
81fe2de
to
d6cb285
Compare
Yes. I'm going to do it in another PR. |
Codecov needs to map the Sentry user onto a GitHub identity to be able to link them to the associated Codecov user. This returns the external_id (GitHub id) and the auth_token to be encrypted and used for requests to Codecov.
d6cb285
to
50b4c8b
Compare
Codecov needs to map the Sentry user onto a GitHub identity to be able to link them to the associated Codecov user. This returns the external_id (GitHub id) and the auth_token to be encrypted and used for requests to Codecov.
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. and is gonna need some rights from me in order to utilize my contributions in this here 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.