ScriptCollection 3.5.16__py3-none-any.whl → 4.0.78__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ScriptCollection/AnionBuildPlatform.py +206 -0
- ScriptCollection/{UpdateCertificates.py → CertificateUpdater.py} +69 -46
- ScriptCollection/Executables.py +515 -18
- ScriptCollection/GeneralUtilities.py +1272 -873
- ScriptCollection/ImageUpdater.py +648 -0
- ScriptCollection/ProgramRunnerBase.py +10 -10
- ScriptCollection/ProgramRunnerMock.py +2 -0
- ScriptCollection/ProgramRunnerPopen.py +7 -1
- ScriptCollection/ProgramRunnerSudo.py +108 -0
- ScriptCollection/SCLog.py +115 -0
- ScriptCollection/ScriptCollectionCore.py +942 -266
- ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py +95 -0
- ScriptCollection/TFCPS/Docker/__init__.py +0 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py +8 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py +6 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py +7 -0
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +485 -0
- ScriptCollection/TFCPS/DotNet/__init__.py +0 -0
- ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py +130 -0
- ScriptCollection/TFCPS/Flutter/__init__.py +0 -0
- ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py +74 -0
- ScriptCollection/TFCPS/Go/__init__.py +0 -0
- ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py +131 -0
- ScriptCollection/TFCPS/NodeJS/__init__.py +0 -0
- ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py +227 -0
- ScriptCollection/TFCPS/Python/__init__.py +0 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py +418 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py +128 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py +136 -0
- ScriptCollection/TFCPS/TFCPS_CreateRelease.py +95 -0
- ScriptCollection/TFCPS/TFCPS_Generic.py +43 -0
- ScriptCollection/TFCPS/TFCPS_MergeToMain.py +122 -0
- ScriptCollection/TFCPS/TFCPS_MergeToStable.py +350 -0
- ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py +47 -0
- ScriptCollection/TFCPS/TFCPS_Tools_General.py +1356 -0
- ScriptCollection/TFCPS/__init__.py +0 -0
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/METADATA +23 -22
- scriptcollection-4.0.78.dist-info/RECORD +43 -0
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/WHEEL +1 -1
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/entry_points.txt +32 -0
- ScriptCollection/ProgramRunnerEpew.py +0 -122
- ScriptCollection/RPStream.py +0 -42
- ScriptCollection/TasksForCommonProjectStructure.py +0 -2625
- ScriptCollection-3.5.16.dist-info/RECORD +0 -16
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from datetime import datetime, timedelta
|
|
3
|
+
from ..GeneralUtilities import GeneralUtilities
|
|
4
|
+
from ..ScriptCollectionCore import ScriptCollectionCore
|
|
5
|
+
from ..SCLog import LogLevel
|
|
6
|
+
from .TFCPS_CodeUnit_BuildCodeUnit import TFCPS_CodeUnit_BuildCodeUnit
|
|
7
|
+
from .TFCPS_Tools_General import TFCPS_Tools_General
|
|
8
|
+
|
|
9
|
+
class TFCPS_CodeUnit_BuildCodeUnits:
|
|
10
|
+
repository:str=None
|
|
11
|
+
tFCPS_Other:TFCPS_Tools_General=None
|
|
12
|
+
sc:ScriptCollectionCore=None
|
|
13
|
+
target_environment_type:str=None
|
|
14
|
+
additionalargumentsfile:str=None
|
|
15
|
+
__use_cache:bool
|
|
16
|
+
__is_pre_merge:bool
|
|
17
|
+
|
|
18
|
+
def __init__(self,repository:str,loglevel:LogLevel,target_environment_type:str,additionalargumentsfile:str,use_cache:bool,is_pre_merge:bool):
|
|
19
|
+
self.sc=ScriptCollectionCore()
|
|
20
|
+
self.sc.log.loglevel=loglevel
|
|
21
|
+
self.__use_cache=use_cache
|
|
22
|
+
self.sc.assert_is_git_repository(repository)
|
|
23
|
+
self.repository=repository
|
|
24
|
+
self.tFCPS_Other:TFCPS_Tools_General=TFCPS_Tools_General(self.sc)
|
|
25
|
+
allowed_target_environment_types=["Development","QualityCheck","Productive"]
|
|
26
|
+
GeneralUtilities.assert_condition(target_environment_type in allowed_target_environment_types,"Unknown target-environment-type. Allowed values are: "+", ".join(allowed_target_environment_types))
|
|
27
|
+
self.target_environment_type=target_environment_type
|
|
28
|
+
self.additionalargumentsfile=additionalargumentsfile
|
|
29
|
+
self.__is_pre_merge=is_pre_merge
|
|
30
|
+
|
|
31
|
+
@GeneralUtilities.check_arguments
|
|
32
|
+
def __save_lines_of_code(self, repository_folder: str, project_version: str) -> None:
|
|
33
|
+
loc = self.sc.get_lines_of_code_with_default_excluded_patterns(repository_folder)
|
|
34
|
+
loc_metric_folder = os.path.join(repository_folder, "Other", "Metrics")
|
|
35
|
+
GeneralUtilities.ensure_directory_exists(loc_metric_folder)
|
|
36
|
+
loc_metric_file = os.path.join(loc_metric_folder, "LinesOfCode.csv")
|
|
37
|
+
GeneralUtilities.ensure_file_exists(loc_metric_file)
|
|
38
|
+
old_lines = GeneralUtilities.read_lines_from_file(loc_metric_file)
|
|
39
|
+
new_lines = []
|
|
40
|
+
for line in old_lines:
|
|
41
|
+
if not line.startswith(f"v{project_version};"):
|
|
42
|
+
new_lines.append(line)
|
|
43
|
+
new_lines.append(f"v{project_version};{loc}")
|
|
44
|
+
GeneralUtilities.write_lines_to_file(loc_metric_file, new_lines)
|
|
45
|
+
|
|
46
|
+
@GeneralUtilities.check_arguments
|
|
47
|
+
def build_codeunits(self) -> None:
|
|
48
|
+
self.sc.log.log(GeneralUtilities.get_line())
|
|
49
|
+
self.sc.log.log(f"Start building codeunits. (Target environment-type: {self.target_environment_type})")
|
|
50
|
+
|
|
51
|
+
#check if changelog exists
|
|
52
|
+
changelog_file=os.path.join(self.repository,"Other","Resources","Changelog",f"v{self.tFCPS_Other.get_version_of_project(self.repository)}.md")
|
|
53
|
+
GeneralUtilities.assert_file_exists(changelog_file,f"Changelogfile \"{changelog_file}\" does not exist. Try to create it for example using \"sccreatechangelogentry -m ...\".")
|
|
54
|
+
|
|
55
|
+
#run prepare-script
|
|
56
|
+
if os.path.isfile( os.path.join(self.repository,"Other","Scripts","PrepareBuildCodeunits.py")):
|
|
57
|
+
arguments:str=f"--targetenvironmenttype {self.target_environment_type} --additionalargumentsfile {self.additionalargumentsfile} --verbosity {int(self.sc.log.loglevel)}"
|
|
58
|
+
if not self.__use_cache:
|
|
59
|
+
arguments=f"{arguments} --nocache"
|
|
60
|
+
if self.sc.git_repository_has_uncommitted_changes(self.repository):
|
|
61
|
+
self.sc.log.log("No-cache-option can not be applied because there are uncommited changes in the repository.",LogLevel.Warning)
|
|
62
|
+
else:
|
|
63
|
+
self.sc.run_program("git","clean -dfx",self.repository)
|
|
64
|
+
|
|
65
|
+
self.sc.log.log("Prepare build codeunits...")
|
|
66
|
+
self.sc.run_program("python", f"PrepareBuildCodeunits.py {arguments}", os.path.join(self.repository,"Other","Scripts"),print_live_output=True)
|
|
67
|
+
|
|
68
|
+
#mark current version as supported
|
|
69
|
+
now = GeneralUtilities.get_now()
|
|
70
|
+
project_version:str=self.tFCPS_Other.get_version_of_project(self.repository)
|
|
71
|
+
if not self.tFCPS_Other.suport_information_exists(self.repository, project_version):
|
|
72
|
+
amount_of_years_for_support:int=1
|
|
73
|
+
support_time = timedelta(days=365*amount_of_years_for_support+30*3+1)
|
|
74
|
+
until = now + support_time
|
|
75
|
+
until_day = datetime(until.year, until.month, until.day, 0, 0, 0)
|
|
76
|
+
from_day = datetime(now.year, now.month, now.day, 0, 0, 0)
|
|
77
|
+
self.tFCPS_Other.mark_current_version_as_supported(self.repository,project_version,from_day,until_day)
|
|
78
|
+
|
|
79
|
+
codeunits:list[str]=self.tFCPS_Other.get_codeunits(self.repository)
|
|
80
|
+
self.sc.log.log("Codeunits will be built in the following order:")
|
|
81
|
+
for codeunit_name in codeunits:
|
|
82
|
+
self.sc.log.log(" - "+codeunit_name)
|
|
83
|
+
for codeunit_name in codeunits:
|
|
84
|
+
tFCPS_CodeUnit_BuildCodeUnit:TFCPS_CodeUnit_BuildCodeUnit = TFCPS_CodeUnit_BuildCodeUnit(os.path.join(self.repository,codeunit_name),self.sc.log.loglevel,self.target_environment_type,self.additionalargumentsfile,self.use_cache(),self.is_pre_merge())
|
|
85
|
+
self.sc.log.log(GeneralUtilities.get_line())
|
|
86
|
+
tFCPS_CodeUnit_BuildCodeUnit.build_codeunit()
|
|
87
|
+
|
|
88
|
+
#TODO run static code analysis tool to search for vulnerabilities
|
|
89
|
+
#TODO self.__search_for_secrets()
|
|
90
|
+
self.__save_lines_of_code(self.repository,self.tFCPS_Other.get_version_of_project(self.repository))
|
|
91
|
+
|
|
92
|
+
self.sc.log.log(GeneralUtilities.get_line())
|
|
93
|
+
self.sc.log.log("Finished building codeunits.")
|
|
94
|
+
self.sc.log.log(GeneralUtilities.get_line())
|
|
95
|
+
|
|
96
|
+
def __search_for_secrets(self):#pylint:disable=unused-private-member
|
|
97
|
+
exe_paths=self.tFCPS_Other.ensure_trufflehog_is_available()
|
|
98
|
+
exe_path:str=None
|
|
99
|
+
if GeneralUtilities.current_system_is_windows():
|
|
100
|
+
exe_path=exe_paths["Windows"]
|
|
101
|
+
elif GeneralUtilities.current_system_is_linux():
|
|
102
|
+
exe_path=exe_paths["Linux"]
|
|
103
|
+
else:
|
|
104
|
+
raise ValueError("unsupported")#TODO check for macos
|
|
105
|
+
result=self.sc.run_program(exe_path,"filesystem . --json",self.repository)
|
|
106
|
+
|
|
107
|
+
enabled:bool=False
|
|
108
|
+
if enabled:
|
|
109
|
+
self.sc.log.log("Secret-scan-result:")#TODO replace this by real analysis
|
|
110
|
+
for line in GeneralUtilities.string_to_lines(result[1]):
|
|
111
|
+
self.sc.log.log(line)
|
|
112
|
+
for line in GeneralUtilities.string_to_lines(result[2]):
|
|
113
|
+
self.sc.log.log(line,LogLevel.Error)
|
|
114
|
+
|
|
115
|
+
@GeneralUtilities.check_arguments
|
|
116
|
+
def use_cache(self) -> bool:
|
|
117
|
+
return self.__use_cache
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@GeneralUtilities.check_arguments
|
|
121
|
+
def is_pre_merge(self) -> bool:
|
|
122
|
+
return self.__is_pre_merge
|
|
123
|
+
|
|
124
|
+
@GeneralUtilities.check_arguments
|
|
125
|
+
def update_dependencies(self) -> None:
|
|
126
|
+
self.update_year_in_license_file()
|
|
127
|
+
|
|
128
|
+
#TODO update project-wide-dependencies here
|
|
129
|
+
codeunits:list[str]=self.tFCPS_Other.get_codeunits(self.repository)
|
|
130
|
+
for codeunit_name in codeunits:
|
|
131
|
+
tFCPS_CodeUnit_BuildCodeUnit:TFCPS_CodeUnit_BuildCodeUnit = TFCPS_CodeUnit_BuildCodeUnit(os.path.join(self.repository,codeunit_name),self.sc.log.loglevel,self.target_environment_type,self.additionalargumentsfile,self.use_cache(),self.is_pre_merge())
|
|
132
|
+
tFCPS_CodeUnit_BuildCodeUnit.update_dependencies()
|
|
133
|
+
|
|
134
|
+
@GeneralUtilities.check_arguments
|
|
135
|
+
def update_year_in_license_file(self) -> None:
|
|
136
|
+
self.sc.update_year_in_first_line_of_file(os.path.join(self.repository, "License.txt"))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from ..ScriptCollectionCore import ScriptCollectionCore
|
|
3
|
+
from ..SCLog import LogLevel
|
|
4
|
+
from .TFCPS_Tools_General import TFCPS_Tools_General
|
|
5
|
+
from .TFCPS_MergeToMain import TFCPS_MergeToMain,MergeToMainConfiguration
|
|
6
|
+
from .TFCPS_MergeToStable import TFCPS_MergeToStable,MergeToStableConfiguration
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TFCPS_CreateReleaseConfiguration:
|
|
10
|
+
|
|
11
|
+
product_name: str
|
|
12
|
+
branch_to_be_released:str
|
|
13
|
+
additional_arguments_file:str
|
|
14
|
+
log_level:LogLevel
|
|
15
|
+
main_branch:str
|
|
16
|
+
stable_branch:str
|
|
17
|
+
build_repository:str
|
|
18
|
+
repository:str
|
|
19
|
+
reference_repository:str
|
|
20
|
+
common_remote_name:str
|
|
21
|
+
build_repo_main_branch_name:str
|
|
22
|
+
reference_repo_main_branch_name:str
|
|
23
|
+
reference_remote_name:str
|
|
24
|
+
build_repo_remote_name:str
|
|
25
|
+
artifacts_target_folder:str
|
|
26
|
+
common_remote_url:str
|
|
27
|
+
|
|
28
|
+
def __init__(self, current_file: str, product_name: str,branch_to_be_released:str,log_level:LogLevel,additional_arguments_file:str,main_branch:str,stable_branch:str,common_remote_name:str,build_repo_main_branch_name:str,reference_repo_main_branch_name:str,reference_remote_name:str,build_repo_remote_name:str,artifacts_target_folder:str,common_remote_url:str):
|
|
29
|
+
self.product_name = product_name
|
|
30
|
+
self.branch_to_be_released=branch_to_be_released
|
|
31
|
+
self.additional_arguments_file=additional_arguments_file
|
|
32
|
+
self.log_level=log_level
|
|
33
|
+
self.main_branch=main_branch
|
|
34
|
+
self.stable_branch=stable_branch
|
|
35
|
+
self.build_repository=ScriptCollectionCore().search_repository_folder(current_file)
|
|
36
|
+
self.repository=os.path.join(self.build_repository,"Submodules",product_name)
|
|
37
|
+
self.reference_repository=os.path.join(self.build_repository,"Submodules",product_name+"Reference")
|
|
38
|
+
self.common_remote_name=common_remote_name
|
|
39
|
+
self.build_repo_main_branch_name=build_repo_main_branch_name
|
|
40
|
+
self.reference_repo_main_branch_name=reference_repo_main_branch_name
|
|
41
|
+
self.reference_remote_name=reference_remote_name
|
|
42
|
+
self.build_repo_remote_name=build_repo_remote_name
|
|
43
|
+
self.artifacts_target_folder=artifacts_target_folder
|
|
44
|
+
self.common_remote_url=common_remote_url
|
|
45
|
+
|
|
46
|
+
class TFCPS_CreateRelease:
|
|
47
|
+
|
|
48
|
+
sc:ScriptCollectionCore
|
|
49
|
+
tFCPS_Tools_General:TFCPS_Tools_General
|
|
50
|
+
|
|
51
|
+
def __init__(self):
|
|
52
|
+
self.sc=ScriptCollectionCore()
|
|
53
|
+
self.tFCPS_Tools_General=TFCPS_Tools_General(self.sc)
|
|
54
|
+
|
|
55
|
+
def do_release(self,tfcps_CreateReleaseConfiguration:TFCPS_CreateReleaseConfiguration)->bool:
|
|
56
|
+
self.sc.log.loglevel=tfcps_CreateReleaseConfiguration.log_level
|
|
57
|
+
return self.sc.do_and_log_task(f"Release {tfcps_CreateReleaseConfiguration.product_name}",lambda : self.__do(tfcps_CreateReleaseConfiguration))
|
|
58
|
+
|
|
59
|
+
def __do(self,tfcps_CreateReleaseConfiguration:TFCPS_CreateReleaseConfiguration)->bool:
|
|
60
|
+
self.sc.log.log("Do checks...",LogLevel.Information)
|
|
61
|
+
|
|
62
|
+
self.sc.assert_is_git_repository(tfcps_CreateReleaseConfiguration.build_repository)
|
|
63
|
+
self.sc.assert_no_uncommitted_changes(tfcps_CreateReleaseConfiguration.build_repository)
|
|
64
|
+
|
|
65
|
+
self.sc.assert_is_git_repository(tfcps_CreateReleaseConfiguration.repository)
|
|
66
|
+
self.sc.assert_no_uncommitted_changes(tfcps_CreateReleaseConfiguration.repository)
|
|
67
|
+
|
|
68
|
+
self.sc.assert_is_git_repository(tfcps_CreateReleaseConfiguration.reference_repository)
|
|
69
|
+
self.sc.assert_no_uncommitted_changes(tfcps_CreateReleaseConfiguration.reference_repository)
|
|
70
|
+
|
|
71
|
+
release_was_done:bool=False
|
|
72
|
+
|
|
73
|
+
branch_to_be_released_commit_id = self.sc.git_get_commit_id(tfcps_CreateReleaseConfiguration.repository, tfcps_CreateReleaseConfiguration.branch_to_be_released)
|
|
74
|
+
main_branch_commit_id = self.sc.git_get_commit_id(tfcps_CreateReleaseConfiguration.repository, tfcps_CreateReleaseConfiguration.main_branch)
|
|
75
|
+
if branch_to_be_released_commit_id == main_branch_commit_id:
|
|
76
|
+
self.sc.log.log("Merge to main-branch will not be done because there are no changed which can be merged.")
|
|
77
|
+
else:
|
|
78
|
+
self.sc.log.log("Merge to main-branch...",LogLevel.Information)
|
|
79
|
+
mergeToMainConfiguration:MergeToMainConfiguration=MergeToMainConfiguration(tfcps_CreateReleaseConfiguration.current_file,tfcps_CreateReleaseConfiguration.product_name,tfcps_CreateReleaseConfiguration.product_name,tfcps_CreateReleaseConfiguration.branch_to_be_released,tfcps_CreateReleaseConfiguration.log_level,tfcps_CreateReleaseConfiguration.additional_arguments_file,tfcps_CreateReleaseConfiguration.main_branch,tfcps_CreateReleaseConfiguration.common_remote_name,tfcps_CreateReleaseConfiguration.build_repository)
|
|
80
|
+
tFCPS_MergeToMain:TFCPS_MergeToMain=TFCPS_MergeToMain(mergeToMainConfiguration)
|
|
81
|
+
tFCPS_MergeToMain.merge_to_main_branch()
|
|
82
|
+
|
|
83
|
+
main_branch_commit_id = self.sc.git_get_commit_id(tfcps_CreateReleaseConfiguration.repository, tfcps_CreateReleaseConfiguration.main_branch)
|
|
84
|
+
stable_branch_commit_id = self.sc.git_get_commit_id(tfcps_CreateReleaseConfiguration.repository, tfcps_CreateReleaseConfiguration.stable_branch)
|
|
85
|
+
if main_branch_commit_id == stable_branch_commit_id:
|
|
86
|
+
self.sc.log.log("Merge to stable-branch will not be done because there are no changed which can be released.")
|
|
87
|
+
else:
|
|
88
|
+
self.sc.log.log("Merge to stable-branch...",LogLevel.Information)
|
|
89
|
+
mergeToStableConfiguration:MergeToStableConfiguration=MergeToStableConfiguration(tfcps_CreateReleaseConfiguration.log_level,tfcps_CreateReleaseConfiguration.main_branch,tfcps_CreateReleaseConfiguration.stable_branch,tfcps_CreateReleaseConfiguration.repository,tfcps_CreateReleaseConfiguration.build_repository,tfcps_CreateReleaseConfiguration.common_remote_name,tfcps_CreateReleaseConfiguration.build_repo_main_branch_name,tfcps_CreateReleaseConfiguration.reference_repo_main_branch_name,tfcps_CreateReleaseConfiguration.reference_remote_name,tfcps_CreateReleaseConfiguration.build_repo_remote_name,tfcps_CreateReleaseConfiguration.artifacts_target_folder,tfcps_CreateReleaseConfiguration.common_remote_url,tfcps_CreateReleaseConfiguration.additional_arguments_file)
|
|
90
|
+
tFCPS_MergeToStable:TFCPS_MergeToStable=TFCPS_MergeToStable(mergeToStableConfiguration)
|
|
91
|
+
tFCPS_MergeToStable.merge_to_stable_branch()
|
|
92
|
+
|
|
93
|
+
release_was_done=True
|
|
94
|
+
|
|
95
|
+
return release_was_done
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from ..ScriptCollectionCore import ScriptCollectionCore
|
|
3
|
+
from ..SCLog import LogLevel
|
|
4
|
+
from .TFCPS_Tools_General import TFCPS_Tools_General
|
|
5
|
+
|
|
6
|
+
class TFCPS_Generic_Functions:
|
|
7
|
+
script_file:str
|
|
8
|
+
repository_folder:str=None
|
|
9
|
+
targetenvironmenttype:str
|
|
10
|
+
additionalargumentsfile:str
|
|
11
|
+
verbosity:LogLevel
|
|
12
|
+
sc:ScriptCollectionCore
|
|
13
|
+
tfcps_Tools_General:TFCPS_Tools_General
|
|
14
|
+
__use_cache:bool
|
|
15
|
+
|
|
16
|
+
def __init__(self,script_file:str,targetenvironmenttype:str,additionalargumentsfile:str,verbosity:LogLevel,use_cache:bool):
|
|
17
|
+
self.verbosity=verbosity
|
|
18
|
+
self.script_file=script_file
|
|
19
|
+
self.sc=ScriptCollectionCore()
|
|
20
|
+
self.sc.log.loglevel=self.verbosity
|
|
21
|
+
self.tfcps_Tools_General=TFCPS_Tools_General(self.sc)
|
|
22
|
+
self.repository_folder=self.sc.search_repository_folder(script_file)
|
|
23
|
+
self.targetenvironmenttype=targetenvironmenttype
|
|
24
|
+
self.__use_cache=use_cache
|
|
25
|
+
self.additionalargumentsfile=additionalargumentsfile
|
|
26
|
+
|
|
27
|
+
def use_cache(self)->bool:
|
|
28
|
+
return self.__use_cache
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class TFCPS_Generic_CLI:
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def parse(file:str)->TFCPS_Generic_Functions:
|
|
35
|
+
parser = argparse.ArgumentParser()
|
|
36
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
|
37
|
+
parser.add_argument('-e', '--targetenvironmenttype', required=False, default="QualityCheck")
|
|
38
|
+
parser.add_argument('-a', '--additionalargumentsfile', required=False, default=None)
|
|
39
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
|
40
|
+
parser.add_argument('-c', '--nocache', action='store_true', required=False, default=False)
|
|
41
|
+
args=parser.parse_args()
|
|
42
|
+
result:TFCPS_Generic_Functions=TFCPS_Generic_Functions(file,args.targetenvironmenttype,args.additionalargumentsfile,LogLevel(int(args.verbosity)),not args.nocache)
|
|
43
|
+
return result
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
from ..GeneralUtilities import GeneralUtilities
|
|
4
|
+
from ..SCLog import LogLevel
|
|
5
|
+
from ..ScriptCollectionCore import ScriptCollectionCore
|
|
6
|
+
from .TFCPS_Tools_General import TFCPS_Tools_General
|
|
7
|
+
from .TFCPS_CodeUnit_BuildCodeUnits import TFCPS_CodeUnit_BuildCodeUnits
|
|
8
|
+
from .TFCPS_Generic import TFCPS_Generic_Functions
|
|
9
|
+
|
|
10
|
+
class MergeToMainConfiguration:
|
|
11
|
+
product_name: str
|
|
12
|
+
merge_source_branch:str
|
|
13
|
+
additional_arguments_file:str
|
|
14
|
+
log_level:LogLevel
|
|
15
|
+
main_branch:str
|
|
16
|
+
repository_folder:str
|
|
17
|
+
tFCPS_Generic_Functions:TFCPS_Generic_Functions
|
|
18
|
+
common_remote_name:str
|
|
19
|
+
build_repo:str
|
|
20
|
+
sc:ScriptCollectionCore=ScriptCollectionCore()
|
|
21
|
+
|
|
22
|
+
def __init__(self, current_file: str,repository:str, product_name: str,merge_source_branch:str,log_level:LogLevel,additional_arguments_file:str,main_branch:str,common_remote_name:str,build_repo:str):
|
|
23
|
+
self.sc.log.loglevel=log_level
|
|
24
|
+
self.repository_folder = repository
|
|
25
|
+
self.product_name = product_name
|
|
26
|
+
self.merge_source_branch=merge_source_branch
|
|
27
|
+
self.additional_arguments_file=additional_arguments_file
|
|
28
|
+
self.log_level=log_level
|
|
29
|
+
self.main_branch=main_branch
|
|
30
|
+
self.common_remote_name=common_remote_name
|
|
31
|
+
self.build_repo=build_repo
|
|
32
|
+
|
|
33
|
+
class TFCPS_MergeToMain:
|
|
34
|
+
|
|
35
|
+
sc:ScriptCollectionCore
|
|
36
|
+
tFCPS_Tools_General:TFCPS_Tools_General
|
|
37
|
+
generic_prepare_new_release_arguments:MergeToMainConfiguration=None
|
|
38
|
+
|
|
39
|
+
def __init__(self,generic_prepare_new_release_arguments:MergeToMainConfiguration):
|
|
40
|
+
self.sc=ScriptCollectionCore()
|
|
41
|
+
self.tFCPS_Tools_General=TFCPS_Tools_General(self.sc)
|
|
42
|
+
self.generic_prepare_new_release_arguments=generic_prepare_new_release_arguments
|
|
43
|
+
|
|
44
|
+
@GeneralUtilities.check_arguments
|
|
45
|
+
def merge_to_main_branch(self ) -> None:
|
|
46
|
+
self.sc.log.loglevel=self.generic_prepare_new_release_arguments.log_level
|
|
47
|
+
self.sc.log.log("Merge to main-branch...")
|
|
48
|
+
fast_forward_source_branch: bool=True
|
|
49
|
+
source_branch: str=self.generic_prepare_new_release_arguments.merge_source_branch
|
|
50
|
+
target_branch: str=self.generic_prepare_new_release_arguments.main_branch
|
|
51
|
+
self.sc.assert_is_git_repository(self.generic_prepare_new_release_arguments.repository_folder)
|
|
52
|
+
|
|
53
|
+
GeneralUtilities.assert_condition(self.sc.git_get_commit_id(self.generic_prepare_new_release_arguments.repository_folder,source_branch)!=self.sc.git_get_commit_id(self.generic_prepare_new_release_arguments.repository_folder,target_branch),"Source- and target-branch must not be the same commit.")
|
|
54
|
+
|
|
55
|
+
self.sc.assert_no_uncommitted_changes(self.generic_prepare_new_release_arguments.repository_folder)
|
|
56
|
+
self.sc.git_checkout(self.generic_prepare_new_release_arguments.repository_folder, source_branch)
|
|
57
|
+
self.sc.assert_no_uncommitted_changes(self.generic_prepare_new_release_arguments.repository_folder)
|
|
58
|
+
|
|
59
|
+
tfcps_CodeUnit_BuildCodeUnits:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(self.generic_prepare_new_release_arguments.repository_folder,self.sc.log.loglevel,"QualityCheck",self.generic_prepare_new_release_arguments.additional_arguments_file,False,True)
|
|
60
|
+
try:
|
|
61
|
+
tfcps_CodeUnit_BuildCodeUnits.build_codeunits()
|
|
62
|
+
except Exception:
|
|
63
|
+
self.sc.git_undo_all_changes(self.generic_prepare_new_release_arguments.repository_folder)
|
|
64
|
+
raise
|
|
65
|
+
|
|
66
|
+
self.sc.git_commit(self.generic_prepare_new_release_arguments.repository_folder, 'Pre-merge-commit', stage_all_changes=True, no_changes_behavior=0)
|
|
67
|
+
|
|
68
|
+
if fast_forward_source_branch:
|
|
69
|
+
self.sc.git_checkout(self.generic_prepare_new_release_arguments.repository_folder, source_branch)
|
|
70
|
+
project_version:str=self.tFCPS_Tools_General.get_version_of_project(self.generic_prepare_new_release_arguments.repository_folder)
|
|
71
|
+
self.sc.git_merge(self.generic_prepare_new_release_arguments.repository_folder, source_branch, target_branch, False, True)
|
|
72
|
+
self.sc.git_merge(self.generic_prepare_new_release_arguments.repository_folder, target_branch, source_branch, True, True)
|
|
73
|
+
self.sc.git_create_tag(self.generic_prepare_new_release_arguments.repository_folder,target_branch,f"v{project_version}")
|
|
74
|
+
|
|
75
|
+
self.sc.log.log("Push branches...")
|
|
76
|
+
self.sc.git_push_with_retry(self.generic_prepare_new_release_arguments.repository_folder,self.generic_prepare_new_release_arguments.common_remote_name,source_branch,source_branch)
|
|
77
|
+
self.sc.git_push_with_retry(self.generic_prepare_new_release_arguments.repository_folder,self.generic_prepare_new_release_arguments.common_remote_name,target_branch,target_branch)
|
|
78
|
+
self.sc.git_commit(self.generic_prepare_new_release_arguments.build_repo,"Updated submodule")
|
|
79
|
+
|
|
80
|
+
class TFCPS_MergeToMain_CLI:
|
|
81
|
+
|
|
82
|
+
@staticmethod
|
|
83
|
+
def get_with_overwritable_defaults(file:str,default_merge_source_branch:str=None,default_loglevel:LogLevel=None,default_additionalargumentsfile:str=None,default_main_branch:str=None,default_common_remote_name:str=None)->TFCPS_MergeToMain:
|
|
84
|
+
parser = argparse.ArgumentParser()
|
|
85
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
|
86
|
+
parser.add_argument('-s', '--mergesourcebranch', required=False)
|
|
87
|
+
parser.add_argument('-a', '--additionalargumentsfile', required=False)
|
|
88
|
+
parser.add_argument('-t', '--mainbranch', required=False)
|
|
89
|
+
parser.add_argument('-r', '--commonremotename', required=False)
|
|
90
|
+
parser.add_argument('-v', '--verbosity', required=False, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
|
91
|
+
args=parser.parse_args()
|
|
92
|
+
|
|
93
|
+
sc:ScriptCollectionCore=ScriptCollectionCore()
|
|
94
|
+
|
|
95
|
+
build_repo=GeneralUtilities.resolve_relative_path("../../..",file)
|
|
96
|
+
sc.assert_is_git_repository(build_repo)
|
|
97
|
+
|
|
98
|
+
default_product_name=os.path.basename(build_repo)[:-len("Build")]
|
|
99
|
+
|
|
100
|
+
if args.mergesourcebranch is not None:
|
|
101
|
+
default_merge_source_branch=args.mergesourcebranch#other/next-release
|
|
102
|
+
GeneralUtilities.assert_not_null(default_merge_source_branch,"mergesourcebranch is not set")
|
|
103
|
+
|
|
104
|
+
if args.verbosity is not None:
|
|
105
|
+
default_loglevel=LogLevel(int( args.verbosity))
|
|
106
|
+
GeneralUtilities.assert_not_null(default_loglevel,"verbosity is not set")
|
|
107
|
+
|
|
108
|
+
if args.additionalargumentsfile is not None:
|
|
109
|
+
default_additionalargumentsfile=args.additionalargumentsfile
|
|
110
|
+
|
|
111
|
+
if args.mainbranch is not None:
|
|
112
|
+
default_main_branch=args.mainbranch#main
|
|
113
|
+
GeneralUtilities.assert_not_null(default_main_branch,"mainbranch is not set")
|
|
114
|
+
|
|
115
|
+
if args.commonremotename is not None:
|
|
116
|
+
default_common_remote_name=args.commonremotename
|
|
117
|
+
GeneralUtilities.assert_not_null(default_common_remote_name,"commonremotename is not set")
|
|
118
|
+
|
|
119
|
+
repository=os.path.join(build_repo,"Submodules",default_product_name)
|
|
120
|
+
config:MergeToMainConfiguration=MergeToMainConfiguration(file,repository,default_product_name,default_merge_source_branch,default_loglevel,default_additionalargumentsfile,default_main_branch,default_common_remote_name,build_repo)
|
|
121
|
+
tFCPS_MergeToMain:TFCPS_MergeToMain=TFCPS_MergeToMain(config)
|
|
122
|
+
return tFCPS_MergeToMain
|