Skip to content

Commit

Permalink
Add cms-bot command to add metadata to issues and PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
iarspider committed Aug 19, 2024
1 parent d2d24cd commit d730ead
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions jenkins-jobs/es-link-issue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

import es_utils
import base64


def main():
data = os.getenv("DATA", None)
data = base64.b64decode(data.replace("@", "\n").encode()).decode()
doc = json.loads(data)
index = doc.pop("index")
doc["@timestamp"] = int(time() * 1000)
payload = json.dumps(doc)
es_utils.send_payload(index + "-failures", index, None, payload)


if __name__ == "__main__":
main()
14 changes: 14 additions & 0 deletions process_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def format(s, **kwds):
r"^\s*(?:(?:@|)cmsbuild\s*[,]*\s+|)(?:please\s*[,]*\s+|)ignore\s+tests-rejected\s+(?:with|)([a-z -]+)$",
re.I,
)
REGEX_FAILURE_METADATA = re.compile(
r"^\s*(?:(?:@|)cmsbuild\s*[,]*\s+|)(?:please\s*[,]*\s+|)(?:attach\s+|)failure-metadata\s+(.+)$",
re.I,
)
REGEX_COMMITS_CACHE = re.compile(r"<!-- (?:commits|bot) cache: (.*) -->", re.DOTALL)
REGEX_IGNORE_COMMIT_COUNT = "\+commit-count"
REGEX_IGNORE_FILE_COUNT = "\+file-count"
Expand Down Expand Up @@ -1381,6 +1385,16 @@ def process_pr(repo_config, gh, repo, issue, dryRun, cmsbuild_user=None, force=F
code_check_apply_patch = True
set_comment_emoji_cache(dryRun, bot_cache, comment, repository, emoji="+1")

m = REGEX_FAILURE_DATA.match(first_line)
if m and commenter in CMSSW_ISSUES_TRACKERS:
if not has_user_emoji(bot_cache, comment, repository, "+1", cmsbuild_user):
data = m[1].strip()
# b64-encode data to safely pass it as enviroment variable; replace new-lines with @
data = base64.b64encode(data.encode()).decode().replace("\n", "@")
with open("failure-metadata.prop", "w") as f:
f.write("DATA=" + data)
set_comment_emoji_cache(dryRun, bot_cache, comment, repository, "+1", True)

selected_cats = []

if re.match("^([+]1|approve[d]?|sign|signed)$", first_line, re.I):
Expand Down

0 comments on commit d730ead

Please sign in to comment.