-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix truncation of good first issues when posting to Zulip
The Zulip API has a max message size and our "good first issues" posting hits it resulting in message truncation and a loss of content. This commit adds a Python script to batch up "good first issues" content into 1 or more messages so that it doesn't get truncated. Also includes new image to run in as we need additional dependencies that the "post sync" image doesn't need. And this adds a PR check to link the python script and make sure it is all kosher. Fixes #18
- Loading branch information
1 parent
e7dd8f2
commit 8ccab72
Showing
6 changed files
with
123 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ARG FROM_TAG=release | ||
FROM ghcr.io/ponylang/shared-docker-ci-x86-64-unknown-linux-builder-with-libressl-3.7.3:${FROM_TAG} | ||
|
||
RUN apk add --update --no-cache \ | ||
pcre2-dev \ | ||
python3 \ | ||
python3-dev \ | ||
py3-pip \ | ||
|
||
RUN pip3 install --upgrade pip \ | ||
pylint \ | ||
zulip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
# | ||
# *** You should already be logged in to GitHub Container Registrṡ when you run | ||
# this *** | ||
# | ||
|
||
DOCKERFILE_DIR="$(dirname "$0")" | ||
NAME="ghcr.io/ponylang/pony-sync-helper-ci-good-first-issues" | ||
|
||
# built from x86-64-unknown-linux-builder release tag | ||
FROM_TAG=release | ||
TAG_AS=release | ||
docker build --pull --build-arg FROM_TAG="${FROM_TAG}" \ | ||
-t "${NAME}:${TAG_AS}" \ | ||
"${DOCKERFILE_DIR}" | ||
docker push "${NAME}:${TAG_AS}" | ||
|
||
# built from x86-64-unknown-linux-builder latest tag | ||
FROM_TAG=latest | ||
TAG_AS=latest | ||
docker build --pull --build-arg FROM_TAG="${FROM_TAG}" \ | ||
-t "${NAME}:${TAG_AS}" \ | ||
"${DOCKERFILE_DIR}" | ||
docker push "${NAME}:${TAG_AS}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/python3 | ||
|
||
from datetime import datetime | ||
import os | ||
import zulip | ||
|
||
issues_str = os.environ['ISSUES'] | ||
issues_lines = issues_str.splitlines() | ||
|
||
messages = [] | ||
current_message = "" | ||
for line in issues_lines: | ||
if len(current_message) + len(line) <= 8092 | ||
current_message += line + "\n" | ||
else: | ||
messages.append(current_message) | ||
current_message = line + "\n" | ||
|
||
# set up topic with today's date | ||
msg_date = datetime.today().strftime('%Y-%m-%d') | ||
msg_topic = "Good first issues as of " + msg_date | ||
|
||
zulip_client = zulip.Client() | ||
for message in messages: | ||
request = { | ||
"type": "stream", | ||
"to": "contribute to Pony", | ||
"topic": msg_topic, | ||
"content": message | ||
} | ||
result = zulip_client.send_message(request) |