From ec869c753ed34268971f7d0b07b97a667c4a8ab6 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sun, 16 Jun 2024 12:38:05 +0100 Subject: Allow some bots through the GitHub Webhook Filter This allows the Fast Forward bot and GitHub Actions scripts through the webhook filter. * Fast Forward bot should be allowed as otherwise any event created by this bot (i.e. it's merges to main) are not reported into Discord as it is considered a bot payload * GitHub Actions are generally things we have created ourselves and are not normally high noise, and as such are also worth reporting --- pydis_site/apps/api/views.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'pydis_site/apps') diff --git a/pydis_site/apps/api/views.py b/pydis_site/apps/api/views.py index a3b0016c..05a2bb02 100644 --- a/pydis_site/apps/api/views.py +++ b/pydis_site/apps/api/views.py @@ -12,6 +12,10 @@ from rest_framework.views import APIView from . import github_utils +WHITELISTED_GITHUB_BOTS = { + "pydis-ff-bot", + "github-actions" +} class HealthcheckView(APIView): """ @@ -291,8 +295,16 @@ class GitHubWebhookFilterView(APIView): or is_dependabot_branch_deletion or is_bot_pr_approval ) + + stripped_name = sender_name.removesuffix("[bot]") + is_whitelisted_bot = stripped_name in WHITELISTED_GITHUB_BOTS + is_noisy_user_action = is_empty_review - should_ignore = is_bot_payload or is_noisy_user_action or is_black_non_main_push + should_ignore = ( + (is_bot_payload and not is_whitelisted_bot) + or is_noisy_user_action + or is_black_non_main_push + ) if should_ignore: return Response( -- cgit v1.2.3 From 28f774445f911a5670e3eb079148ab288e95cfc3 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Wed, 10 Jul 2024 18:59:33 +0200 Subject: Pleasure the style dictator --- pydis_site/apps/api/tests/test_github_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site/apps') diff --git a/pydis_site/apps/api/tests/test_github_utils.py b/pydis_site/apps/api/tests/test_github_utils.py index d36111c9..7b41d2f6 100644 --- a/pydis_site/apps/api/tests/test_github_utils.py +++ b/pydis_site/apps/api/tests/test_github_utils.py @@ -210,7 +210,7 @@ class ArtifactFetcherTests(unittest.TestCase): def setUp(self) -> None: self.call_args = ["owner", "repo", "action_sha", "action_name", "artifact_name"] - self.client = httpx.Client(base_url="https://example.com") + self.client = httpx.Client(base_url="https://example.com", timeout=5) self.patchers = [ mock.patch.object(self.client, "send", new=self.get_response_get_artifact), -- cgit v1.2.3