codecov-api icon indicating copy to clipboard operation
codecov-api copied to clipboard

[WIP] fix: Uptake additional GH Repository webhook actions

Open ajay-sentry opened this issue 9 months ago • 5 comments

Purpose/Motivation

This PR aims to uptake additional GH webhook actions for the repository webhook, specifically the following:

  • Created
  • Edited (for default branch updates)
  • Transferred
  • Archived
  • Unarchived
  • Renamed

According to https://console.cloud.google.com/logs/query;query=%22Unknown%20repository%20action:%22;summaryFields=jsonPayload%252Fgithub_webhook_event:false:32:beginning;lfeCustomFields=jsonPayload%252Fgithub_webhook_event,jsonPayload%252Fmessage;cursorTimestamp=2025-02-12T17:03:57.668527951Z;duration=P1D?project=genuine-polymer-165712&authuser=1&rapt=AEjHL4PD4ouhhOp5AhDcztMI1qB_NYCOer76Ai9CN49BTAs-Fw4c9_D6WEGzs31euTGsCazldjgAGyD6cLTKNvlQhWl3KZEc_TwPi1zqmfO_2FiqwOZee2U, we drop ~2000+ of these events per day

I think if we uptake these there's a possibility some load can be removed from sync_repos to find and update stale repos, and I think in the case of archived/unarchived, those are not handled even within sync_repos.

Plus there's some "quality of life" adjustment here with the "created" action, no longer needing to rely on sync_repos to pull it in and create the repo. Generally, it seems like sync_repos has been "bandaged" together to handle all these edge cases when if we solve the problem upstream (in the webhook handler), we might be able to get rid of a lot of that stuff if we can get confidence that these webhooks keep things in sync on their own.

Links to relevant tickets

Closes https://github.com/codecov/engineering-team/issues/2938

Notes to Reviewer

Anything to note to the team? Any tips on how to review, or where to start?

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.

ajay-sentry avatar Feb 12 '25 22:02 ajay-sentry

🔍 Existing Issues For Review

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

📄 File: webhook_handlers/views/github.py

Function Unhandled Issue
validate_signature TypeError: '>' not supported between instances of 'int' and 'str' /webhooks/...
Event Count: 84

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

sentry[bot] avatar Feb 12 '25 22:02 sentry[bot]

Codecov Report

Attention: Patch coverage is 34.88372% with 28 lines in your changes missing coverage. Please review.

Project coverage is 95.90%. Comparing base (06167fb) to head (16d8889).

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

:white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
webhook_handlers/views/github.py Critical 34.88% 28 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1153      +/-   ##
==========================================
- Coverage   96.03%   95.90%   -0.14%     
==========================================
  Files         838      838              
  Lines       19818    19846      +28     
==========================================
  Hits        19033    19033              
- Misses        785      813      +28     
Flag Coverage Δ
unit 95.76% <34.88%> (-0.16%) :arrow_down:
unit-latest-uploader 95.76% <34.88%> (-0.16%) :arrow_down:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 12 '25 22:02 codecov[bot]

Codecov Report

Attention: Patch coverage is 34.88372% with 28 lines in your changes missing coverage. Please review.

Project coverage is 95.76%. Comparing base (06167fb) to head (16d8889).

:white_check_mark: All tests successful. No failed tests found.

codecov-qa[bot] avatar Feb 12 '25 22:02 codecov-qa[bot]

:white_check_mark: All tests successful. No failed tests were found.

:mega: Thoughts on this report? Let Codecov know! | Powered by Codecov

github-actions[bot] avatar Feb 12 '25 22:02 github-actions[bot]

Codecov Report

Attention: Patch coverage is 34.88372% with 28 lines in your changes missing coverage. Please review.

:white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
webhook_handlers/views/github.py 34.88% 28 Missing :warning:

:loudspeaker: Thoughts on this report? Let us know!