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: don't select suspended apps #534

Merged
merged 4 commits into from
Jul 4, 2024

Conversation

giovanni-guidini
Copy link
Contributor

Currently we ignore if an app is suspended or not.
An app is suspended by the user.
If we select a suspended app we will fail to get an access_token for it
and eventually fail with InstallationError

These changes filter out suspended apps from being selected.
In case all apps for the user are suspended we skip notifications.
Other tasks would fail with NoConfiguredAppsAvailable.

closes https://github.com/codecov/internal-issues/issues/519

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 and others added 3 commits June 28, 2024 14:41
This column is part of the model since codecov/shared#237
but was not reflected in the worker yet.

related: codecov/internal-issues#519
Currently we ignore if an app is suspended or not.
An app is suspended by the user.
If we select a suspended app we will fail to get an access_token for it
and eventually fail with `InstallationError`

These changes filter out suspended apps from being selected.
In case all apps for the user are suspended we skip notifications.
Other tasks would fail with `NoConfiguredAppsAvailable`.

closes codecov/internal-issues#519
@codecov-notifications
Copy link

codecov-notifications bot commented Jul 2, 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     #534      +/-   ##
==========================================
+ Coverage   97.48%   97.50%   +0.02%     
==========================================
  Files         418      420       +2     
  Lines       35013    35396     +383     
==========================================
+ Hits        34132    34514     +382     
- Misses        881      882       +1     
Flag Coverage Δ
integration 97.50% <100.00%> (+0.02%) ⬆️
latest-uploader-overall 97.50% <100.00%> (+0.02%) ⬆️
unit 97.50% <100.00%> (+0.02%) ⬆️

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

Components Coverage Δ
NonTestCode 94.58% <100.00%> (+0.04%) ⬆️
OutsideTasks 97.74% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
database/models/core.py 97.43% <100.00%> (+0.32%) ⬆️
helpers/exceptions.py 100.00% <100.00%> (ø)
services/bots/github_apps.py 97.64% <100.00%> (+0.21%) ⬆️
services/bots/tests/test_github_apps.py 100.00% <100.00%> (ø)
tasks/notify.py 98.27% <100.00%> (+0.02%) ⬆️
tasks/tests/unit/test_notify_task.py 100.00% <100.00%> (ø)

... and 20 files with indirect coverage changes

@codecov-qa
Copy link

codecov-qa bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.50%. Comparing base (2a234be) to head (dc66506).
Report is 10 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #534      +/-   ##
==========================================
+ Coverage   97.48%   97.50%   +0.02%     
==========================================
  Files         418      420       +2     
  Lines       35013    35396     +383     
==========================================
+ Hits        34132    34514     +382     
- Misses        881      882       +1     
Flag Coverage Δ
integration 97.50% <100.00%> (+0.02%) ⬆️
latest-uploader-overall 97.50% <100.00%> (+0.02%) ⬆️
unit 97.50% <100.00%> (+0.02%) ⬆️

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

Components Coverage Δ
NonTestCode 94.58% <100.00%> (+0.04%) ⬆️
OutsideTasks 97.74% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
database/models/core.py 97.43% <100.00%> (+0.32%) ⬆️
helpers/exceptions.py 100.00% <100.00%> (ø)
services/bots/github_apps.py 97.64% <100.00%> (+0.21%) ⬆️
services/bots/tests/test_github_apps.py 100.00% <100.00%> (ø)
tasks/notify.py 98.27% <100.00%> (+0.02%) ⬆️
tasks/tests/unit/test_notify_task.py 100.00% <100.00%> (ø)

... and 20 files with indirect coverage changes

Copy link

codecov-public-qa bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.50%. Comparing base (2a234be) to head (dc66506).
Report is 10 commits behind head on main.

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #534      +/-   ##
==========================================
+ Coverage   97.48%   97.50%   +0.02%     
==========================================
  Files         418      420       +2     
  Lines       35013    35396     +383     
==========================================
+ Hits        34132    34514     +382     
- Misses        881      882       +1     
Flag Coverage Δ
integration 97.50% <100.00%> (+0.02%) ⬆️
latest-uploader-overall 97.50% <100.00%> (+0.02%) ⬆️
unit 97.50% <100.00%> (+0.02%) ⬆️

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

Components Coverage Δ
NonTestCode 94.58% <100.00%> (+0.04%) ⬆️
OutsideTasks 97.74% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
database/models/core.py 97.43% <100.00%> (+0.32%) ⬆️
helpers/exceptions.py 100.00% <100.00%> (ø)
services/bots/github_apps.py 97.64% <100.00%> (+0.21%) ⬆️
services/bots/tests/test_github_apps.py 100.00% <100.00%> (ø)
tasks/notify.py 98.27% <100.00%> (+0.02%) ⬆️
tasks/tests/unit/test_notify_task.py 100.00% <100.00%> (ø)

... and 20 files with indirect coverage changes

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.54%. Comparing base (2a234be) to head (dc66506).
Report is 10 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     #534      +/-   ##
==========================================
+ Coverage   97.50%   97.54%   +0.04%     
==========================================
  Files         449      451       +2     
  Lines       35736    36561     +825     
==========================================
+ Hits        34845    35665     +820     
- Misses        891      896       +5     
Flag Coverage Δ
integration 97.50% <100.00%> (+0.02%) ⬆️
latest-uploader-overall 97.50% <100.00%> (+0.02%) ⬆️
unit 97.50% <100.00%> (+0.02%) ⬆️

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

Components Coverage Δ
NonTestCode 94.66% <100.00%> (+0.07%) ⬆️
OutsideTasks 97.74% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
database/models/core.py 97.43% <100.00%> (+0.32%) ⬆️
helpers/exceptions.py 100.00% <100.00%> (ø)
services/bots/github_apps.py 97.64% <100.00%> (+0.21%) ⬆️
services/bots/tests/test_github_apps.py 100.00% <100.00%> (ø)
tasks/notify.py Critical 98.27% <100.00%> (+0.02%) ⬆️
tasks/tests/unit/test_notify_task.py 100.00% <100.00%> (ø)

... and 20 files with indirect coverage changes

This change has been scanned for critical changes. Learn more

@giovanni-guidini giovanni-guidini requested a review from a team July 2, 2024 13:26
Base automatically changed from gio/track-suspended to main July 3, 2024 13:25
@@ -225,18 +245,15 @@ def get_github_app_info_for_owner(
owner, installation_name, repository
)
apps_matching_criteria_count = len(apps_to_consider)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does apps_to_consider have a hierarchy of which app to try first over another?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, as documented in the function that produces this list:

"""This function returns an ordered list of GithubAppInstallations that can be used to communicate with GitHub

The ordering of apps in the list is the hierarchy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see I see

)


def _filter_suspended_apps(
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: making tests for this that isn't necessarily tethered to the notify test

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.

Approved, extra tests optional

@giovanni-guidini giovanni-guidini added this pull request to the merge queue Jul 4, 2024
Merged via the queue into main with commit dc7810b Jul 4, 2024
29 of 30 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/update-no-apps-available branch July 4, 2024 14:34
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