-
-
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
a6b41b8
commit cc1e9f7
Showing
6 changed files
with
149 additions
and
20 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,16 @@ | ||
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 | ||
|
||
COPY post-good-first-issues.py /post-good-first-issues.py | ||
|
||
RUN chmod a+x /post-good-first-issues.py |
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,33 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
# | ||
# *** You should already be logged in to GitHub Container Registrṡ when you run | ||
# this *** | ||
# | ||
# *** | ||
# This must be run from the root of the repository like: | ||
# bash .ci-dockerfiles/good-first-issues/build-and-push.bash | ||
# *** | ||
# | ||
|
||
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}" \ | ||
-f "${DOCKERFILE_DIR}/Dockerfile" . | ||
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}" \ | ||
-f "${DOCKERFILE_DIR}/Dockerfile" . | ||
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,40 @@ | ||
#!/usr/bin/python3 | ||
# pylint: disable=C0103 | ||
# pylint: disable=C0114 | ||
|
||
from datetime import datetime | ||
import sys | ||
import zulip | ||
|
||
messages = [] | ||
current_message = "" | ||
for line in sys.stdin.readlines(): | ||
if len(current_message) + len(line) <= 7000: | ||
current_message += line + "\n" | ||
else: | ||
# We have a decent chunk of cotent to post at this point. | ||
# We are now looking for the next repository to start a new message. | ||
# We don't want to break during a repository as it messes up the | ||
# markdown formatting of the message in Zulip. | ||
if line.startswith("**ponylang/"): | ||
messages.append(current_message) | ||
current_message = line + "\n" | ||
else: | ||
current_message += line + "\n" | ||
|
||
# add the final message in to messages | ||
messages.append(current_message) | ||
|
||
# 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) |