From 7d29984fb347c6786e629332e5552dfe91e32213 Mon Sep 17 00:00:00 2001 From: tushenmei Date: Sun, 26 Sep 2021 20:50:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96release=5Fd?= =?UTF-8?q?ate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/modifypart/modifyentrance.py | 46 +++++++++++++++++-- release-assistant/javcra/cli/base.py | 9 +++- release-assistant/javcra/cli/cmd.py | 15 ++++-- .../javcra/cli/commands/checkpart.py | 8 ++-- .../javcra/cli/commands/releasepart.py | 6 +-- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/release-assistant/javcra/application/modifypart/modifyentrance.py b/release-assistant/javcra/application/modifypart/modifyentrance.py index 2749ef2..179cb3f 100644 --- a/release-assistant/javcra/application/modifypart/modifyentrance.py +++ b/release-assistant/javcra/application/modifypart/modifyentrance.py @@ -611,6 +611,7 @@ class CveIssue(Operation): t_head = ["CVE", "仓库", "status", "score", "version", "abi是否变化"] block_name = "## 1、CVE" + logger.info("Start to obtain cve archive information, it may take a few minutes.") cve_list = [] if operate != "init" else self.get_cve_list(*args) cve_prefix = "修复CVE {}个".format(len(cve_list)) @@ -821,11 +822,46 @@ class IssueOperation(Operation): if re.compile("1、CVE.*?\\n\\n", re.S).search(issue_body): logger.error("Issue has CVE content, maybe you already have operated start update command.") return None + + if "代码冻结" not in issue_body: + logger.error("the code freeze time is not in release issue body.") + return None + if not issue_body.endswith("\n"): issue_body += "\n" return issue_body return None + def get_release_time(self): + """ + get the date for release + Returns: + release_date + """ + issue_body = self.get_issue_body(self.issue_num) + if not issue_body: + logger.error("no content of release issue body.") + return None + + date_info = re.compile("(?P代码冻结.*?\\n\\n)", re.S).search(issue_body) + if not date_info: + logger.error("the code freeze time is not in release issue body.") + return None + + split_date_info = re.split(r":|:", date_info["release_date"].strip()) + try: + release_date = split_date_info[1].strip() + # The length of the date including year, month, and day is 8 + if release_date.isdigit() and len(release_date) == 8: + return release_date + + logger.error("The format of the code freeze date: %s does not meet the requirements." % release_date) + return None + + except IndexError: + logger.error("error in getting code freeze date.") + return None + def get_repo(self, md_type=True): """ get repo according to branch 、date and epol @@ -834,11 +870,15 @@ class IssueOperation(Operation): if not branch: raise ValueError("can not get the branch, please check.") + release_date = self.get_release_time() + if not release_date: + raise ValueError("can not get the release time, please check.") + base_url = REPO_BASE_URL + branch repos = [] repo_dict = { "repo_type": "standard", - "url": base_url + "/update_" + self.date + "/" + "url": base_url + "/update_" + release_date + "/" } repos.append(repo_dict) @@ -848,9 +888,9 @@ class IssueOperation(Operation): repo_dict = dict() repo_dict["repo_type"] = "epol" if "sp2" in branch or "SP2" in branch: - repo_dict["url"] = base_url + "/EPOL/update_" + self.date + "/main/" + repo_dict["url"] = base_url + "/EPOL/update_" + release_date + "/main/" else: - repo_dict["url"] = base_url + "/EPOL/update_" + self.date + "/" + repo_dict["url"] = base_url + "/EPOL/update_" + release_date + "/" repos.append(repo_dict) if md_type: diff --git a/release-assistant/javcra/cli/base.py b/release-assistant/javcra/cli/base.py index c5b3510..85bc216 100644 --- a/release-assistant/javcra/cli/base.py +++ b/release-assistant/javcra/cli/base.py @@ -121,7 +121,7 @@ class BaseCommand(): print("[INFO] successfully create %s" % type_res) @staticmethod - def get_branch_pkgs(issue): + def get_release_info(issue): branch_name = issue.get_update_issue_branch() if not branch_name: raise ValueError("failed to get branch name.") @@ -129,7 +129,12 @@ class BaseCommand(): update_pkgs = issue.get_update_list() if not update_pkgs: raise ValueError("failed to get obs_pkgs.") - return branch_name, update_pkgs + + release_date = issue.get_release_time() + if not release_date: + raise ValueError("can not get the release time, please check.") + + return branch_name, update_pkgs, release_date @staticmethod def register_command(command): diff --git a/release-assistant/javcra/cli/cmd.py b/release-assistant/javcra/cli/cmd.py index 220e3e7..95136d1 100644 --- a/release-assistant/javcra/cli/cmd.py +++ b/release-assistant/javcra/cli/cmd.py @@ -14,14 +14,15 @@ Description: register method for all commands Class: JavcraCommand """ +import os +import sys + +ABSPATH = os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(os.path.dirname(__file__))))) +sys.path.insert(0, ABSPATH) from javcra.cli.base import BaseCommand from javcra.common.exc import Error -# 'import xxxxCommand' would be used in the args_parser() to register command -from javcra.cli.commands.startpart import StartCommand # pylint: disable=unused-import -from javcra.cli.commands.releasepart import ReleaseCommand # pylint: disable=unused-import -from javcra.cli.commands.modifypart import ModifyCommand # pylint: disable=unused-import -from javcra.cli.commands.checkpart import CheckCommand # pylint: disable=unused-import + def main(): """ @@ -38,3 +39,7 @@ def main(): BaseCommand().args_parser() except Error: print('Command execution error please try again') + + +if __name__ == '__main__': + main() diff --git a/release-assistant/javcra/cli/commands/checkpart.py b/release-assistant/javcra/cli/commands/checkpart.py index 79f182e..82f7677 100644 --- a/release-assistant/javcra/cli/commands/checkpart.py +++ b/release-assistant/javcra/cli/commands/checkpart.py @@ -197,7 +197,7 @@ class CheckCommand(BaseCommand): "ScanOSSResultRepo": constant.JENKINS_SERVER_REPO, "action": "create", "obs_project": obs_project, - "update_dir": "update_" + issue.date, + "update_dir": "update_" + release_date, "package_family": pkg_family, "pkgnamelist": ",".join(pkgs), } @@ -228,7 +228,7 @@ class CheckCommand(BaseCommand): "ScanOSSResultRepo": constant.JENKINS_SERVER_REPO, "ARCH": X86_FRAME, "EPOL": epol_flag, - "UPDATE_TIME": issue.date, + "UPDATE_TIME": release_date, "BRANCH": branch_name, "PKGLIST": ",".join(update_pkgs), } @@ -259,7 +259,7 @@ class CheckCommand(BaseCommand): issue = self.issue(params) check_issue = self.check_issue(params) - branch_name, update_pkgs = self.get_branch_pkgs(issue) + branch_name, update_pkgs, release_date = self.get_release_info(issue) standard_list, epol_list = issue.get_standard_epol_list(branch_name, update_pkgs) epol_flag = "True" if epol_list else "False" @@ -268,7 +268,7 @@ class CheckCommand(BaseCommand): paral_num = min(MAX_PARAL_NUM, len(update_pkgs)) # get jenkins_server and cloud server - jenkins_server = self.jenkins_server(params, paral_num, branch_name, issue.date) + jenkins_server = self.jenkins_server(params, paral_num, branch_name, release_date) cloud_server = ObsCloud( params.ak, params.sk, REALSE_TOOLS_SERVER, REALSE_TOOLS_BUCKET_NAME ) diff --git a/release-assistant/javcra/cli/commands/releasepart.py b/release-assistant/javcra/cli/commands/releasepart.py index cf5e317..58ad090 100644 --- a/release-assistant/javcra/cli/commands/releasepart.py +++ b/release-assistant/javcra/cli/commands/releasepart.py @@ -90,7 +90,7 @@ class ReleaseCommand(BaseCommand): "ScanOSSResultRepo": constant.JENKINS_SERVER_REPO, "action": "release", "obs_project": obs_project, - "update_dir": "update_" + issue.date, + "update_dir": "update_" + release_date, "package_family": pkg_family, } jenkins_obs_res = jenkins_server.get_specific_job_comment( @@ -99,7 +99,7 @@ class ReleaseCommand(BaseCommand): return jenkins_obs_res issue = IssueOperation(GITEE_REPO, params.token, params.releaseIssueID) - branch_name, update_pkgs = self.get_branch_pkgs(issue) + branch_name, update_pkgs, release_date = self.get_release_info(issue) # get parallel jenkins job num according to length of pkg_list and max parallel num paral_num = min(MAX_PARAL_NUM, len(update_pkgs)) @@ -111,7 +111,7 @@ class ReleaseCommand(BaseCommand): params.jenkinskey, paral_num, branch_name, - issue.date, + release_date, ) # publish pkg rpms -- Gitee