snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-15 15:05:30 +05:00
commit 64898b2c79
8999 changed files with 1757358 additions and 0 deletions

View File

View File

@@ -0,0 +1,35 @@
# Zulip Travis CI integration
See your Travis CI build notifications in Zulip!
{start_tabs}
1. {!create-an-incoming-webhook.md!}
1. {!generate-webhook-url-basic.md!}
1. Add the following to the bottom of your `.travis.yml` file, and push
the change to your repository:
```
notifications:
webhooks:
- <URL generated above>
```
{end_tabs}
{!congrats.md!}
![](/static/images/integrations/travis/001.png)
{!event-filtering-additional-feature.md!}
### Related documentation
- [Travis CI's webhook documentation][1]
{!webhooks-url-specification.md!}
[1]: https://docs.travis-ci.com/user/notifications/#configuring-webhook-notifications

View File

@@ -0,0 +1,83 @@
{
"id": 277712204,
"number": "1",
"config": {
"language": "ruby",
"os": [
"linux"
],
"dist": "focal",
"notifications": {
"webhooks": [
{
"urls": [
"https://338d-49-37-250-23.ngrok-free.app/api/v1/external/travis?api_key=qgbRyggtXVwFxCWeEwRS2sCeyfMleyFZ&stream=12"
],
"on_success": "always",
"on_failure": "always",
"on_start": "always"
}
]
}
},
"type": "push",
"state": "started",
"status": null,
"result": null,
"status_message": "Pending",
"result_message": "Pending",
"started_at": "2026-03-18T08:16:56Z",
"finished_at": null,
"duration": null,
"build_url": "https://app.travis-ci.com/sathwikshetty33/travis-test/builds/277712204",
"commit_id": 1277737906,
"commit": "193da1b723460e185115a27554dfddab7ae0ec6e",
"base_commit": null,
"head_commit": null,
"branch": "main",
"message": "Add Projects model.",
"compare_url": "https://github.com/sathwikshetty33/travis-test/commit/193da1b72346",
"committed_at": "2026-03-18T08:16:12Z",
"author_name": "sathwikshetty33",
"author_email": "sathwikshetty2005@gmail.com",
"committer_name": "sathwikshetty33",
"committer_email": "sathwikshetty2005@gmail.com",
"pull_request": false,
"pull_request_number": null,
"pull_request_title": null,
"tag": null,
"repository": {
"id": 29853331,
"name": "travis-test",
"owner_name": "sathwikshetty33",
"url": null
},
"matrix": [
{
"id": 638473449,
"repository_id": 29853331,
"parent_id": 277712204,
"number": "1.1",
"state": "started",
"config": {
"os": "linux",
"language": "ruby",
"dist": "focal"
},
"status": null,
"result": null,
"commit": "193da1b723460e185115a27554dfddab7ae0ec6e",
"branch": "main",
"message": "Add Projects model.",
"compare_url": "https://github.com/sathwikshetty33/travis-test/commit/193da1b72346",
"started_at": "2026-03-18T08:16:56Z",
"finished_at": null,
"committed_at": "2026-03-18T08:16:12Z",
"author_name": "sathwikshetty33",
"author_email": "sathwikshetty2005@gmail.com",
"committer_name": "sathwikshetty33",
"committer_email": "sathwikshetty2005@gmail.com",
"allow_failure": null
}
]
}

View File

@@ -0,0 +1,83 @@
{
"id": 277927122,
"number": "42",
"config": {
"language": "ruby",
"os": [
"linux"
],
"dist": "focal",
"notifications": {
"webhooks": [
{
"urls": [
"https://41da-49-37-250-179.ngrok-free.app/api/v1/external/travis?api_key=pDmnOb1fCfy181J2aTz8k2FI3dlxcXEV&stream=7"
],
"on_success": "always",
"on_failure": "always",
"on_start": "always"
}
]
}
},
"type": "pull_request",
"state": "failed",
"status": 1,
"result": 1,
"status_message": "Failed",
"result_message": "Failed",
"started_at": "2026-04-15T16:39:52Z",
"finished_at": "2026-04-15T16:40:15Z",
"duration": 23,
"build_url": "https://app.travis-ci.com/sathwikshetty33/travis-test/builds/277927122",
"commit_id": 1291891363,
"commit": "853c38dfecb99b75e9d4987fba0c4f58eab0bae3",
"base_commit": "6864d112b255e2c26cfc48882594397c4e561bab",
"head_commit": "b2b0af11c1d6e03fe390050a97506c0a2f437d5a",
"branch": "main",
"message": "feat: Created Name.txt.",
"compare_url": "https://github.com/sathwikshetty33/travis-test/pull/2",
"committed_at": "2026-04-15T16:38:07Z",
"author_name": "Sathwik Shetty",
"author_email": "sathwikshetty2k5@gmail.com",
"committer_name": "GitHub",
"committer_email": "noreply@github.com",
"pull_request": true,
"pull_request_number": 2,
"pull_request_title": "feat: Add Name.txt.",
"tag": null,
"repository": {
"id": 29853331,
"name": "travis-test",
"owner_name": "sathwikshetty33",
"url": null
},
"matrix": [
{
"id": 638911273,
"repository_id": 29853331,
"parent_id": 277927122,
"number": "42.1",
"state": "failed",
"config": {
"os": "linux",
"language": "ruby",
"dist": "focal"
},
"status": 1,
"result": 1,
"commit": "853c38dfecb99b75e9d4987fba0c4f58eab0bae3",
"branch": "main",
"message": "feat: Created Name.txt.",
"compare_url": "https://github.com/sathwikshetty33/travis-test/pull/2",
"started_at": "2026-04-15T16:39:52Z",
"finished_at": "2026-04-15T16:40:15Z",
"committed_at": "2026-04-15T16:38:07Z",
"author_name": "Sathwik Shetty",
"author_email": "sathwikshetty2k5@gmail.com",
"committer_name": "GitHub",
"committer_email": "noreply@github.com",
"allow_failure": null
}
]
}

View File

@@ -0,0 +1,176 @@
from urllib.parse import urlencode
import orjson
from typing_extensions import override
from zerver.lib.test_classes import WebhookTestCase
class TravisHookTests(WebhookTestCase):
NON_PR_TOPIC = "travis-test / main"
PR_TOPIC = "travis-test / PR #2 feat: Add Name.txt."
EXPECTED_NON_PULL_REQUEST_MESSAGE = (
":time_ticking: Build [#1](https://app.travis-ci.com/sathwikshetty33/travis-test/builds/277712204) "
"**is in progress** for commit [Add Projects model.](https://github.com/sathwikshetty33/travis-test/commit/193da1b72346) by sathwikshetty33"
)
EXPECTED_PULL_REQUEST_MESSAGE = (
":warning: Build [#42](https://app.travis-ci.com/sathwikshetty33/travis-test/builds/277927122) "
"**failed** for commit [feat: Created Name.txt.](https://github.com/sathwikshetty33/travis-test/pull/2) by Sathwik Shetty."
)
def test_travis_message(self) -> None:
"""
Build notifications are generated by Travis after build completes.
The subject describes the repo and Stash "project". The
content describes the commits pushed.
"""
self.check_webhook(
"non_pull_request",
self.NON_PR_TOPIC,
f"{self.EXPECTED_NON_PULL_REQUEST_MESSAGE}.",
content_type="application/x-www-form-urlencoded",
)
def test_travis_only_pull_request_event(self) -> None:
self.url = f'{self.build_webhook_url()}&only_events=["pull_request"]'
self.check_webhook(
"pull_request",
self.PR_TOPIC,
self.EXPECTED_PULL_REQUEST_MESSAGE,
content_type="application/x-www-form-urlencoded",
)
self.check_webhook(
"non_pull_request",
content_type="application/x-www-form-urlencoded",
expect_noop=True,
)
def test_travis_exclude_pull_request_event(self) -> None:
self.url = f'{self.build_webhook_url()}&exclude_events=["pull_request"]'
self.check_webhook(
"pull_request",
content_type="application/x-www-form-urlencoded",
expect_noop=True,
)
self.check_webhook(
"non_pull_request",
self.NON_PR_TOPIC,
f"{self.EXPECTED_NON_PULL_REQUEST_MESSAGE}.",
content_type="application/x-www-form-urlencoded",
)
def test_travis_only_push_event(self) -> None:
self.url = f'{self.build_webhook_url()}&only_events=["push"]'
self.check_webhook(
"non_pull_request",
self.NON_PR_TOPIC,
f"{self.EXPECTED_NON_PULL_REQUEST_MESSAGE}.",
content_type="application/x-www-form-urlencoded",
)
self.check_webhook(
"pull_request",
content_type="application/x-www-form-urlencoded",
expect_noop=True,
)
def test_travis_exclude_push_event(self) -> None:
self.url = f'{self.build_webhook_url()}&exclude_events=["push"]'
self.check_webhook(
"non_pull_request",
content_type="application/x-www-form-urlencoded",
expect_noop=True,
)
self.check_webhook(
"pull_request",
self.PR_TOPIC,
self.EXPECTED_PULL_REQUEST_MESSAGE,
content_type="application/x-www-form-urlencoded",
)
def test_travis_include_glob_events(self) -> None:
self.url = f'{self.build_webhook_url()}&include_events=["*"]'
self.check_webhook(
"pull_request",
self.PR_TOPIC,
self.EXPECTED_PULL_REQUEST_MESSAGE,
content_type="application/x-www-form-urlencoded",
)
self.check_webhook(
"non_pull_request",
self.NON_PR_TOPIC,
f"{self.EXPECTED_NON_PULL_REQUEST_MESSAGE}.",
content_type="application/x-www-form-urlencoded",
)
def test_travis_exclude_glob_events(self) -> None:
self.url = f'{self.build_webhook_url()}&exclude_events=["*"]'
self.check_webhook(
"pull_request",
content_type="application/x-www-form-urlencoded",
expect_noop=True,
)
self.check_webhook(
"non_pull_request",
content_type="application/x-www-form-urlencoded",
expect_noop=True,
)
def test_travis_noop(self) -> None:
expected_error_message = """
While no message is expected given expect_noop=True,
your test code triggered an endpoint that did write
one or more new messages.
""".strip()
with self.assertRaises(Exception) as exc:
self.check_webhook(
"non_pull_request",
content_type="application/x-www-form-urlencoded",
expect_noop=True,
)
self.assertEqual(str(exc.exception), expected_error_message)
@override
def get_body(self, fixture_name: str) -> str:
if fixture_name in {"api", "cron"}:
payload = orjson.loads(
self.webhook_fixture_data("travis", "non_pull_request", file_type="json")
)
payload["type"] = fixture_name
return urlencode({"payload": orjson.dumps(payload).decode()})
return urlencode(
{"payload": self.webhook_fixture_data("travis", fixture_name, file_type="json")}
)
def test_travis_api_event(self) -> None:
self.check_webhook(
"api",
self.NON_PR_TOPIC,
f"{self.EXPECTED_NON_PULL_REQUEST_MESSAGE} (triggered by api).",
content_type="application/x-www-form-urlencoded",
)
def test_travis_cron_event(self) -> None:
self.check_webhook(
"cron",
self.NON_PR_TOPIC,
f"{self.EXPECTED_NON_PULL_REQUEST_MESSAGE} (triggered by cron).",
content_type="application/x-www-form-urlencoded",
)

View File

@@ -0,0 +1,114 @@
# Webhooks for external integrations.
from typing import Annotated
from django.http import HttpRequest, HttpResponse
from pydantic import BaseModel, Json
from zerver.decorator import webhook_view
from zerver.lib.exceptions import UnsupportedWebhookEventTypeError
from zerver.lib.response import json_success
from zerver.lib.typed_endpoint import ApiParamConfig, typed_endpoint
from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE
from zerver.models import UserProfile
ALL_EVENT_TYPES = [
"push",
"pull_request",
"api",
"cron",
]
STATUS_MAP = {
"Passed": ("passed", ":check:"),
"Fixed": ("was fixed", ":check:"),
"Failed": ("failed", ":warning:"),
"Broken": ("is broken", ":warning:"),
"Still Failing": ("is still failing", ":warning:"),
"Canceled": ("was canceled", ":no_entry:"),
"Errored": ("errored", ":rotating_light:"),
"Pending": ("is in progress", ":time_ticking:"),
}
MESSAGE_TEMPLATE = """
{emoji} Build [#{build_number}]({build_url}) **{status}** \
for commit [{commit_message}]({compare_url}) by {author}{trigger}.
""".strip()
class Repository(BaseModel):
name: str
class TravisPayload(BaseModel):
author_name: str
status_message: str
compare_url: str
build_url: str
type: str
message: str | None = None
number: str
branch: str
repository: Repository
pull_request_number: int | None = None
pull_request_title: str | None = None
def get_message_body(payload: TravisPayload, event: str) -> str:
# Extract only the first line of the commit message
# for multi-line commit messages.
commit_message = (
payload.message.strip().splitlines()[0] if payload.message else "(no commit message)"
)
trigger = f" (triggered by {event})" if event in ("api", "cron") else ""
status_message, emoji = STATUS_MAP[payload.status_message]
body = MESSAGE_TEMPLATE.format(
build_number=payload.number,
build_url=payload.build_url,
status=status_message,
commit_message=commit_message,
author=payload.author_name,
emoji=emoji,
compare_url=payload.compare_url,
trigger=trigger,
)
return body
def get_topic(payload: TravisPayload, event: str) -> str:
if event == "pull_request":
topic = TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
repo=payload.repository.name,
type="PR",
id=payload.pull_request_number,
title=payload.pull_request_title,
)
else:
topic = TOPIC_WITH_BRANCH_TEMPLATE.format(
repo=payload.repository.name,
branch=payload.branch,
)
return topic
@webhook_view("Travis", all_event_types=ALL_EVENT_TYPES)
@typed_endpoint
def api_travis_webhook(
request: HttpRequest,
user_profile: UserProfile,
*,
message: Annotated[Json[TravisPayload], ApiParamConfig("payload")],
) -> HttpResponse:
event = message.type
if event not in ALL_EVENT_TYPES:
raise UnsupportedWebhookEventTypeError(event)
body = get_message_body(message, event)
topic_name = get_topic(message, event)
check_send_webhook_message(request, user_profile, topic_name, body, event)
return json_success(request)