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: Add functions to get/set apps to commits #469

Merged
merged 2 commits into from
May 28, 2024

Conversation

giovanni-guidini
Copy link
Contributor

Adds set_github_app_for_commit and get_github_app_for_commit functions. These let us set and later get a GithubAppInstallation.id that's related to a Commit.id

ticket: codecov/engineering-team#1737

👀 This commit is part 1/4 of a bigger change that is actually done, but I decided to break it up into multiple PRs so it's easier to review. See how it plays with the rest here: main...gio/pin-commit-to-ghapp

(I'll try to leave the original branch up to date best as I can)

Adds `set_github_app_for_commit` and `get_github_app_for_commit` functions.
These let us set and later get a GithubAppInstallation.id that's related to
a Commit.id
Copy link

sentry-io bot commented May 27, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: services/github.py

Function Unhandled Issue
get_github_integration_token RepositoryWithoutValidBotError app.tasks.sync_rep...
Event Count: 4
get_github_integration_token JSONDecodeError: Expecting value: line 1 column 1 (char 0) app.tasks....
Event Count: 2
get_github_integration_token JSONDecodeError: Expecting value: line 1 column 1 (char 0) app.tasks.not...
Event Count: 1
get_github_integration_token JSONDecodeError: Expecting value: line 1 column 1 (char 0) app.tasks.upl...
Event Count: 1
get_github_integration_token RepositoryWithoutValidBotError app.tasks.sync_rep...
Event Count: 1

Did you find this useful? React with a 👍 or 👎

@codecov-qa
Copy link

codecov-qa bot commented May 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.25%. Comparing base (e18b4ff) to head (65a7ce4).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff            @@
##             main     #469    +/-   ##
========================================
  Coverage   97.25%   97.25%            
========================================
  Files         409      410     +1     
  Lines       33976    34082   +106     
========================================
+ Hits        33042    33148   +106     
  Misses        934      934            
Flag Coverage Δ
integration 97.25% <100.00%> (+<0.01%) ⬆️
latest-uploader-overall 97.25% <100.00%> (+<0.01%) ⬆️
unit 97.25% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 94.36% <100.00%> (+0.01%) ⬆️
OutsideTasks 97.51% <100.00%> (+0.01%) ⬆️
Files Coverage Δ
services/github.py 94.44% <100.00%> (+8.73%) ⬆️
services/tests/test_github.py 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Copy link

codecov-public-qa bot commented May 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.25%. Comparing base (e18b4ff) to head (65a7ce4).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@           Coverage Diff            @@
##             main     #469    +/-   ##
========================================
  Coverage   97.25%   97.25%            
========================================
  Files         409      410     +1     
  Lines       33976    34082   +106     
========================================
+ Hits        33042    33148   +106     
  Misses        934      934            
Flag Coverage Δ
integration 97.25% <100.00%> (+<0.01%) ⬆️
latest-uploader-overall 97.25% <100.00%> (+<0.01%) ⬆️
unit 97.25% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 94.36% <100.00%> (+0.01%) ⬆️
OutsideTasks 97.51% <100.00%> (+0.01%) ⬆️
Files Coverage Δ
services/github.py 94.44% <100.00%> (+8.73%) ⬆️
services/tests/test_github.py 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Copy link

codecov bot commented May 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.30%. Comparing base (e18b4ff) to head (65a7ce4).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #469      +/-   ##
==========================================
+ Coverage   97.28%   97.30%   +0.02%     
==========================================
  Files         441      441              
  Lines       34731    34939     +208     
==========================================
+ Hits        33788    33999     +211     
+ Misses        943      940       -3     
Flag Coverage Δ
integration 97.25% <100.00%> (+<0.01%) ⬆️
latest-uploader-overall 97.25% <100.00%> (+<0.01%) ⬆️
unit 97.25% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 94.47% <100.00%> (+0.06%) ⬆️
OutsideTasks 97.51% <100.00%> (+0.01%) ⬆️
Files Coverage Δ
services/github.py 100.00% <100.00%> (ø)
services/tests/test_github.py 100.00% <100.00%> (ø)

... and 2 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 May 28, 2024 11:20
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 except for a few comments!

Comment on lines 42 to 44
redis.set(
COMMIT_GHAPP_KEY_NAME(commit.id), str(installation_id), ex=(60 * 60 * 2)
) # 2h
Copy link
Contributor

Choose a reason for hiding this comment

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

For readability, let's extract (60 * 60 * 2) as a constant as well.



def set_github_app_for_commit(
installation_id: str | int | None, commit: Commit
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, installation_id has a lot of different types. In what circumstances should we be expecting a str vs int vs None type? Should this be documented?

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.

LGTM!

@giovanni-guidini giovanni-guidini added this pull request to the merge queue May 28, 2024
Merged via the queue into main with commit 1b7be5f May 28, 2024
25 of 26 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/pin-commits/get-set-apps-for-commits branch May 28, 2024 14:43
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.

2 participants