From 16abd82fa5116743afb3c91435053e72742ddadf Mon Sep 17 00:00:00 2001 From: Niloth P <20315308+Niloth-p@users.noreply.github.com> Date: Sat, 20 Jul 2024 15:25:33 +0530 Subject: [PATCH] integrations: Remove Solano integration. --- tools/test-backend | 1 - zerver/lib/integrations.py | 2 - zerver/webhooks/solano/__init__.py | 0 zerver/webhooks/solano/doc.md | 25 ------ .../webhooks/solano/fixtures/build_001.json | 1 - .../webhooks/solano/fixtures/build_002.json | 1 - zerver/webhooks/solano/fixtures/received.json | 21 ----- zerver/webhooks/solano/fixtures/test.json | 37 --------- zerver/webhooks/solano/tests.py | 75 ----------------- zerver/webhooks/solano/view.py | 81 ------------------- 10 files changed, 244 deletions(-) delete mode 100644 zerver/webhooks/solano/__init__.py delete mode 100644 zerver/webhooks/solano/doc.md delete mode 100644 zerver/webhooks/solano/fixtures/build_001.json delete mode 100644 zerver/webhooks/solano/fixtures/build_002.json delete mode 100644 zerver/webhooks/solano/fixtures/received.json delete mode 100644 zerver/webhooks/solano/fixtures/test.json delete mode 100644 zerver/webhooks/solano/tests.py delete mode 100644 zerver/webhooks/solano/view.py diff --git a/tools/test-backend b/tools/test-backend index d2bf9c8867..204c102ee2 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -123,7 +123,6 @@ not_yet_fully_covered = [ # Webhook integrations with incomplete coverage "zerver/webhooks/greenhouse/view.py", "zerver/webhooks/jira/view.py", - "zerver/webhooks/solano/view.py", "zerver/webhooks/teamcity/view.py", "zerver/webhooks/travis/view.py", "zerver/webhooks/zapier/view.py", diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py index 8e9fba5232..9b2049ba7c 100644 --- a/zerver/lib/integrations.py +++ b/zerver/lib/integrations.py @@ -472,7 +472,6 @@ WEBHOOK_INTEGRATIONS: list[WebhookIntegration] = [ logo="images/integrations/logos/slack.svg", ), WebhookIntegration("slack", ["communication"]), - WebhookIntegration("solano", ["continuous-integration"], display_name="Solano Labs"), WebhookIntegration("sonarqube", ["continuous-integration"], display_name="SonarQube"), WebhookIntegration("sonarr", ["entertainment"], display_name="Sonarr"), WebhookIntegration("splunk", ["monitoring"], display_name="Splunk"), @@ -805,7 +804,6 @@ DOC_SCREENSHOT_CONFIG: dict[str, list[BaseScreenshotConfig]] = { ScreenshotConfig("issue_assigned_to_team.json", "002.png"), ], "slack": [ScreenshotConfig("message_info.txt")], - "solano": [ScreenshotConfig("build_001.json")], "sonarqube": [ScreenshotConfig("error.json")], "sonarr": [ScreenshotConfig("sonarr_episode_grabbed.json")], "splunk": [ScreenshotConfig("search_one_result.json")], diff --git a/zerver/webhooks/solano/__init__.py b/zerver/webhooks/solano/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/zerver/webhooks/solano/doc.md b/zerver/webhooks/solano/doc.md deleted file mode 100644 index 8edbd12815..0000000000 --- a/zerver/webhooks/solano/doc.md +++ /dev/null @@ -1,25 +0,0 @@ -Get Zulip notifications for your Solano CI builds! - -1. {!create-channel.md!} - -1. {!create-an-incoming-webhook.md!} - -1. {!generate-integration-url.md!} - -1. Go to your Solano CI **Organizations** page, and click on - **Organization Settings**. Click on **Web Hooks**. - -1. Under **Add a Web Hook**, provide the URL constructed above. - Set **Repo** to the repository you'd like to be notified about. - Leave the **Username** and **Password** fields blank, and click - **Add Web Hook**. - -!!! tip "" - - For more information, see [Solano Labs' Web Hook documentation][1]. - -[1]: http://docs.solanolabs.com/Setup/webhooks/#build-notification-web-hooks-outgoing - -{!congrats.md!} - -![](/static/images/integrations/solano/001.png) diff --git a/zerver/webhooks/solano/fixtures/build_001.json b/zerver/webhooks/solano/fixtures/build_001.json deleted file mode 100644 index d9733eaa32..0000000000 --- a/zerver/webhooks/solano/fixtures/build_001.json +++ /dev/null @@ -1 +0,0 @@ -{"event":"first-fail","timestamp":"2016-12-31T13:31:31+00:00","session":3316175,"profile_name":"default","url":"https://ci.solanolabs.com:443/reports/3316175","commit_id":"5f438401eb7cc7268cbc28438bfa70bb99f48a03","committers":["solano-ci[bot]@users.noreply.github.com"],"status":"failed","counts":{"notstarted":0,"started":48,"aborted":0,"passed":10,"failed":1,"pending":1,"skipped":0,"error":0},"workers":4,"timing":{"ci_received_at":1483191022.138977,"queue_first_seen_at":"1483191025.159813","queue_first_allowed_at":"1483191025.4943628","workers_assigned_at":"1483191025.9718277","setup":{"timestamp":1483191031.0,"has_failure":false},"setup_cache":{"timestamp":1483191033.0,"has_failure":false},"package_setup":{"timestamp":1483191035.0,"has_failure":false},"services_setup":{"timestamp":1483191080.0,"has_failure":false},"setup_hooks":{"timestamp":1483191082.0,"has_failure":false},"worker_hooks":{"timestamp":1483191082.0,"has_failure":false},"setup_post_hooks":{"timestamp":1483191082.0,"has_failure":false},"exec":{"timestamp":1483191083.0,"has_failure":false}},"branch":"master","ref":"refs/heads/master","repository":{"name":"solano","url":"ssh://git@github.com/fazerlicourice7/solano","org_name":"fazerlicourice7"},"gen":1,"xid":"6b2d0793e"} diff --git a/zerver/webhooks/solano/fixtures/build_002.json b/zerver/webhooks/solano/fixtures/build_002.json deleted file mode 100644 index a734647673..0000000000 --- a/zerver/webhooks/solano/fixtures/build_002.json +++ /dev/null @@ -1 +0,0 @@ -{"event":"stop","timestamp":"2016-12-31T23:28:45Z","session":3316723,"profile_name":"default","url":"https://ci.solanolabs.com:443/reports/3316723","commit_id":"5d0b92e26448a9e91db794bfed4b8c3556eabc4e", "commiters":["random.user@email.com"],"status":"failed","counts":{"notstarted":0,"started":0,"aborted":0,"passed":0,"failed":0,"pending":0,"skipped":0,"error":0},"workers":0,"timing":{"ci_received_at":1483226288.415732,"queue_first_seen_at":"1483226306.774112","queue_first_allowed_at":"1483226307.247373","workers_assigned_at":"1483226307.9570494","setup":{"timestamp":1483226315.0,"has_failure":false},"post_build":{"timestamp":1483226316.0,"has_failure":false},"worker_rendezvous":{"timestamp":1483226316.0,"has_failure":false},"post_build_hook":{"timestamp":1483226925.0,"has_failure":false},"artifact_collect":{"timestamp":1483226925.0,"has_failure":false},"capture_cache":{"timestamp":1483226925.0,"has_failure":false},"done":{"timestamp":1483226925.0,"has_failure":false},"snapshot_creation":{"timestamp":1483226926.0,"has_failure":false}},"branch":"master","ref":"master","repository":{"name":"test","url":"ssh://git@bitbucket.org/fazerlicourice7/test","org_name":null},"gen":1,"xid":"522fa9d68"} diff --git a/zerver/webhooks/solano/fixtures/received.json b/zerver/webhooks/solano/fixtures/received.json deleted file mode 100644 index 5bfa60ac45..0000000000 --- a/zerver/webhooks/solano/fixtures/received.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "event": "received", - "timestamp": "2017-01-02T18:23:06+00:00", - "session": 3317799, - "profile_name": "default", - "url": "https:\/\/ci.solanolabs.com:443\/reports\/3317799", - "commit_id": "191d34f9da8ff7279b051cd68e44223253e18408", - "committers": [ - "solano-ci[bot]@users.noreply.github.com" - ], - "status": "running", - "branch": "master", - "ref": "refs\/heads\/master", - "repository": { - "name": "scipy", - "url": "ssh:\/\/git@github.com\/anirudhjain75\/scipy", - "org_name": "anirudhjain75" - }, - "gen": 1, - "xid": "8c7f63bf9" -} diff --git a/zerver/webhooks/solano/fixtures/test.json b/zerver/webhooks/solano/fixtures/test.json deleted file mode 100644 index 2ebb4ff355..0000000000 --- a/zerver/webhooks/solano/fixtures/test.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "event": "test", - "timestamp": "2015-08-25T00:58:27Z", - "session": 351279, - "guid": "c946783126c9e74291d24465f0a60", - "url": "https://ci.solanolabs.com/1/reports/351279", - "parent_session": 351278, - "profile_name": "default", - "commit_id": "38d4d2548e85729e138fdba32e08421bb899ba37", - "committers": [], - "status": "passed", - "counts": { - "notstarted": 0, - "started": 0, - "passed": 234.0, - "failed": 0.0, - "pending": 3.0, - "skipped": 0.0, - "error": 0.0 - }, - "workers": 24, - "stopped_by": "user@mycompany.com", - "timing": { - "ci_received_at": 1475250402.480408, - "queue_first_seen_at": 1475250412.841408, - "queue_first_allowed_at": 1475250492.863428, - "workers_assigned_at": 1475250493.136248 - }, - "branch": "production", - "ref": "refs/head/production", - "repository": { - "name": "repo_name", - "url": "ssh://git@github.com/organization_name/repo_name", - "org_name": "organization_name" - }, - "xid": "372da4f69" -} diff --git a/zerver/webhooks/solano/tests.py b/zerver/webhooks/solano/tests.py deleted file mode 100644 index b6968bf6c2..0000000000 --- a/zerver/webhooks/solano/tests.py +++ /dev/null @@ -1,75 +0,0 @@ -from zerver.lib.test_classes import WebhookTestCase - - -class SolanoHookTests(WebhookTestCase): - CHANNEL_NAME = "solano labs" - URL_TEMPLATE = "/api/v1/external/solano?api_key={api_key}&stream={stream}" - WEBHOOK_DIR_NAME = "solano" - - def test_solano_message_001(self) -> None: - """ - Build notifications are generated by Solano Labs after build completes. - """ - expected_topic_name = "build update" - expected_message = """ -Build update (see [build log](https://ci.solanolabs.com:443/reports/3316175)): -* **Author**: solano-ci[bot]@users.noreply.github.com -* **Commit**: [5f438401eb7](github.com/fazerlicourice7/solano/commit/5f438401eb7cc7268cbc28438bfa70bb99f48a03) -* **Status**: failed :thumbs_down: -""".strip() - - self.check_webhook( - "build_001", - expected_topic_name, - expected_message, - content_type="application/x-www-form-urlencoded", - ) - - def test_solano_message_002(self) -> None: - """ - Build notifications are generated by Solano Labs after build completes. - """ - expected_topic_name = "build update" - expected_message = """ -Build update (see [build log](https://ci.solanolabs.com:443/reports/3316723)): -* **Author**: Unknown -* **Commit**: [5d0b92e2644](bitbucket.org/fazerlicourice7/test/commits/5d0b92e26448a9e91db794bfed4b8c3556eabc4e) -* **Status**: failed :thumbs_down: -""".strip() - - self.check_webhook( - "build_002", - expected_topic_name, - expected_message, - content_type="application/x-www-form-urlencoded", - ) - - def test_solano_message_received(self) -> None: - """ - Build notifications are generated by Solano Labs after build completes. - """ - expected_topic_name = "build update" - expected_message = """ -Build update (see [build log](https://ci.solanolabs.com:443/reports/3317799)): -* **Author**: solano-ci[bot]@users.noreply.github.com -* **Commit**: [191d34f9da8](github.com/anirudhjain75/scipy/commit/191d34f9da8ff7279b051cd68e44223253e18408) -* **Status**: running :arrows_counterclockwise: -""".strip() - - self.check_webhook( - "received", - expected_topic_name, - expected_message, - content_type="application/x-www-form-urlencoded", - ) - - def test_solano_test_message(self) -> None: - expected_topic_name = "build update" - expected_message = "Solano webhook set up correctly." - - self.check_webhook( - "test", - expected_topic_name, - expected_message, - content_type="application/x-www-form-urlencoded", - ) diff --git a/zerver/webhooks/solano/view.py b/zerver/webhooks/solano/view.py deleted file mode 100644 index 65c9750bdf..0000000000 --- a/zerver/webhooks/solano/view.py +++ /dev/null @@ -1,81 +0,0 @@ -# Webhooks for external integrations. -from django.core.exceptions import ValidationError -from django.http import HttpRequest, HttpResponse - -from zerver.decorator import webhook_view -from zerver.lib.response import json_success -from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint -from zerver.lib.validator import WildValue, check_string -from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.webhooks.git import get_short_sha -from zerver.models import UserProfile - -MESSAGE_TEMPLATE = """ -Build update (see [build log]({build_log_url})): -* **Author**: {author} -* **Commit**: [{commit_id}]({commit_url}) -* **Status**: {status} {emoji} -""".strip() - -ALL_EVENT_TYPES = ["first-fail", "stop", "received"] - - -@webhook_view("SolanoLabs", all_event_types=ALL_EVENT_TYPES) -@typed_endpoint -def api_solano_webhook( - request: HttpRequest, - user_profile: UserProfile, - *, - payload: JsonBodyPayload[WildValue], -) -> HttpResponse: - event = payload["event"].tame(check_string) - topic_name = "build update" - if event == "test": - return handle_test_event(request, user_profile, topic_name) - try: - author = payload["committers"][0].tame(check_string) - except ValidationError: - author = "Unknown" - status = payload["status"].tame(check_string) - build_log = payload["url"].tame(check_string) - repository = payload["repository"]["url"].tame(check_string) - commit_id = payload["commit_id"].tame(check_string) - - good_status = ["passed"] - bad_status = ["failed", "error"] - neutral_status = ["running"] - emoji = "" - if status in good_status: - emoji = ":thumbs_up:" - elif status in bad_status: - emoji = ":thumbs_down:" - elif status in neutral_status: - emoji = ":arrows_counterclockwise:" - - # If the service is not one of the following, the URL is of the repository home, not the individual - # commit itself. - commit_url = repository.split("@")[1] - if "github" in repository: - commit_url += f"/commit/{commit_id}" - elif "bitbucket" in repository: - commit_url += f"/commits/{commit_id}" - elif "gitlab" in repository: - commit_url += f"/pipelines/{commit_id}" - - body = MESSAGE_TEMPLATE.format( - author=author, - build_log_url=build_log, - commit_id=get_short_sha(commit_id), - commit_url=commit_url, - status=status, - emoji=emoji, - ) - - check_send_webhook_message(request, user_profile, topic_name, body, event) - return json_success(request) - - -def handle_test_event(request: HttpRequest, user_profile: UserProfile, topic: str) -> HttpResponse: - body = "Solano webhook set up correctly." - check_send_webhook_message(request, user_profile, topic, body) - return json_success(request)