DPDK CI discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: ci@dpdk.org
Cc: Ali Alnubani <alialnu@mellanox.com>
Subject: [dpdk-ci] [PATCH] tools: add patchwork polling
Date: Fri,  8 Jun 2018 09:25:26 +0200	[thread overview]
Message-ID: <20180608072526.24409-1-thomas@monjalon.net> (raw)

This script should be run as a daemon to launch a per-patch command.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
---
 tools/poll-pw | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100755 tools/poll-pw

diff --git a/tools/poll-pw b/tools/poll-pw
new file mode 100755
index 0000000..b533591
--- /dev/null
+++ b/tools/poll-pw
@@ -0,0 +1,56 @@
+#! /bin/sh -e
+
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2017 6WIND S.A.
+# Copyright 2018 Mellanox Technologies, Ltd
+
+print_usage () {
+	cat <<- END_OF_HELP
+	usage: $(basename $0) <counter> <command>
+
+	Poll patchwork and call command for each patch.
+	The first patchwork id to be checked is read from the counter file.
+	The command should use '$1' to be evaluated as patchwork id.
+	When a patch is found and the command is successful,
+	then the counter is incremented.
+	END_OF_HELP
+}
+
+while getopts h arg ; do
+	case $arg in
+		h ) print_usage ; exit 0 ;;
+		? ) print_usage >&2 ; exit 1 ;;
+	esac
+done
+if [ $# -lt 2 ] ; then
+	printf 'missing argument\n\n' >&2
+	print_usage >&2
+	exit 1
+fi
+shift $(($OPTIND - 1))
+counter=$1
+shift
+cmd=$*
+
+callcmd () # <patchwork id>
+{
+	eval $cmd
+}
+
+checkid () # <patchwork id>
+{
+	curl -sfIo /dev/null https://dpdk.org/dev/patchwork/api/patches/$1/ ||
+	curl -sfIo /dev/null https://dpdk.org/dev/patchwork/api/covers/$1/
+}
+
+pwid=$(cat $counter)
+while true ; do
+	# process all recent patches
+	while checkid $pwid ; do
+		callcmd $pwid || break
+		pwid=$(($pwid + 1))
+		echo $pwid >$counter
+	done
+	# pause before next check
+	sleep 100
+done
-- 
2.17.1

                 reply	other threads:[~2018-06-08  7:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180608072526.24409-1-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=alialnu@mellanox.com \
    --cc=ci@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).