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: notify status to multiple shas (gitlab) #712

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

giovanni-guidini
Copy link
Contributor

related to codecov/engineering-team#2076

Now that we are collecting different SHAs that we potentially need to notify for Gitlab,
the only missing piece was actually doing the notification in multiple SHAs.

Some notes:

  • The checks notifier is exclusive for GitHub, so no need to change that
  • "notifying to multiple shas" is done in the most transparent way possible
  • I created _send_notification_with_metrics just to wrap the timer, but it would probably be better to
    add it in the Torngit adapter directly
  • We don't need to do this for the PR comment, just the status

related to codecov/engineering-team#2076

Now that we are collecting different SHAs that we potentially need to notify for Gitlab,
the only missing piece was actually doing the notification in multiple SHAs.

Some notes:
* The `checks` notifier is exclusive for GitHub, so no need to change that
* "notifying to multiple shas" is done in the most transparent way possible
* I created `_send_notification_with_metrics` just to wrap the timer, but it would probably be better to
add it in the Torngit adapter directly
* We don't need to do this for the PR comment, just the status
@giovanni-guidini giovanni-guidini requested a review from a team September 16, 2024 17:48
@codecov-notifications
Copy link

codecov-notifications bot commented Sep 16, 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     #712      +/-   ##
==========================================
- Coverage   98.08%   98.07%   -0.01%     
==========================================
  Files         434      434              
  Lines       36653    36776     +123     
==========================================
+ Hits        35950    36069     +119     
- Misses        703      707       +4     
Flag Coverage Δ
integration 98.07% <100.00%> (-0.01%) ⬇️
latest-uploader-overall 98.07% <100.00%> (-0.01%) ⬇️
unit 98.07% <100.00%> (-0.01%) ⬇️

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

Components Coverage Δ
NonTestCode 95.98% <100.00%> (-0.02%) ⬇️
OutsideTasks 98.10% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
services/notification/notifiers/status/base.py 98.76% <100.00%> (+0.06%) ⬆️
...s/notification/notifiers/tests/unit/test_status.py 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

@codecov-qa
Copy link

codecov-qa bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.07%. Comparing base (8c6d621) to head (ff3aec4).
Report is 12 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #712      +/-   ##
==========================================
- Coverage   98.08%   98.07%   -0.01%     
==========================================
  Files         434      434              
  Lines       36653    36776     +123     
==========================================
+ Hits        35950    36069     +119     
- Misses        703      707       +4     
Flag Coverage Δ
integration 98.07% <100.00%> (-0.01%) ⬇️
latest-uploader-overall 98.07% <100.00%> (-0.01%) ⬇️
unit 98.07% <100.00%> (-0.01%) ⬇️

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

Components Coverage Δ
NonTestCode 95.98% <100.00%> (-0.02%) ⬇️
OutsideTasks 98.10% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
services/notification/notifiers/status/base.py 98.76% <100.00%> (+0.06%) ⬆️
...s/notification/notifiers/tests/unit/test_status.py 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

Copy link

codecov-public-qa bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.07%. Comparing base (8c6d621) to head (ff3aec4).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #712      +/-   ##
==========================================
- Coverage   98.08%   98.07%   -0.01%     
==========================================
  Files         434      434              
  Lines       36653    36776     +123     
==========================================
+ Hits        35950    36069     +119     
- Misses        703      707       +4     
Flag Coverage Δ
integration 98.07% <100.00%> (-0.01%) ⬇️
latest-uploader-overall 98.07% <100.00%> (-0.01%) ⬇️
unit 98.07% <100.00%> (-0.01%) ⬇️

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

Components Coverage Δ
NonTestCode 95.98% <100.00%> (-0.02%) ⬇️
OutsideTasks 98.10% <100.00%> (+<0.01%) ⬆️
Files Coverage Δ
services/notification/notifiers/status/base.py 98.76% <100.00%> (+0.06%) ⬆️
...s/notification/notifiers/tests/unit/test_status.py 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.13%. Comparing base (8c6d621) to head (ff3aec4).
Report is 12 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     #712    +/-   ##
========================================
  Coverage   98.12%   98.13%            
========================================
  Files         475      475            
  Lines       38008    38382   +374     
========================================
+ Hits        37297    37667   +370     
- Misses        711      715     +4     
Flag Coverage Δ
integration 98.07% <100.00%> (-0.01%) ⬇️
latest-uploader-overall 98.07% <100.00%> (-0.01%) ⬇️
unit 98.07% <100.00%> (-0.01%) ⬇️

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

Components Coverage Δ
NonTestCode 96.12% <100.00%> (+0.02%) ⬆️
OutsideTasks 98.10% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
services/notification/notifiers/status/base.py 98.76% <100.00%> (+0.06%) ⬆️
...s/notification/notifiers/tests/unit/test_status.py 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

Related Entrypoints
run/app.tasks.notify.Notify

@@ -273,7 +272,7 @@ def get_status_external_name(self) -> str:
return f"codecov/{self.context}{status_piece}"

async def maybe_send_notification(
self, comparison: Comparison, payload: dict
self, comparison: ComparisonProxy, payload: dict
Copy link
Contributor

Choose a reason for hiding this comment

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

Has this always been Proxy and we never realized?

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 so... Looking at the data flow in the code this does seem to be the case

description=message,
url=url,
)
all_results = await asyncio.gather(*all_notify_tasks)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any overhead of doing gather vs await if all_notify_tasks has more often than not length = 1?

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 don't know. But this seems to be the best way to do it.
It probably has some overhead, but I doubt it's relevant

@@ -336,26 +357,37 @@ async def send_notification(self, comparison: Comparison, payload):
"state": state,
"message": message,
}

all_shas_to_notify = [head_commit_sha] + list(
comparison.context.gitlab_extra_shas or set()
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: leave a comment explaining why we have to do this, also optional since you already left a comment in the gitlab_extra_shas definition

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 was hoping that having a comment both in the gitlab_extra_shas definition and the function that calculates those extra shas would suffice.

url=url,
)
all_results = await asyncio.gather(*all_notify_tasks)
res = all_results[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we only care of the 1st result here? I guess cause the second+ would be the extra gitlab ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. The 1st result matches the notification we were doing before. All others should be as transparent as possible, I suppose

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.

Left some questions 👀

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!

@giovanni-guidini giovanni-guidini added this pull request to the merge queue Sep 18, 2024
Merged via the queue into main with commit 95d0b4a Sep 18, 2024
24 of 28 checks passed
@giovanni-guidini giovanni-guidini deleted the gio/notify-to-many-gl-shas branch September 18, 2024 19:28
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.

3 participants