LicenceAndFormattingCheck: remove global variable, pass directly
Signed-off-by: Robert Schmidt <robert.schmidt@openairinterface.org>
This commit is contained in:
@@ -22,7 +22,7 @@ import constants as CONST
|
|||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER):
|
def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,CLUSTER):
|
||||||
|
|
||||||
force_local = False
|
force_local = False
|
||||||
date_fmt = None
|
date_fmt = None
|
||||||
@@ -53,7 +53,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER):
|
|||||||
RAN.ranRepository=matchReg.group(1)
|
RAN.ranRepository=matchReg.group(1)
|
||||||
HTML.ranRepository=matchReg.group(1)
|
HTML.ranRepository=matchReg.group(1)
|
||||||
CONTAINERS.ranRepository=matchReg.group(1)
|
CONTAINERS.ranRepository=matchReg.group(1)
|
||||||
SCA.ranRepository=matchReg.group(1)
|
|
||||||
CLUSTER.ranRepository=matchReg.group(1)
|
CLUSTER.ranRepository=matchReg.group(1)
|
||||||
elif re.match(r'^\-\-eNB_AllowMerge=(.+)$|^\-\-ranAllowMerge=(.+)$', myArgv, re.IGNORECASE):
|
elif re.match(r'^\-\-eNB_AllowMerge=(.+)$|^\-\-ranAllowMerge=(.+)$', myArgv, re.IGNORECASE):
|
||||||
if re.match(r'^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE):
|
if re.match(r'^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE):
|
||||||
@@ -66,7 +65,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER):
|
|||||||
RAN.ranAllowMerge=True
|
RAN.ranAllowMerge=True
|
||||||
HTML.ranAllowMerge=True
|
HTML.ranAllowMerge=True
|
||||||
CONTAINERS.ranAllowMerge=True
|
CONTAINERS.ranAllowMerge=True
|
||||||
SCA.ranAllowMerge=True
|
|
||||||
CLUSTER.ranAllowMerge=True
|
CLUSTER.ranAllowMerge=True
|
||||||
elif re.match(r'^\-\-eNBBranch=(.+)$|^\-\-ranBranch=(.+)$', myArgv, re.IGNORECASE):
|
elif re.match(r'^\-\-eNBBranch=(.+)$|^\-\-ranBranch=(.+)$', myArgv, re.IGNORECASE):
|
||||||
if re.match(r'^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE):
|
if re.match(r'^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE):
|
||||||
@@ -77,7 +75,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER):
|
|||||||
RAN.ranBranch=matchReg.group(1)
|
RAN.ranBranch=matchReg.group(1)
|
||||||
HTML.ranBranch=matchReg.group(1)
|
HTML.ranBranch=matchReg.group(1)
|
||||||
CONTAINERS.ranBranch=matchReg.group(1)
|
CONTAINERS.ranBranch=matchReg.group(1)
|
||||||
SCA.ranBranch=matchReg.group(1)
|
|
||||||
CLUSTER.ranBranch=matchReg.group(1)
|
CLUSTER.ranBranch=matchReg.group(1)
|
||||||
elif re.match(r'^\-\-eNBCommitID=(.*)$|^\-\-ranCommitID=(.*)$', myArgv, re.IGNORECASE):
|
elif re.match(r'^\-\-eNBCommitID=(.*)$|^\-\-ranCommitID=(.*)$', myArgv, re.IGNORECASE):
|
||||||
if re.match(r'^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE):
|
if re.match(r'^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE):
|
||||||
@@ -88,7 +85,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER):
|
|||||||
RAN.ranCommitID=matchReg.group(1)
|
RAN.ranCommitID=matchReg.group(1)
|
||||||
HTML.ranCommitID=matchReg.group(1)
|
HTML.ranCommitID=matchReg.group(1)
|
||||||
CONTAINERS.ranCommitID=matchReg.group(1)
|
CONTAINERS.ranCommitID=matchReg.group(1)
|
||||||
SCA.ranCommitID=matchReg.group(1)
|
|
||||||
CLUSTER.ranCommitID=matchReg.group(1)
|
CLUSTER.ranCommitID=matchReg.group(1)
|
||||||
elif re.match(r'^\-\-eNBTargetBranch=(.*)$|^\-\-ranTargetBranch=(.*)$', myArgv, re.IGNORECASE):
|
elif re.match(r'^\-\-eNBTargetBranch=(.*)$|^\-\-ranTargetBranch=(.*)$', myArgv, re.IGNORECASE):
|
||||||
if re.match(r'^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE):
|
if re.match(r'^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE):
|
||||||
@@ -99,7 +95,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER):
|
|||||||
RAN.ranTargetBranch=matchReg.group(1)
|
RAN.ranTargetBranch=matchReg.group(1)
|
||||||
HTML.ranTargetBranch=matchReg.group(1)
|
HTML.ranTargetBranch=matchReg.group(1)
|
||||||
CONTAINERS.ranTargetBranch=matchReg.group(1)
|
CONTAINERS.ranTargetBranch=matchReg.group(1)
|
||||||
SCA.ranTargetBranch=matchReg.group(1)
|
|
||||||
CLUSTER.ranTargetBranch=matchReg.group(1)
|
CLUSTER.ranTargetBranch=matchReg.group(1)
|
||||||
elif re.match(r'^\-\-eNBIPAddress=(.+)$|^\-\-eNB[1-2]IPAddress=(.+)$', myArgv, re.IGNORECASE):
|
elif re.match(r'^\-\-eNBIPAddress=(.+)$|^\-\-eNB[1-2]IPAddress=(.+)$', myArgv, re.IGNORECASE):
|
||||||
print("parameters --eNB*IPAddress ignored")
|
print("parameters --eNB*IPAddress ignored")
|
||||||
@@ -112,7 +107,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER):
|
|||||||
matchReg = re.match(r'^\-\-eNBSourceCodePath=(.+)$', myArgv, re.IGNORECASE)
|
matchReg = re.match(r'^\-\-eNBSourceCodePath=(.+)$', myArgv, re.IGNORECASE)
|
||||||
RAN.eNBSourceCodePath=matchReg.group(1)
|
RAN.eNBSourceCodePath=matchReg.group(1)
|
||||||
CONTAINERS.eNBSourceCodePath=matchReg.group(1)
|
CONTAINERS.eNBSourceCodePath=matchReg.group(1)
|
||||||
SCA.eNBSourceCodePath=matchReg.group(1)
|
|
||||||
CLUSTER.eNBSourceCodePath=matchReg.group(1)
|
CLUSTER.eNBSourceCodePath=matchReg.group(1)
|
||||||
elif re.match(r'^\-\-eNB1SourceCodePath=(.+)$', myArgv, re.IGNORECASE):
|
elif re.match(r'^\-\-eNB1SourceCodePath=(.+)$', myArgv, re.IGNORECASE):
|
||||||
print("parameter --eNB1SourceCodePath ignored")
|
print("parameter --eNB1SourceCodePath ignored")
|
||||||
|
|||||||
@@ -29,38 +29,28 @@ from cls_ci_helper import archiveArtifact
|
|||||||
|
|
||||||
class StaticCodeAnalysis():
|
class StaticCodeAnalysis():
|
||||||
|
|
||||||
def __init__(self):
|
def LicenceAndFormattingCheck(ctx, node, HTML, d, branch, allowMerge, targetBranch):
|
||||||
|
|
||||||
self.ranRepository = ''
|
|
||||||
self.ranBranch = ''
|
|
||||||
self.ranAllowMerge = False
|
|
||||||
self.ranCommitID = ''
|
|
||||||
self.ranTargetBranch = ''
|
|
||||||
self.eNBSourceCodePath = ''
|
|
||||||
|
|
||||||
def LicenceAndFormattingCheck(self, ctx, node, HTML):
|
|
||||||
# Workspace is no longer recreated from scratch.
|
# Workspace is no longer recreated from scratch.
|
||||||
# It implies that this method shall be called last within a build pipeline
|
# It implies that this method shall be called last within a build pipeline
|
||||||
# where workspace is already created
|
# where workspace is already created
|
||||||
lSourcePath = self.eNBSourceCodePath
|
|
||||||
|
|
||||||
if not node or not lSourcePath:
|
if not node or not d:
|
||||||
raise ValueError(f"{lSourcePath=} {node=}")
|
raise ValueError(f"{d=} {node=}")
|
||||||
logging.debug('Building on server: ' + node)
|
logging.debug('Building on server: ' + node)
|
||||||
cmd = cls_cmd.getConnection(node)
|
cmd = cls_cmd.getConnection(node)
|
||||||
check_options = ''
|
check_options = ''
|
||||||
if self.ranAllowMerge:
|
if allowMerge:
|
||||||
check_options = f'--build-arg MERGE_REQUEST=true --build-arg SRC_BRANCH={self.ranBranch}'
|
check_options = f'--build-arg MERGE_REQUEST=true --build-arg SRC_BRANCH={branch}'
|
||||||
if self.ranTargetBranch == '':
|
if targetBranch == '':
|
||||||
if self.ranBranch != 'develop' and self.ranBranch != 'origin/develop':
|
if branch != 'develop' and branch != 'origin/develop':
|
||||||
check_options += ' --build-arg TARGET_BRANCH=develop'
|
check_options += ' --build-arg TARGET_BRANCH=develop'
|
||||||
else:
|
else:
|
||||||
check_options += f' --build-arg TARGET_BRANCH={self.ranTargetBranch}'
|
check_options += f' --build-arg TARGET_BRANCH={targetBranch}'
|
||||||
|
|
||||||
logDir = f'{lSourcePath}/cmake_targets/log/'
|
logDir = f'{d}/cmake_targets/log/'
|
||||||
cmd.run(f'mkdir -p {logDir}')
|
cmd.run(f'mkdir -p {logDir}')
|
||||||
cmd.run('docker image rm oai-formatting-check:latest')
|
cmd.run('docker image rm oai-formatting-check:latest')
|
||||||
cmd.run(f'docker build --target oai-formatting-check --tag oai-formatting-check:latest {check_options} --file {lSourcePath}/ci-scripts/docker/Dockerfile.formatting.ubuntu {lSourcePath} > {logDir}/oai-formatting-check.txt 2>&1')
|
cmd.run(f'docker build --target oai-formatting-check --tag oai-formatting-check:latest {check_options} --file {d}/ci-scripts/docker/Dockerfile.formatting.ubuntu {d} > {logDir}/oai-formatting-check.txt 2>&1')
|
||||||
|
|
||||||
cmd.run('docker image rm oai-formatting-check:latest')
|
cmd.run('docker image rm oai-formatting-check:latest')
|
||||||
cmd.run('docker image prune --force')
|
cmd.run('docker image prune --force')
|
||||||
|
|||||||
+3
-5
@@ -22,7 +22,7 @@ import constants as CONST
|
|||||||
|
|
||||||
import cls_oaicitest #main class for OAI CI test framework
|
import cls_oaicitest #main class for OAI CI test framework
|
||||||
import cls_containerize #class Containerize for all container-based operations on RAN/UE objects
|
import cls_containerize #class Containerize for all container-based operations on RAN/UE objects
|
||||||
import cls_static_code_analysis #class for static code analysis
|
import cls_static_code_analysis as SCA
|
||||||
import cls_cluster # class for building/deploying on cluster
|
import cls_cluster # class for building/deploying on cluster
|
||||||
import cls_native # class for all native/source-based operations
|
import cls_native # class for all native/source-based operations
|
||||||
from cls_ci_helper import TestCaseCtx
|
from cls_ci_helper import TestCaseCtx
|
||||||
@@ -64,7 +64,6 @@ def ExecuteActionWithParam(action, ctx, node):
|
|||||||
global RAN
|
global RAN
|
||||||
global HTML
|
global HTML
|
||||||
global CONTAINERS
|
global CONTAINERS
|
||||||
global SCA
|
|
||||||
global CLUSTER
|
global CLUSTER
|
||||||
if action == 'Build_eNB' or action == 'Build_Image' or action == 'Build_Proxy' or action == "Build_Cluster_Image" or action == "Build_Run_Tests":
|
if action == 'Build_eNB' or action == 'Build_Image' or action == 'Build_Proxy' or action == "Build_Cluster_Image" or action == "Build_Run_Tests":
|
||||||
RAN.Build_eNB_args=test.findtext('Build_eNB_args')
|
RAN.Build_eNB_args=test.findtext('Build_eNB_args')
|
||||||
@@ -196,7 +195,7 @@ def ExecuteActionWithParam(action, ctx, node):
|
|||||||
success = CONTAINERS.Create_Workspace(node, HTML)
|
success = CONTAINERS.Create_Workspace(node, HTML)
|
||||||
|
|
||||||
elif action == 'LicenceAndFormattingCheck':
|
elif action == 'LicenceAndFormattingCheck':
|
||||||
success = SCA.LicenceAndFormattingCheck(ctx, node, HTML)
|
success = SCA.StaticCodeAnalysis.LicenceAndFormattingCheck(ctx, node, HTML, RAN.eNBSourceCodePath, RAN.ranBranch, RAN.ranAllowMerge, RAN.ranTargetBranch)
|
||||||
|
|
||||||
elif action == 'Push_Local_Registry':
|
elif action == 'Push_Local_Registry':
|
||||||
tag_prefix = test.findtext('tag_prefix') or ""
|
tag_prefix = test.findtext('tag_prefix') or ""
|
||||||
@@ -294,7 +293,6 @@ CiTestObj = cls_oaicitest.OaiCiTest()
|
|||||||
RAN = ran.RANManagement()
|
RAN = ran.RANManagement()
|
||||||
HTML = cls_oai_html.HTMLManagement()
|
HTML = cls_oai_html.HTMLManagement()
|
||||||
CONTAINERS = cls_containerize.Containerize()
|
CONTAINERS = cls_containerize.Containerize()
|
||||||
SCA = cls_static_code_analysis.StaticCodeAnalysis()
|
|
||||||
CLUSTER = cls_cluster.Cluster()
|
CLUSTER = cls_cluster.Cluster()
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
@@ -304,7 +302,7 @@ CLUSTER = cls_cluster.Cluster()
|
|||||||
import args_parse
|
import args_parse
|
||||||
# Force local execution, move all execution targets to localhost
|
# Force local execution, move all execution targets to localhost
|
||||||
force_local = False
|
force_local = False
|
||||||
mode, force_local, date_fmt = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER)
|
mode, force_local, date_fmt = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,CONTAINERS,HELP,CLUSTER)
|
||||||
fmt = "%(levelname)8s: %(message)s"
|
fmt = "%(levelname)8s: %(message)s"
|
||||||
if date_fmt:
|
if date_fmt:
|
||||||
fmt = "[%(asctime)s] %(levelname)s %(message)s"
|
fmt = "[%(asctime)s] %(levelname)s %(message)s"
|
||||||
|
|||||||
Reference in New Issue
Block a user