From b27c572da2c1e9579f76a307cb1efb61c2ba9dad Mon Sep 17 00:00:00 2001 From: Ivan Razumov Date: Mon, 17 Feb 2025 15:21:42 +0100 Subject: [PATCH] Collect commit statuses to update --- common/github_reports.sh | 3 ++- update-commit-statues-matching.py | 41 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 update-commit-statues-matching.py diff --git a/common/github_reports.sh b/common/github_reports.sh index 90424159683f..e5ae1ca44ae6 100644 --- a/common/github_reports.sh +++ b/common/github_reports.sh @@ -22,7 +22,8 @@ function mark_commit_status_all_prs () { if [ $(echo $CMSSW_QUEUE | grep '_X' | wc -l) -gt 0 ] ; then CMSSW_FLAVOR=$(echo $CMSSW_QUEUE | cut -d_ -f4) fi - if [ "${CMSSW_FLAVOR}" != "X" ] ; then CONTEXT="${CMSSW_FLAVOR}/${CONTEXT}" ; fi + if [ "${CMSSW_FLAVOR}" != "X" ] ; then CMSSW_FLAVOR="default" ; fi + CONTEXT="${CMSSW_FLAVOR}/${CONTEXT}" if [ "$1" != "" ] ; then CONTEXT="${CONTEXT}/$1" ; fi else CONTEXT="${COMMIT_STATUS_CONTEXT}" diff --git a/update-commit-statues-matching.py b/update-commit-statues-matching.py new file mode 100644 index 000000000000..58673f6bd0de --- /dev/null +++ b/update-commit-statues-matching.py @@ -0,0 +1,41 @@ +import github_utils +import argparse + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--repository", "-r") + parser.add_argument("--commit", "-c") + parser.add_argument("--architecture", "-a") + parser.add_argument("--queue", "-u", required=False) + parser.add_argument("--prefix", "-p") + args = parser.parse_args() + + status_suffix = args.architecture + if args.queue: + flavor = args.queue.split("_")[3] + if flavor != "X": + status_suffix = flavor + "/" + status_suffix + + all_statuses = github_utils.get_combined_statuses(args.commit, args.repository).get( + "statuses", [] + ) + index = 0 + + for status in all_statuses: + if ( + status["context"].startswith(args.prefix + "/" + status_suffix) + and status["state"] == "pending" + ): + with open("update-pr-status-{0}.prop".format(index), "w") as f: + f.write("REPOSITORY={0}\n".format(args.repository)) + f.write("PULL_REQUEST={0}\n".format(args.commit)) + f.write("CONTEXT={0}\n".format(status["context"])) + f.write("STATUS=error\n") + f.write("STATUS_MESSAGE=Stuck due to all nodes being offline\n") + + index = index + 1 + + +if __name__ == "__main__": + main()