mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
tools: Reimplement CI failure script without using CircleCI endpoint.
Using curl to POST to the CircleCI workflow endpoint on CZO: - Doesn't work on zulip/zulip@main (CZO runs a revert) - Sets a bad example for other orgs - Robs us of an opportunity to dogfood our own zulip/github-actions-zulip Refactor the Actions workflows in this repo to report failure states using the Zulip Action, and reimplement the related helper scripts in Python, since they'd previously mostly shelled out to Python anyway.
This commit is contained in:
22
tools/ci/generate-failure-message
Executable file
22
tools/ci/generate-failure-message
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def get_build_url_from_environment() -> str:
|
||||
server = os.environ["GITHUB_SERVER_URL"]
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
run_id = os.environ["GITHUB_RUN_ID"]
|
||||
return f"{server}/{repo}/actions/runs/{run_id}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
branch = os.environ.get("GITHUB_REF", "unknown branch").split("/")[-1]
|
||||
topic = f"{branch} failing"
|
||||
build_url = get_build_url_from_environment()
|
||||
github_actor = os.environ.get("GITHUB_ACTOR", "unknown user")
|
||||
content = f"[Build]({build_url}) triggered by {github_actor} on branch `{branch}` has failed."
|
||||
|
||||
# Output in the key-value pair format GitHub Actions outputs are expected
|
||||
# to be in.
|
||||
print(f"topic={topic}\ncontent={content}")
|
||||
@@ -39,7 +39,7 @@ cp -a \
|
||||
tools/ci/production-upgrade \
|
||||
tools/ci/production-pgroonga \
|
||||
tools/ci/production-upgrade-pg \
|
||||
tools/ci/send-failure-message \
|
||||
tools/ci/generate-failure-message \
|
||||
package.json yarn.lock \
|
||||
/tmp/production-build
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [[ "$ZULIP_BOT_KEY" != "" && "$GITHUB_REPOSITORY" == "zulip/zulip" ]]; then
|
||||
BRANCH="$(python3 -c 'import sys; print(sys.argv[1].split("/")[-1])' "$GITHUB_REF")"
|
||||
URI_ESCAPED_TOPIC="$(python3 -c 'import sys; import urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$BRANCH failing")"
|
||||
curl -fL -H "Content-Type: application/json" \
|
||||
-X POST -i 'https://chat.zulip.org/api/v1/external/circleci?api_key='"$ZULIP_BOT_KEY"'&stream=automated%20testing&topic='"$URI_ESCAPED_TOPIC" \
|
||||
-d '{"payload": { "branch": "'"$BRANCH"'", "reponame": "'"$GITHUB_REPOSITORY"'", "status": "failed", "build_url": "'"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"'", "username": "'"$GITHUB_ACTOR"'"}}'
|
||||
fi
|
||||
Reference in New Issue
Block a user