DPDK CI discussions
 help / color / mirror / Atom feed
* [dpdk-ci] [PATCH] tools: add patchwork polling
@ 2018-06-08  7:25 Thomas Monjalon
  0 siblings, 0 replies; only message in thread
From: Thomas Monjalon @ 2018-06-08  7:25 UTC (permalink / raw)
  To: ci; +Cc: Ali Alnubani

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-06-08  7:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-08  7:25 [dpdk-ci] [PATCH] tools: add patchwork polling Thomas Monjalon

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).