DPDK CI discussions
 help / color / 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, back to index

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

DPDK CI discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/ci/0 ci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ci ci/ http://inbox.dpdk.org/ci \
		ci@dpdk.org
	public-inbox-index ci


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.ci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox