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: GithubAppInstallation model #346

Merged
merged 3 commits into from
Jan 19, 2024
Merged

Conversation

giovanni-guidini
Copy link
Contributor

@giovanni-guidini giovanni-guidini commented Jan 18, 2024

Model definitions for GithubAppInstallation.
This will unlock multiple apps for an org.
It also will improve how we keep track of what repos
an installation can access.

context: codecov/engineering-team#969

this is PR 1 of 2

giovanni-guidini added a commit that referenced this pull request Jan 18, 2024
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.

depends on: #346
giovanni-guidini added a commit that referenced this pull request Jan 18, 2024
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.

depends on: #346
@codecov-staging
Copy link

codecov-staging bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6be2a74) 96.06% compared to head (9796875) 96.07%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #346   +/-   ##
=======================================
  Coverage   96.06%   96.07%           
=======================================
  Files         624      625    +1     
  Lines       16171    16196   +25     
=======================================
+ Hits        15535    15560   +25     
  Misses        636      636           
Flag Coverage Δ
unit 96.07% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.07% <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.

Copy link

codecov-public-qa bot commented Jan 18, 2024

Codecov Report

Merging #346 (9796875) into main (6be2a74) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #346   +/-   ##
=======================================
  Coverage   96.06%   96.07%           
=======================================
  Files         624      625    +1     
  Lines       16171    16196   +25     
=======================================
+ Hits        15535    15560   +25     
  Misses        636      636           
Flag Coverage Δ
unit 96.07% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.07% <100.00%> (+<0.01%) ⬆️

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

Files Coverage Δ
...ecov_auth/migrations/0048_githubappinstallation.py 100.00% <100.00%> (ø)
codecov_auth/models.py 98.93% <100.00%> (+0.05%) ⬆️
core/models.py 94.71% <ø> (ø)

Impacted file tree graph

Model definitions for GithubAppInstallation.
This will unlock multiple apps for an org.
It also will improve how we keep track of what repos
an installation can access.

context: codecov/engineering-team#969
Copy link

codecov bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (86431d3) 95.69% compared to head (ca8798d) 95.67%.
Report is 2 commits behind head on main.

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

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #346     +/-   ##
=======================================
- Coverage   95.69   95.67   -0.02     
=======================================
  Files        738     740      +2     
  Lines      16670   16842    +172     
=======================================
+ Hits       15951   16112    +161     
- Misses       719     730     +11     
Flag Coverage Δ
unit 96.07% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.07% <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.

giovanni-guidini added a commit that referenced this pull request Jan 18, 2024
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
Copy link
Contributor

@matt-codecov matt-codecov left a comment

Choose a reason for hiding this comment

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

i like the helper methods, nice touch

pls address comments but this'll defo do the trick

GITHUB_APP_INSTALLATION_DEFAULT_NAME = "codecov_app_installation"


class GithubAppInstallation(
Copy link
Contributor

Choose a reason for hiding this comment

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

do we also need an app id column? since we may use sentry's app or support multiple apps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the "installation_id" is the "app_id"

# replacement for owner.integration_id
# installation id GitHub sends us in the installation-related webhook events
installation_id = models.IntegerField(null=False, blank=False)
name = models.TextField(default=GITHUB_APP_INSTALLATION_DEFAULT_NAME)
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is what will differentiate the type of apps. As you mentioned above, we might use sentry's app or support multiple apps. This is how we know which is which.

codecov_auth/tests/unit/test_models.py Show resolved Hide resolved
giovanni-guidini added a commit that referenced this pull request Jan 18, 2024
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
@giovanni-guidini giovanni-guidini merged commit 635ff36 into main Jan 19, 2024
19 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/multi-apps/model branch January 19, 2024 00:05
giovanni-guidini added a commit that referenced this pull request Jan 19, 2024
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
giovanni-guidini added a commit that referenced this pull request Jan 19, 2024
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
giovanni-guidini added a commit that referenced this pull request Jan 19, 2024
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
giovanni-guidini added a commit that referenced this pull request Jan 19, 2024
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
giovanni-guidini added a commit that referenced this pull request Jan 19, 2024
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
giovanni-guidini added a commit to codecov/worker that referenced this pull request Jan 19, 2024
These changes port codecov/codecov-api#346
to the worker so we can use them here as well.

context: codecov/engineering-team#970
giovanni-guidini added a commit to codecov/worker that referenced this pull request Jan 24, 2024
These changes port codecov/codecov-api#346
to the worker so we can use them here as well.

context: codecov/engineering-team#970
giovanni-guidini added a commit that referenced this pull request Jan 24, 2024
* feat: use GithubAppInstallation in api

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

* refactor webhook handling related to gh app installation

* use ghapp when getting torngit adapter

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.
giovanni-guidini added a commit to codecov/worker that referenced this pull request Jan 26, 2024
These changes port codecov/codecov-api#346
to the worker so we can use them here as well.

context: codecov/engineering-team#970
giovanni-guidini added a commit to codecov/worker that referenced this pull request Jan 29, 2024
These changes port codecov/codecov-api#346
to the worker so we can use them here as well.

context: codecov/engineering-team#970
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

2 participants