diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-12-20 14:51:41 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-12-20 14:51:41 +0100 |
commit | 58c4b1f83c531c0c61d153eb85eb8c7cac2e3449 (patch) | |
tree | 2cbd41266c05678a0f99c1e2c8efe88f2466c2b3 | |
parent | c70ceea3757a0664131605a012b2d41d81edb935 (diff) | |
download | psutil-58c4b1f83c531c0c61d153eb85eb8c7cac2e3449.tar.gz |
adjust CI bots
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r-- | .github/workflows/build.yml | 22 | ||||
-rw-r--r-- | .github/workflows/issues.py | 94 | ||||
-rw-r--r-- | .github/workflows/issues.yml | 2 | ||||
-rw-r--r-- | HISTORY.rst | 3 | ||||
-rw-r--r-- | psutil/__init__.py | 2 |
5 files changed, 88 insertions, 35 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25efdbc1..8427a929 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,20 @@ # Executed on every push by GitHub Actions. This runs CI tests and -# generates wheels on the following platforms: +# generates wheels (not all) on the following platforms: # # * Linux # * macOS +# * Windows (commented) # * FreeBSD # -# Windows works as well but it's disabled (we do it via AppVeyor). # To skip certain builds see: # https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip +# +# External GH actions: +# * https://github.com/actions/checkout +# * https://github.com/actions/setup-python +# * https://github.com/actions/upload-artifact +# * https://github.com/marketplace/actions/cancel-workflow-action +# * https://github.com/vmactions/freebsd-vm on: [push] name: build @@ -85,6 +92,7 @@ jobs: run: | set +e export \ + PYTHONUNBUFFERED=1 \ PYTHONWARNINGS=always \ PSUTIL_TESTING=1 \ PSUTIL_DEBUG=1 @@ -98,10 +106,12 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - name: 'Linters' + - name: 'Run linters' run: | - python -m pip install flake8 - python -m flake8 . + python2 -m pip install flake8 + python3 -m pip install flake8 + python2 -m flake8 . + python3 -m flake8 . echo "flake8 linting OK" - find . -type f \( -iname "*.c" -o -iname "*.h" \) | xargs python scripts/internal/clinter.py + find . -type f \( -iname "*.c" -o -iname "*.h" \) | xargs python3 scripts/internal/clinter.py echo "C linting OK" diff --git a/.github/workflows/issues.py b/.github/workflows/issues.py index c9f92d31..91e12202 100644 --- a/.github/workflows/issues.py +++ b/.github/workflows/issues.py @@ -10,9 +10,11 @@ is created. Assign labels, provide replies, closes issues, etc. depending on the situation. """ +import functools +import json import os import re -import sys +from pprint import pprint as pp from github import Github @@ -122,24 +124,15 @@ If this was a mistake or you think there's a bug with psutil installation \ process, please add a comment to reopen this issue. """ +# REPLY_UPDATE_CHANGELOG = """\ +# """ -# --- utils - -def is_pr(issue): - return 'PullRequest' in issue.__module__ - - -def is_issue(issue): - return not is_pr(issue) - - -def is_new(issue): - return issue.comments == 0 +# --- github API utils -def is_comment(issue): - return not is_new(issue) +def is_pr(issue): + return issue.pull_request is not None def has_label(issue, label): @@ -161,6 +154,49 @@ def get_repo(): return Github(token).get_repo(repo) +# --- event utils + + +@functools.lru_cache() +def _get_event_data(): + ret = json.load(open(os.environ["GITHUB_EVENT_PATH"])) + pp(ret) + return ret + + +def is_event_new_issue(): + data = _get_event_data() + try: + return data['action'] == 'opened' and 'issue' in data + except KeyError: + return False + + +def is_event_new_pr(): + data = _get_event_data() + try: + return data['action'] == 'opened' and 'pull_request' in data + except KeyError: + return False + + +def is_event_new_comment(): + data = _get_event_data() + try: + return data['action'] == 'created' and 'comment' in data + except KeyError: + return False + + +def get_issue(): + data = _get_event_data() + try: + num = data['issue']['number'] + except KeyError: + num = data['pull_request']['number'] + return get_repo().get_issue(number=num) + + # --- actions @@ -275,6 +311,10 @@ def on_new_issue(issue): def on_new_pr(issue): pass + # pr = get_repo().get_pull(issue.number) + # files = [x.filename for x in list(pr.get_files())] + # if "HISTORY.rst" not in files: + # issue.create_comment(REPLY_UPDATE_CHANGELOG) def on_new_comment(issue): @@ -282,21 +322,25 @@ def on_new_comment(issue): def main(): - issue = get_repo().get_issue(number=int(sys.argv[1])) - stype = "issue" if is_issue(issue) else "PR" + issue = get_issue() + stype = "PR" if is_pr(issue) else "issue" log("running issue bot for %s %r" % (stype, issue)) - if is_new(issue): - log("new %s\n%s" % (stype, issue.body)) + 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 is_issue(issue): - on_new_issue(issue) - if is_pr(issue): - on_new_pr(issue) - else: - log("new comment: \n" % 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) + on_new_pr(issue) + elif is_event_new_comment(): + log("created new comment for %s" % issue) on_new_comment(issue) + else: + raise ValueError("unhandled event") if __name__ == '__main__': diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index 2c2e38e3..fa739eab 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -25,4 +25,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - python .github/workflows/issues.py ${{ github.event.issue.number }} + PYTHONUNBUFFERED=1 python .github/workflows/issues.py diff --git a/HISTORY.rst b/HISTORY.rst index 66efe586..cf81ddc7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,6 @@ *Bug tracker at https://github.com/giampaolo/psutil/issues* -5.8.0 (IN DEVELOPMENT) +5.8.1 (IN DEVELOPMENT) ====================== XXXX-XX-XX @@ -11,7 +11,6 @@ XXXX-XX-XX determined (instead of crashing). - 1892_: [macOS] psutil.cpu_freq() broken on Apple M1. - 5.8.0 ===== diff --git a/psutil/__init__.py b/psutil/__init__.py index acd42ac2..488eb694 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -209,7 +209,7 @@ if hasattr(_psplatform.Process, "rlimit"): AF_LINK = _psplatform.AF_LINK __author__ = "Giampaolo Rodola'" -__version__ = "5.8.0" +__version__ = "5.8.1" version_info = tuple([int(num) for num in __version__.split('.')]) _timer = getattr(time, 'monotonic', time.time) |