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 04B2C45638; Wed, 17 Jul 2024 20:05:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F09B3402F2; Wed, 17 Jul 2024 20:05:49 +0200 (CEST) Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by mails.dpdk.org (Postfix) with ESMTP id 89455402A2 for ; Wed, 17 Jul 2024 20:05:49 +0200 (CEST) Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-e05eccfcdb3so71173276.1 for ; Wed, 17 Jul 2024 11:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721239549; x=1721844349; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Vj5GG+HUCb3X8WCQBwAjoO7NshrVA2i2hSXXKoOdBic=; b=HsX5TOM6tW1IGwhi5oMG+jN/QJ8XTXfIJ/QhcbzK1cllLGsLS9Mf70lRaEDn39+5IS XCcOq86OmpQkzs1/Wkz/QS5nA3mb24eD2iDwaYJMEZFpQxp1JdasZOqlhJEGba/iMI0x TBSFuq+vHQxz5n/DfTJAKXVJBkS3hVAkZuetY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721239549; x=1721844349; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Vj5GG+HUCb3X8WCQBwAjoO7NshrVA2i2hSXXKoOdBic=; b=V+0mv6AqPaE2oW8A1FOxSSnbIocHHD405eSUaCuOVO4AILn0q1FxNGV2AxITIID7n2 csLyVq6bHndt/DTloLq08sC56vg2VS+d+cToiG6LNEzcXoPxbZO+i6WuYXfrvs9ZTwoo /Jq16LUZdOWRIDePH3rm+wu7iTokhu2MtVsXlSuzVrYvd1CoG5ceARPUG6uoHc/iS3dA 1QKnbHyoK8HRrX2ysUwlmR0V6NKs77MFg6aOg244KzmGmKF6qNrflSnh+DegkzD+pLja ci1JBPo9JsYn9VwbmDw8IT7toPkfkoxOhUaMipqpUp+M0WruSAWEmxPWGCBlsuaMcmeL AMjQ== X-Gm-Message-State: AOJu0YxtUtlb16NoUsNixhN1bLQK38qoDfpYV0GdlQ7GTFKEjh7PQlNV HZkVtYi7mTvORmTYL02dopSXqvG2NRNXBCHLwF18u+ubTwyh1YdinJiJeLjnT1Losl8OhGmLvpp 9H3wwBgvPcQ8w2JjW4KqXRIgtDPDSYCbW1kQRzsTTxyFMws19t2HEXXwYhX4kXooFm4orZ1XYTa Ula1cGGvaNuiZxPoxR3BlYWQk= X-Google-Smtp-Source: AGHT+IEWI94CKUfuI88ycxdK/Sv29d3Yd6xEK+qUg5++hYIkxE3SP2ywe7dOqCcXfYBtWUbPVzDP+w== X-Received: by 2002:a05:6902:2e0f:b0:e03:5298:77b4 with SMTP id 3f1490d57ef6-e05ed789803mr2836571276.35.1721239548669; Wed, 17 Jul 2024 11:05:48 -0700 (PDT) Received: from bubs.iol.unh.edu ([2606:4100:3880:1271:27d2:9af4:4b7f:fdb5]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44f5b7fb4f7sm50727661cf.53.2024.07.17.11.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jul 2024 11:05:48 -0700 (PDT) From: Adam Hassick To: ci@dpdk.org Cc: aconole@redhat.com, alialnu@nvidia.com, Adam Hassick Subject: [PATCH v1] tools: Update create_series_artifact script Date: Wed, 17 Jul 2024 14:06:42 -0400 Message-ID: <20240717180642.24550-1-ahassick@iol.unh.edu> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 This is a collection of small changes to the create_artifact_script that the community lab has made over the past several months. The most notable change is the addition of the "branch" argument, which allows the caller to specify a branch to apply on. * Add branch override argument. * Default to main branch if guess_git_tree fails. * Return list of default patch tags if patch_parser fails. * Use patch name instead of database ID for the patch file name. Signed-off-by: Adam Hassick --- tools/create_series_artifact.py | 51 +++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/tools/create_series_artifact.py b/tools/create_series_artifact.py index 235896c..550ea82 100755 --- a/tools/create_series_artifact.py +++ b/tools/create_series_artifact.py @@ -47,6 +47,7 @@ BRANCH_NAME_MAP = { @dataclass class CreateSeriesParameters(object): + branch_override: Optional[str] pw_server: str pw_project: str pw_token: str @@ -95,7 +96,8 @@ class ProjectTree(object): def move_logs(self): shutil.move(self.log_file_path, pathlib.Path(os.getcwd(), "log.txt")) shutil.move( - self.props_file_path, pathlib.Path(os.getcwd(), self.data.output_properties) + self.props_file_path, + pathlib.Path(os.getcwd(), self.data.output_properties), ) def __init__(self, data: CreateSeriesParameters): @@ -302,12 +304,23 @@ class ProjectTree(object): return True +def get_patch_filename(patch_name: str) -> str: + filename: str = "".join( + [ + "-" if char.isspace() else char.lower() + for char in patch_name + if char.isalnum() or char.isspace() + ] + ) + return f"{filename}.patch" + + def get_tags( patch_parser_script: pathlib.Path, patch_parser_cfg: pathlib.Path, series: Dict, ) -> List[str]: - series_filename = f"{series['id']}.patch" + series_filename = get_patch_filename(series.get("name", "unnamed")) # Pull down the patch series as a single file. pw_api.download(series["mbox"], None, series_filename) @@ -320,7 +333,13 @@ def get_tags( ) # Assert that patch parser succeeded. - parse_result.check_returncode() + if parse_result.returncode != 0: + print( + "WARNING: Patch parsing for tags failed:", + parse_result.stderr.decode(), + ) + # Return some default tags. + return ["core", "driver", "application"] # Return the output return parse_result.stdout.decode().splitlines() @@ -360,6 +379,9 @@ def parse_args() -> argparse.Namespace: action="store_true", help="When set, does not acknowledge the Depends-on label.", ) + parser.add_argument( + "-b", "--branch", type=str, help="When present, apply on this branch." + ) return parser.parse_args() @@ -409,6 +431,7 @@ def collect_series_info(args: argparse.Namespace) -> CreateSeriesParameters: patch_ids.sort() return CreateSeriesParameters( + branch_override=args.branch, pw_server=pw_server, pw_project=pw_project, pw_token=pw_token, @@ -440,17 +463,29 @@ def main() -> int: # Pull down the DPDK mirror. tree = ProjectTree(data) - # Try to guess the Git tree for this patchset. - guessed_tree = tree.guess_git_tree() + if data.branch_override: + guessed_tree: str = ( + BRANCH_NAME_MAP.get(data.branch_override) or data.branch_override + ) + + # Try to check out to the tree. + if not tree.checkout(guessed_tree): + print( + f'Could not checkout to specified branch "{data.branch_override}" because it did not exist.' + ) + return 1 + else: + guessed_tree = tree.guess_git_tree() if not guessed_tree: - print("Failed to guess git tree.") - return 1 + print("Failed to guess git tree. Trying main instead...") + guessed_tree = "main" # Try to apply this patch. if not ( try_to_apply(tree) # First, try to apply on the guessed tree. - or guessed_tree != "main" # If that fails, and the guessed tree was not main + or not data.branch_override # Skip when branch is given + and guessed_tree != "main" # 2nd attempt on main if guess not main and tree.checkout("main") # Checkout to main, then and try_to_apply(tree) # Try to apply on main ): -- 2.45.2