[dpdk-ci] [PATCH 9/9] tools: filter new patchwork IDs by project name

Ali Alnubani alialnu at oss.nvidia.com
Mon Sep 6 17:45:37 CEST 2021


Different projects require different checks usually, this
patch modifies the script so that it requires a project's name
which it passes as a parameter with the API end point.

Example usage:
$ export TZ="Europe/Paris"
$ export MAINTAINERS_FILE_PATH=/path/to/dpdk/MAINTAINERS
$ ./tools/poll-pw series DPDK /path/to/last.txt \
    '/path/to/maintainers.py --command set_pw_delegate --type series $1'

Signed-off-by: Ali Alnubani <alialnu at nvidia.com>
---
 tools/poll-pw | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/poll-pw b/tools/poll-pw
index 6017146..67251cc 100755
--- a/tools/poll-pw
+++ b/tools/poll-pw
@@ -9,7 +9,7 @@ PAUSE_SECONDS=100
 
 print_usage () {
 	cat <<- END_OF_HELP
-	usage: $(basename $0) [OPTIONS] <series|patches> </path/to/last.txt> <command>
+	usage: $(basename $0) [OPTIONS] <series|patches> <project> </path/to/last.txt> <command>
 
 	Poll patchwork and call a command for each new patch/series id.
 	The first date to filter with is read from the specified file.
@@ -31,15 +31,16 @@ while getopts h arg ; do
 	esac
 done
 
-if [ $# -lt 3 ] ; then
+if [ $# -lt 4 ] ; then
 	printf 'missing argument(s)\n\n' >&2
 	print_usage >&2
 	exit 1
 fi
 shift $(($OPTIND - 1))
 resource_type=$1
-since_file=$2
-shift 2
+project=$2
+since_file=$3
+shift 3
 cmd=$*
 
 if ! curl -sfIo /dev/null $URL/$resource_type ; then
@@ -47,6 +48,12 @@ if ! curl -sfIo /dev/null $URL/$resource_type ; then
 	exit 1
 fi
 
+curl -s $URL/projects/ | jq '.[].name' | grep -qi "^\"${project}\"$"
+if [ ! $? -eq 0 ] ; then
+	echo "The project '$project' doesn't exist."
+	exit 1
+fi
+
 if [ ! -f "$since_file" ] ; then
 	echo "The file '$since_file' doesn't exist."
 	exit 1
@@ -58,7 +65,7 @@ if [ ! $? -eq 0 ] ; then
 	exit 1
 fi
 
-URL="${URL}/${resource_type}/?"
+URL="${URL}/${resource_type}/?project=${project}&"
 
 callcmd () # <patchwork id>
 {
-- 
2.25.1



More information about the ci mailing list