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

Add call to avoid status + checks at the same time #756

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

adrian-codecov
Copy link
Contributor

We have two ways of doing PR checks: via the commit statuses API or the check runs API. They both serve as a PR check, which tells the customer their status relevant to patch, change and project. We've had customers complain of seeing the same check with two different numbers/duplicates, and that's when you have a PR check using both APIs. You only want to use one of them and not the other, so this is a check to help favoring the commit status over a PR check if there's one existing.

This ^ happens when you try to do a check, you fail for some reason, fallback to doing a commit status, and eventually do a check for the same commit, ending up with duplicate checks. Ideally we'd like to favor having PR checks, but github offers no way to delete commit statuses (although they reset every time you push a new commit). Therefore, this seemed like the way to go. The main caveat is that, for every "legit" check, we're also calling an extra time to determine if there's a status for this commit already, which isn't ideal. But this will prevent sending a check and a status and only a status when there's already one posted.

More details here codecov/engineering-team#1967

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.

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.01%. Comparing base (47c669a) to head (901e799).
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     #756      +/-   ##
==========================================
- Coverage   98.02%   98.01%   -0.02%     
==========================================
  Files         438      438              
  Lines       36386    36420      +34     
==========================================
+ Hits        35669    35696      +27     
- Misses        717      724       +7     
Flag Coverage Δ
integration 98.01% <100.00%> (-0.02%) ⬇️
unit 98.01% <100.00%> (-0.02%) ⬇️

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

Components Coverage Δ
NonTestCode 95.85% <100.00%> (-0.05%) ⬇️
OutsideTasks 98.02% <100.00%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
services/notification/notifiers/checks/base.py 97.51% <100.00%> (-0.57%) ⬇️
...ification/notifiers/checks/checks_with_fallback.py 87.50% <ø> (-10.00%) ⬇️
...s/notification/notifiers/tests/unit/test_checks.py 100.00% <100.00%> (ø)
...tification/tests/unit/test_notification_service.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@codecov-qa
Copy link

codecov-qa bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.01%. Comparing base (47c669a) to head (901e799).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #756      +/-   ##
==========================================
- Coverage   98.02%   98.01%   -0.02%     
==========================================
  Files         438      438              
  Lines       36386    36420      +34     
==========================================
+ Hits        35669    35696      +27     
- Misses        717      724       +7     
Flag Coverage Δ
integration 98.01% <100.00%> (-0.02%) ⬇️
unit 98.01% <100.00%> (-0.02%) ⬇️

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

Components Coverage Δ
NonTestCode 95.85% <100.00%> (-0.05%) ⬇️
OutsideTasks 98.02% <100.00%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
services/notification/notifiers/checks/base.py 97.51% <100.00%> (-0.57%) ⬇️
...ification/notifiers/checks/checks_with_fallback.py 87.50% <ø> (-10.00%) ⬇️
...s/notification/notifiers/tests/unit/test_checks.py 100.00% <100.00%> (ø)
...tification/tests/unit/test_notification_service.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@codecov-notifications
Copy link

codecov-notifications bot commented Oct 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     #756      +/-   ##
==========================================
- Coverage   98.02%   98.01%   -0.02%     
==========================================
  Files         438      438              
  Lines       36386    36420      +34     
==========================================
+ Hits        35669    35696      +27     
- Misses        717      724       +7     
Flag Coverage Δ
integration 98.01% <100.00%> (-0.02%) ⬇️
unit 98.01% <100.00%> (-0.02%) ⬇️

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

Components Coverage Δ
NonTestCode 95.85% <100.00%> (-0.05%) ⬇️
OutsideTasks 98.02% <100.00%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
services/notification/notifiers/checks/base.py 97.51% <100.00%> (-0.57%) ⬇️
...ification/notifiers/checks/checks_with_fallback.py 87.50% <ø> (-10.00%) ⬇️
...s/notification/notifiers/tests/unit/test_checks.py 100.00% <100.00%> (ø)
...tification/tests/unit/test_notification_service.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

Copy link

codecov-public-qa bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.01%. Comparing base (47c669a) to head (901e799).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #756      +/-   ##
==========================================
- Coverage   98.02%   98.01%   -0.02%     
==========================================
  Files         438      438              
  Lines       36386    36420      +34     
==========================================
+ Hits        35669    35696      +27     
- Misses        717      724       +7     
Flag Coverage Δ
integration 98.01% <100.00%> (-0.02%) ⬇️
unit 98.01% <100.00%> (-0.02%) ⬇️

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

Components Coverage Δ
NonTestCode 95.85% <100.00%> (-0.05%) ⬇️
OutsideTasks 98.02% <100.00%> (-0.02%) ⬇️
Files Coverage Δ
services/notification/notifiers/checks/base.py 97.51% <100.00%> (-0.57%) ⬇️
...ification/notifiers/checks/checks_with_fallback.py 87.50% <ø> (-10.00%) ⬇️
...s/notification/notifiers/tests/unit/test_checks.py 100.00% <100.00%> (ø)
...tification/tests/unit/test_notification_service.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@@ -461,6 +462,7 @@ def test_notify_individual_notifier_timeout(self, mocker, sample_comparison):
def test_notify_individual_checks_notifier(
self, mocker, sample_comparison, mock_repo_provider, mock_configuration
):
mock_repo_provider.get_commit_statuses.return_value = Status([])
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of defining this in every test thats using the function, how about adding this as a default to the mock_repo_provider

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a bad thought, but the mock_repo_provider is used in other files/tests so it may lead to unnecessary calls/undesired side effects. I also like it this way cause it makes it clearer to me what each test does, I find it better for readability :). I'll merge this tmrw since it's kinda late now

@adrian-codecov adrian-codecov added this pull request to the merge queue Oct 4, 2024
Merged via the queue into main with commit ae480f7 Oct 4, 2024
27 of 40 checks passed
@adrian-codecov adrian-codecov deleted the 1967-adjust-checks-with-fallbacks branch October 4, 2024 19:41
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