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 discord webhook helpers #1045

Merged
merged 1 commit into from
Mar 10, 2025
Merged

Conversation

MarceloRobert
Copy link
Collaborator

Adds helper functions to send messages using a discord webhook

How to test

Get a discord webhook url, by going to discord server settings, creating or viewing a webhook and copying its URL
Set the environment variable DISCORD_WEBHOOK_URL with the url of your webhook (should look something like https://discord.com/api/webhooks/<id>/<webhook_id>)
Currently there is only a notification for failed builds that had tests, such as this localhost buildDetails

Closes #1027

@MarceloRobert MarceloRobert self-assigned this Mar 7, 2025
@murilx
Copy link
Contributor

murilx commented Mar 7, 2025

Just a quick correction, is seems that you have implemented code for both failed builds with tests but also for trees with no builds, tests or boots, or am I overlooking something?

@MarceloRobert MarceloRobert force-pushed the feat/prepare-discord-webhook branch from 92ee98d to beb769a Compare March 7, 2025 17:28
@@ -26,6 +29,13 @@ def get(self, request, build_id: str) -> Response:
status=HTTPStatus.OK,
)

if result[0]["build__valid"] is False:
Copy link
Collaborator

Choose a reason for hiding this comment

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

check if result[0] exists

Copy link
Contributor

@murilx murilx Mar 7, 2025

Choose a reason for hiding this comment

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

I think that the if before (if not result) should be enough, shouldn't it?

Python 3.12.7 (main, Nov 18 2024, 15:03:02) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = []
>>> not a
True
>>> a.append(1)
>>> not a
False

Copy link
Contributor

Choose a reason for hiding this comment

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

but I'd still do

Suggested change
if result[0]["build__valid"] is False:
if result[0].get("build__valid") is False:

just to be sure

@MarceloRobert MarceloRobert force-pushed the feat/prepare-discord-webhook branch 2 times, most recently from b982a81 to 15ce9bf Compare March 7, 2025 18:36
@@ -45,6 +45,7 @@ services:
- DB_DEFAULT_USER=${DB_DEFAULT_USER:-kernelci}
- DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY}
- DEBUG=False
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add the env description to the backend README file

Copy link
Collaborator

@WilsonNet WilsonNet left a comment

Choose a reason for hiding this comment

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

nice job, worked on my tests

@MarceloRobert MarceloRobert force-pushed the feat/prepare-discord-webhook branch from 15ce9bf to 3c565cd Compare March 10, 2025 17:54
Copy link
Contributor

@murilx murilx left a comment

Choose a reason for hiding this comment

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

Worked well on my tests

@MarceloRobert MarceloRobert merged commit e96f008 into main Mar 10, 2025
5 checks passed
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.

Add support to discord webhook to send notifications
3 participants