From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E704A0C4B for ; Mon, 8 Nov 2021 07:29:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A741410E9; Mon, 8 Nov 2021 07:29:30 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2045.outbound.protection.outlook.com [40.107.96.45]) by mails.dpdk.org (Postfix) with ESMTP id 43909410E9 for ; Mon, 8 Nov 2021 07:29:29 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lI1AFPtH6iQv+QJlsv4PIOwhaTFC/vlAIxr+9RSm5io2C31yDkgUGkkoNsnqr7vwMQ/wNYhJYSb9oXhn+x/HwfUV9t/j+OsjlNkQ4QVO90mw/TcZ7P7ed3Z2InLnGU0982/97eMcNGt5BYcbOcZQlNmeFt/U9lDOHQ6nT/nmwrM2ReLz1hwj6J/B41aEaRaegYq48DnSy7tpnIam9a41B9DeelIuLUv+0twcGExY6EwlSNJ0KFKafLClaFkEXqg5Y5IGkVO41ZFFt4nGGKHQ63sxewE6k4/84hvQaHePP5Np9xVLWYko4+VIMU9cI2yz6V4/s9bd3qXm9cmIXUKFlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EVmm6HDvNZcyqZYj5Lj+CnxiODPcz6AwSjDdVl9syuE=; b=Y7VQ4DIPJ/ae1OejoQ6R/LWkaJDHD/TR0xx4GjJkFzLn/9MVAFxCuN6kiLXMEjtjqD9LpVrxsjtOwNmv/203oD+eD9oLNSYGj8LSY6rqpriC3awpgPQZqcCTpGXpBfZJce3sIFzSHJsr1joZCbb1cCYYE28Of66QX7P3VPn4OQJ9rOXwGTlEYisCK/6MjDFh/+k3jOT7EiyjYuowYVBR9fRHUlFPNluYoNvyHkArQ1jA6KKGQu6ZA/R+PFyCZgeeHO+19MWDYf7dFYQSLoncbFXd5Ioia3gjEpT1uRiV0pH/4ALOAIlgGtna4q+/nCNehBhBRJHHlQLaW7zb9NGq9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EVmm6HDvNZcyqZYj5Lj+CnxiODPcz6AwSjDdVl9syuE=; b=dT4SK6pBEovqAjH7iw8Q+/nV+CE1grbe75hYzTXGCl40+EoZyP+TRorY8sX/T/j4Fy3JBb5gDYeNQswOvKr5Tu01nm7u1ctbr7yF8kyKVBXcQ94z6+tYv77RyYl7vSJsmM2EDfih6Oec8EuBGedXoNyevuyeKF/iPBgsxC+2PO59x4ZtBeYz8CAFhqeNiidFCdkTQVatv8KC4PwO3v0aG+BSA5217SARulRT6susTFJSRRBsftov8v5DJ8kSlcu5hAY6xeizON8X7WWe3AEPdhgthxVYRB9/55Pkz8l3FwM6L0OIBS1Pgw6f4YIxWyc7DRQjLOi1Ck8/rYYBReuirA== Received: from DM6PR03CA0067.namprd03.prod.outlook.com (2603:10b6:5:100::44) by BY5PR12MB4950.namprd12.prod.outlook.com (2603:10b6:a03:1d9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Mon, 8 Nov 2021 06:29:26 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::c8) by DM6PR03CA0067.outlook.office365.com (2603:10b6:5:100::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Mon, 8 Nov 2021 06:29:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Mon, 8 Nov 2021 06:29:26 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 8 Nov 2021 06:29:23 +0000 From: Ali Alnubani To: CC: , , , , Date: Mon, 8 Nov 2021 08:28:10 +0200 Message-ID: <20211108062815.7614-6-alialnu@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211108062815.7614-1-alialnu@nvidia.com> References: <20210906154537.1299-1-alialnu@nvidia.com> <20211108062815.7614-1-alialnu@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e744daa9-6e56-4dd6-1293-08d9a2811c9c X-MS-TrafficTypeDiagnostic: BY5PR12MB4950: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m7V2QpAm8UlWYLhz2NnpOvF5WNr4zLnbdrxcFfXROJoSOUEvRXF7TiZJz1l5TwdhkfVm8TEvLCXqeZAV/leOq4VHciDXbIQC1bWHcLncyDm7SJzgQ4zBAcv7DrYN89622gEv/UPCEq6lMp2E232eniud2o4CszCTL57U+Eexx0H/dRh5WOg+vBLxOarUEdkT/Ow6fP3wrp3XHyNqLRV3pubcc7aPeUGAWnL3C/OkJ/DIF7AVOnu5EtMjVzWEjMnRWVkHWl7KAeTmst5kDRy3k6roSGsL222NRET+9BPbhMhMWjB3EAdDWizgOHY63GRWCmMaO0ItSMmlmaKmXvwTCyFSdIV3LEc0ftrqzOv6STbVCsHH6P9Sa8LhEdo1VLHdG9B3TbfBzwu+K3Qa4KQ1jYC4AoV5JxMpWe/AZD34M1LSEfblsVVBgSK85ykIeLa2PlPSb9LC98czObuC7WOEH6uL/ggawo9Y2XQO6RqoJI/CIHqQ4RALdJVERJNQGErSZee+wC7HJKwhyZBp3XYrG9TqIygAo2gs0cVrzrDh0l5qwntpxjqzP6lsce0vtn2IzY+OHFvcxu9TyGbyXcwtAr2+sMD81smtAfzIWkZ5YoL2Vb0zxQJ3RrmG/OKhvJRVacI4Il7Zw60fg9q2dtr9CG3/yS4MYAzwpzvH+DVm3p7D/o58zmFqQJV8tBEMfPLjhUudrd6r2R+cmpLSpOYi2ibp77Z+R4FTEMz+BbzJwwZcMAnwJOh8PuMvx7w365VxCtJWNFsnzoTV5IVPBOrvhciFe5YghlG2f+w2IXhTfBM= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(336012)(47076005)(6286002)(36906005)(356005)(70586007)(26005)(1076003)(2906002)(7636003)(2616005)(5660300002)(6666004)(508600001)(8676002)(426003)(4326008)(86362001)(316002)(186003)(36756003)(82310400003)(8936002)(7696005)(70206006)(16526019)(6916009)(36860700001)(966005)(55016002)(83380400001)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2021 06:29:26.2947 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e744daa9-6e56-4dd6-1293-08d9a2811c9c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4950 Subject: [dpdk-ci] [PATCH v4 05/10] tools: add functionality for setting pw delegates X-BeenThere: ci@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK CI discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ci-bounces@dpdk.org Sender: "ci" A new command was added to set patch delegates in Patchwork based on the emails found in DPDK's MAINTAINERS file. Example usage: $ export MAINTAINERS_FILE_PATH=/path/to/dpdk/MAINTAINERS $ ./pw_maintainers_cli.py --type series set-pw-delegate SERIES_ID Signed-off-by: Ali Alnubani --- Changes in v3: - Added an argument to force overriding delegates. Changes in v4: - Force overriding delegates by default, and add an arg to change that behavior (Suggested by Thomas Monjalon). - Shorten link in set_delegate's doc. tools/pw_maintainers_cli.py | 56 +++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py index 904be2e..4527cf7 100755 --- a/tools/pw_maintainers_cli.py +++ b/tools/pw_maintainers_cli.py @@ -14,6 +14,7 @@ from requests.exceptions import HTTPError from git_pw import config from git_pw import api from git_pw import utils +from git_pw import patch as git_pw_patch """ Description: @@ -84,6 +85,33 @@ class GitPW(object): else: raise + def set_delegate(self, patch_list, delegate, skip_delegated=False): + """Set the delegate for a patch. + This overrides the current delegate. If 'skip_delegated' is set to + True, only set a delegate for patches that don't have one set already. + + Reference: + https://github.com/getpatchwork/git-pw/blob/76b79097dc0a57/git_pw/patch.py#L167 + """ + users = api.index('users', [('q', delegate)]) + if len(users) != 1: + # Zero or multiple users found + print('Cannot choose a Patchwork user to delegate to from ' + 'user list ({}). Skipping..'.format(users)) + return + for patch in patch_list: + if patch['delegate'] != None and \ + (patch['delegate'].get('email') == users[0].get('email') or \ + skip_delegated): + print('Patch {} is already delegated to {}. ' + 'Skipping..'.format( + patch['id'], patch['delegate']['email'])) + continue + print("Delegating patch {} to {}..".format( + patch['id'], users[0]['email'])) + _ = api.update( + 'patches', patch['id'], [('delegate', users[0]['id'])]) + class Diff(object): @@ -286,16 +314,21 @@ if __name__ == '__main__': default=os.environ.get('PW_TOKEN', utils.git_config('pw.token')), help='Authentication token') + parser.add_argument( + '--skip-delegated', + action='store_true', required=False, + help='Skip patches that are already delegated') parser.add_argument( 'command', choices=[ - 'list-trees', 'list-maintainers'], + 'list-trees', 'list-maintainers', 'set-pw-delegate'], help='Command to perform') parser.add_argument( 'id', type=int, help='patch/series id') args = parser.parse_args() + skip_delegated = args.skip_delegated command = args.command resource_type = args.type _id = args.id @@ -325,5 +358,22 @@ if __name__ == '__main__': if command == 'list-trees': print(tree.split('/')[-1]) - elif command == 'list-maintainers': - print(*maintainers.get_maintainers(tree), sep='\n') + if command in ['list-maintainers', 'set-pw-delegate']: + maintainer_list = maintainers.get_maintainers(tree) + if command == 'list-maintainers': + print(*maintainer_list, sep='\n') + elif command == 'set-pw-delegate': + if len(maintainer_list) > 0: + # Get the email of the first maintainer in the list. + try: + delegate = re.match( + r".*\<(?P.*)\>", + maintainer_list[0]).group('email') + except AttributeError: + print("Unexpected format: '{}'".format(maintainer_list[0])) + sys.exit(1) + _git_pw.set_delegate( + patch_list, delegate, + skip_delegated=skip_delegated) + else: + print('No maintainers found. Not setting a delegate.') -- 2.25.1