From 3c08ec2f40279eb1910dfe1df4de629d6b116f4c Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Thu, 22 Sep 2022 11:36:24 +0200 Subject: [PATCH 1/2] Don't delay daily tags for draft PRs Draft PRs are not tested until marked as non-draft, so there's no point in waiting for them. --- ci/check-open-pr | 51 +++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/ci/check-open-pr b/ci/check-open-pr index 90058296..545d0407 100755 --- a/ci/check-open-pr +++ b/ci/check-open-pr @@ -9,10 +9,13 @@ # we do not need to wait any longer. from __future__ import print_function -from github import Github,GithubException -import os, sys, pytz -from datetime import datetime import json +import os +import sys +from datetime import datetime +import pytz +from github import Github + def utc_to_local(utc_dt): tz = pytz.timezone("Europe/Zurich") @@ -53,25 +56,29 @@ for pull in gh.get_repo(repo_name).get_pulls(): wait_for_build = True what_approved = None - # Collect statuses (review and required build checks). Beware, states are - # cumulative (state history is kept). We should only keep the first one per - # given context, the others are old! - for st in pull.base.repo.get_commit(pull.head.sha).get_statuses(): - if st.context == "review" and not review: - review = st.state - what_approved = st.description - if st.context in checks and not st.context in build: - # This is one of the mandatory tests - build[st.context] = st.state - if st.state == "error": - wait_for_build = False - - # Take a decision. If we need to wait, exit from the program with nonzero - # Policy: we need all PRs to be: - # * opened before the deadline, - # * review == "success" with status == "merge approved" (not just testing) - # * all build statuses must NOT be "error" - wait_for_build = (wait_for_build and review == "success" and what_approved == "merge approved") + if pull.draft: + wait_for_build = False + else: + # Collect statuses (review and required build checks). Beware, states are + # cumulative (state history is kept). We should only keep the first one per + # given context, the others are old! + for st in pull.base.repo.get_commit(pull.head.sha).get_statuses(): + if st.context == "review" and not review: + review = st.state + what_approved = st.description + if st.context in checks and st.context not in build: + # This is one of the mandatory tests + build[st.context] = st.state + if st.state == "error": + wait_for_build = False + + # Take a decision. If we need to wait, exit from the program with nonzero + # Policy: we need all PRs to be: + # * opened before the deadline, + # * review == "success" with status == "merge approved" (not just testing) + # * all build statuses must NOT be "error" + wait_for_build = (wait_for_build and review == "success" and + what_approved == "merge approved") # Print out the current status decision = "must wait" if wait_for_build else "not waiting: bad state" From b39076566067a40727e2b038a8aef611d599f7bc Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Thu, 22 Sep 2022 11:52:49 +0200 Subject: [PATCH 2/2] Update PyGithub so that we can use `pull.draft` --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 71b43e77..6654d788 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -PyGithub==1.45 +PyGithub==1.55 argparse requests pytz diff --git a/setup.py b/setup.py index ccd56763..a45b2e29 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ with open(path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() -install_requires = ['PyGithub==1.45', 'argparse', 'requests', 'pytz', 's3cmd', +install_requires = ['PyGithub==1.55', 'argparse', 'requests', 'pytz', 's3cmd', 'pyyaml'] # Old setuptools versions (which pip2 uses) don't support range comparisons # (like :python_version >= "3.6") in extras_require, so do this ourselves here.