[dpdk-ci] [PATCH] tools: add patchwork polling

Thomas Monjalon thomas at monjalon.net
Fri Jun 8 09:25:26 CEST 2018


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

Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
Signed-off-by: Ali Alnubani <alialnu at 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



More information about the ci mailing list