summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2022-11-08 22:51:09 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2022-11-08 22:51:09 +0100
commit6941261ad010d4d1e936af22fec224e9900509c0 (patch)
treeda8cd59f1d1c66204369845a6fa3e08f4e368def /.github
parent7da5a631234af1425027b9190dd6c1029327ae6f (diff)
downloadpsutil-6941261ad010d4d1e936af22fec224e9900509c0.tar.gz
update and fix issue/PR labeler script (CI)
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/issues.py28
-rw-r--r--.github/workflows/issues.yml13
2 files changed, 27 insertions, 14 deletions
diff --git a/.github/workflows/issues.py b/.github/workflows/issues.py
index ef686495..fce52ce7 100644
--- a/.github/workflows/issues.py
+++ b/.github/workflows/issues.py
@@ -194,9 +194,9 @@ def get_issue():
def log(msg):
if '\n' in msg or "\r\n" in msg:
- print(">>>\n%s\n<<<" % msg)
+ print(">>>\n%s\n<<<" % msg, flush=True)
else:
- print(">>> %s <<<" % msg)
+ print(">>> %s <<<" % msg, flush=True)
def add_label(issue, label):
@@ -221,6 +221,7 @@ def add_label(issue, label):
def _guess_labels_from_text(issue, text):
+ assert isinstance(text, str), text
for label, keywords in LABELS_MAP.items():
for keyword in keywords:
if keyword.lower() in text.lower():
@@ -228,11 +229,13 @@ def _guess_labels_from_text(issue, text):
def add_labels_from_text(issue, text):
+ assert isinstance(text, str), text
for label, keyword in _guess_labels_from_text(issue, text):
add_label(issue, label)
def add_labels_from_new_body(issue, text):
+ assert isinstance(text, str), text
log("start searching for template lines in new issue/PR body")
# add os label
r = re.search(r"\* OS:.*?\n", text)
@@ -288,14 +291,21 @@ def add_labels_from_new_body(issue, text):
def on_new_issue(issue):
def has_text(text):
- return text in issue.title.lower() or text in issue.body.lower()
+ return text in issue.title.lower() or \
+ (issue.body and text in issue.body.lower())
+
+ def body_mentions_python_h():
+ if not issue.body:
+ return False
+ body = issue.body.replace(' ', '')
+ return "#include<Python.h>\n^~~~" in body or \
+ "#include<Python.h>\r\n^~~~" in body
log("searching for missing Python.h")
if has_text("missing python.h") or \
has_text("python.h: no such file or directory") or \
- "#include<Python.h>\n^~~~" in issue.body.replace(' ', '') or \
- "#include<Python.h>\r\n^~~~" in issue.body.replace(' ', ''):
- log("found")
+ body_mentions_python_h():
+ log("found mention of Python.h")
issue.create_comment(REPLY_MISSING_PYTHON_HEADERS)
issue.edit(state='closed')
return
@@ -317,12 +327,14 @@ def main():
if is_event_new_issue():
log("created new issue %s" % issue)
add_labels_from_text(issue, issue.title)
- add_labels_from_new_body(issue, issue.body)
+ if issue.body:
+ add_labels_from_new_body(issue, issue.body)
on_new_issue(issue)
elif is_event_new_pr():
log("created new PR %s" % issue)
add_labels_from_text(issue, issue.title)
- add_labels_from_new_body(issue, issue.body)
+ if issue.body:
+ add_labels_from_new_body(issue, issue.body)
on_new_pr(issue)
else:
log("unhandled event")
diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml
index d5118157..245d00cb 100644
--- a/.github/workflows/issues.yml
+++ b/.github/workflows/issues.yml
@@ -1,4 +1,5 @@
# Fired by Github Actions every time an issue, PR or comment is created.
+
name: issues
on:
issues:
@@ -14,17 +15,17 @@ jobs:
# install python
- uses: actions/checkout@v3
- name: Install Python
- uses: actions/setup-python@v3
+ uses: actions/setup-python@v4
with:
- python-version: 3.8
- cache: pip
- cache-dependency-path: .github/workflows/issues.yml
+ python-version: '3.x'
+
# install deps
- name: Install deps
- run: python -m pip install --upgrade pip PyGithub
+ run: python3 -m pip install PyGithub
+
# run
- name: Run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
- PYTHONUNBUFFERED=1 python .github/workflows/issues.py
+ PYTHONUNBUFFERED=1 PYTHONWARNINGS=always python3 .github/workflows/issues.py