ScriptCollection 4.3.63__py3-none-any.whl → 4.4.0__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 +205 -205
- ScriptCollection/CertificateUpdater.py +157 -155
- ScriptCollection/Executables.py +4 -2
- ScriptCollection/GeneralUtilities.py +1696 -1696
- ScriptCollection/OCIImages/OCIImageManager.py +278 -278
- ScriptCollection/ProcessesRunner.py +43 -43
- ScriptCollection/ProgramRunnerSudo.py +110 -110
- ScriptCollection/Resources/CultureChooser/CultureChooser.js +0 -0
- ScriptCollection/Resources/CultureChooser/index.html +0 -0
- ScriptCollection/Resources/Dependencies/JRE/Version.txt +0 -0
- ScriptCollection/Resources/Dependencies/OpenAPIGenerator/Version.txt +0 -0
- ScriptCollection/Resources/Dependencies/PlantUML/Version.txt +0 -0
- ScriptCollection/Resources/Fonts/DejaVuSans-Bold.ttf +0 -0
- ScriptCollection/Resources/Fonts/DejaVuSans-BoldOblique.ttf +0 -0
- ScriptCollection/Resources/Fonts/DejaVuSans-Oblique.ttf +0 -0
- ScriptCollection/Resources/Fonts/DejaVuSans.ttf +0 -0
- ScriptCollection/Resources/Fonts/LICENSE.txt +0 -0
- ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html +0 -0
- ScriptCollection/SCLog.py +115 -115
- ScriptCollection/ScriptCollectionCore.py +4372 -4292
- ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py +8 -2
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +716 -709
- ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py +235 -235
- ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py +258 -258
- ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py +524 -524
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py +157 -155
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py +691 -672
- ScriptCollection/TFCPS/TFCPS_CreateRelease.py +98 -98
- ScriptCollection/TFCPS/TFCPS_Generic.py +44 -44
- ScriptCollection/TFCPS/TFCPS_MergeToMain.py +132 -131
- ScriptCollection/TFCPS/TFCPS_MergeToStable.py +358 -358
- ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py +48 -48
- ScriptCollection/TFCPS/TFCPS_Tools_General.py +38 -8
- {scriptcollection-4.3.63.dist-info → scriptcollection-4.4.0.dist-info}/METADATA +1 -1
- {scriptcollection-4.3.63.dist-info → scriptcollection-4.4.0.dist-info}/RECORD +27 -27
- {scriptcollection-4.3.63.dist-info → scriptcollection-4.4.0.dist-info}/WHEEL +0 -0
- {scriptcollection-4.3.63.dist-info → scriptcollection-4.4.0.dist-info}/entry_points.txt +0 -0
- {scriptcollection-4.3.63.dist-info → scriptcollection-4.4.0.dist-info}/top_level.txt +0 -0
|
@@ -1,155 +1,157 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import re
|
|
3
|
-
from ..GeneralUtilities import GeneralUtilities
|
|
4
|
-
from ..ScriptCollectionCore import ScriptCollectionCore
|
|
5
|
-
from ..SCLog import LogLevel
|
|
6
|
-
from .TFCPS_Tools_General import TFCPS_Tools_General
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class TFCPS_CodeUnit_BuildCodeUnit:
|
|
10
|
-
|
|
11
|
-
codeunit_folder: str = None
|
|
12
|
-
repository_folder: str = None
|
|
13
|
-
sc: ScriptCollectionCore =
|
|
14
|
-
codeunit_name: str = None
|
|
15
|
-
tFCPS_Tools: TFCPS_Tools_General = None
|
|
16
|
-
target_environment_type: str = None
|
|
17
|
-
additionalargumentsfile: str = None
|
|
18
|
-
use_cache: bool = None
|
|
19
|
-
is_pre_merge: bool = None
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
self.sc
|
|
24
|
-
self.
|
|
25
|
-
self.tFCPS_Tools.
|
|
26
|
-
self.codeunit_folder
|
|
27
|
-
self.
|
|
28
|
-
self.
|
|
29
|
-
self.
|
|
30
|
-
self.
|
|
31
|
-
self.
|
|
32
|
-
self.
|
|
33
|
-
self.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if not
|
|
51
|
-
arguments
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
self.
|
|
59
|
-
|
|
60
|
-
self.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
self.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
self.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
for line in GeneralUtilities.string_to_lines(linting_result[
|
|
77
|
-
self.sc.log.log(line, LogLevel.Warning)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
self.sc.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
<cps:
|
|
112
|
-
<cps:
|
|
113
|
-
<cps:
|
|
114
|
-
<cps:
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
size_value
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
from ..GeneralUtilities import GeneralUtilities
|
|
4
|
+
from ..ScriptCollectionCore import ScriptCollectionCore
|
|
5
|
+
from ..SCLog import LogLevel
|
|
6
|
+
from .TFCPS_Tools_General import TFCPS_Tools_General
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TFCPS_CodeUnit_BuildCodeUnit:
|
|
10
|
+
|
|
11
|
+
codeunit_folder: str = None
|
|
12
|
+
repository_folder: str = None
|
|
13
|
+
sc: ScriptCollectionCore = None
|
|
14
|
+
codeunit_name: str = None
|
|
15
|
+
tFCPS_Tools: TFCPS_Tools_General = None
|
|
16
|
+
target_environment_type: str = None
|
|
17
|
+
additionalargumentsfile: str = None
|
|
18
|
+
use_cache: bool = None
|
|
19
|
+
is_pre_merge: bool = None
|
|
20
|
+
fast_lane: bool = None
|
|
21
|
+
|
|
22
|
+
def __init__(self, codeunit_folder: str, verbosity: LogLevel, target_environment_type: str, additionalargumentsfile: str, use_cache: bool,is_pre_merge:bool,fast_lane:bool=False):
|
|
23
|
+
self.sc = ScriptCollectionCore()
|
|
24
|
+
self.sc.log.loglevel = verbosity
|
|
25
|
+
self.tFCPS_Tools = TFCPS_Tools_General(self.sc)
|
|
26
|
+
self.tFCPS_Tools.assert_is_codeunit_folder(codeunit_folder)
|
|
27
|
+
self.codeunit_folder = codeunit_folder
|
|
28
|
+
self.codeunit_name = os.path.basename(self.codeunit_folder)
|
|
29
|
+
self.repository_folder =os.path.dirname(codeunit_folder)
|
|
30
|
+
self.sc.assert_is_git_repository(self.repository_folder)
|
|
31
|
+
self.target_environment_type = target_environment_type
|
|
32
|
+
self.additionalargumentsfile = additionalargumentsfile
|
|
33
|
+
self.use_cache = use_cache
|
|
34
|
+
self.is_pre_merge=is_pre_merge
|
|
35
|
+
self.fast_lane=fast_lane
|
|
36
|
+
|
|
37
|
+
@GeneralUtilities.check_arguments
|
|
38
|
+
def build_codeunit(self) -> None:
|
|
39
|
+
codeunit_file: str = str(os.path.join(self.codeunit_folder, f"{self.codeunit_name}.codeunit.xml"))
|
|
40
|
+
|
|
41
|
+
if not self.tFCPS_Tools.codeunit_is_enabled(codeunit_file):
|
|
42
|
+
self.sc.log.log(f"Codeunit {self.codeunit_name} is disabled.", LogLevel.Warning)
|
|
43
|
+
return
|
|
44
|
+
|
|
45
|
+
self.sc.log.log(f"Build codeunit {self.codeunit_name}...")
|
|
46
|
+
|
|
47
|
+
GeneralUtilities.ensure_folder_exists_and_is_empty(self.codeunit_folder+"/Other/Artifacts")
|
|
48
|
+
|
|
49
|
+
arguments: str = f"--targetenvironmenttype {self.target_environment_type} --verbosity {int(self.sc.log.loglevel)}"
|
|
50
|
+
if self.additionalargumentsfile is not None:
|
|
51
|
+
arguments=arguments+f" --additionalargumentsfile {self.additionalargumentsfile}"
|
|
52
|
+
if not self.use_cache:
|
|
53
|
+
arguments = f"{arguments} --nocache"
|
|
54
|
+
|
|
55
|
+
if self.is_pre_merge:
|
|
56
|
+
arguments = f"{arguments} --ispremerge"
|
|
57
|
+
|
|
58
|
+
self.sc.log.log("Do common tasks...")
|
|
59
|
+
self.sc.run_program(GeneralUtilities.get_python_executable(), f"CommonTasks.py {arguments}", os.path.join(self.codeunit_folder, "Other"), print_live_output=self.sc.log.loglevel==LogLevel.Debug)
|
|
60
|
+
self.verify_artifact_exists(self.codeunit_folder, dict[str, bool]({"License": True}))
|
|
61
|
+
|
|
62
|
+
self.sc.log.log("Build...")
|
|
63
|
+
self.sc.run_program(GeneralUtilities.get_python_executable(), f"Build.py {arguments}", os.path.join(self.codeunit_folder, "Other", "Build"), print_live_output=self.sc.log.loglevel==LogLevel.Debug)
|
|
64
|
+
artifacts = {"BuildResult_.+": True, "BOM": False, "SourceCode": self.tFCPS_Tools.codeunit_has_testable_sourcecode(codeunit_file)}
|
|
65
|
+
self.verify_artifact_exists(self.codeunit_folder, dict[str, bool](artifacts))
|
|
66
|
+
|
|
67
|
+
if self.tFCPS_Tools.codeunit_has_testable_sourcecode(codeunit_file) and not self.fast_lane:
|
|
68
|
+
self.sc.log.log("Run testcases...")
|
|
69
|
+
self.sc.run_program(GeneralUtilities.get_python_executable(), f"RunTestcases.py {arguments}", os.path.join(self.codeunit_folder, "Other", "QualityCheck"), print_live_output=self.sc.log.loglevel==LogLevel.Debug)
|
|
70
|
+
self.verify_artifact_exists(self.codeunit_folder, dict[str, bool]({"TestCoverage": True, "TestCoverageReport": False}))
|
|
71
|
+
|
|
72
|
+
self.sc.log.log("Check for linting-issues...")
|
|
73
|
+
linting_result = self.sc.run_program(GeneralUtilities.get_python_executable(), f"Linting.py {arguments}", os.path.join(self.codeunit_folder, "Other", "QualityCheck"), print_live_output=self.sc.log.loglevel==LogLevel.Quiet, throw_exception_if_exitcode_is_not_zero=False)
|
|
74
|
+
if linting_result[0] != 0:
|
|
75
|
+
self.sc.log.log("Linting-issues were found.", LogLevel.Warning)
|
|
76
|
+
for line in GeneralUtilities.string_to_lines(linting_result[1]):
|
|
77
|
+
self.sc.log.log(line, LogLevel.Warning)
|
|
78
|
+
for line in GeneralUtilities.string_to_lines(linting_result[2]):
|
|
79
|
+
self.sc.log.log(line, LogLevel.Warning)
|
|
80
|
+
|
|
81
|
+
self.sc.log.log("Generate reference...")
|
|
82
|
+
try:
|
|
83
|
+
self.sc.run_program(GeneralUtilities.get_python_executable(), "GenerateReference.py", os.path.join(self.codeunit_folder, "Other", "Reference"), print_live_output=self.sc.log.loglevel==LogLevel.Debug)
|
|
84
|
+
except Exception as e:
|
|
85
|
+
self.sc.log.log_exception(f"Generating reference failed with the following error",e, LogLevel.Warning)
|
|
86
|
+
self.verify_artifact_exists(self.codeunit_folder, dict[str, bool]({"Reference": True}))
|
|
87
|
+
|
|
88
|
+
if os.path.isfile(os.path.join(self.codeunit_folder, "Other", "OnBuildingFinished.py")):
|
|
89
|
+
self.sc.log.log('Finalize building codeunits...')
|
|
90
|
+
self.sc.run_program(GeneralUtilities.get_python_executable(), f"OnBuildingFinished.py {arguments}", os.path.join(self.codeunit_folder, "Other"), print_live_output=self.sc.log.loglevel==LogLevel.Debug)
|
|
91
|
+
|
|
92
|
+
codeunit_version = self.tFCPS_Tools.get_version_of_codeunit(codeunit_file)
|
|
93
|
+
|
|
94
|
+
# Generate diff-report
|
|
95
|
+
self.tFCPS_Tools.generate_diff_report(self.repository_folder, self.codeunit_name, codeunit_version)
|
|
96
|
+
|
|
97
|
+
artifacts_folder = os.path.join(self.codeunit_folder, "Other", "Artifacts")
|
|
98
|
+
artifactsinformation_file = os.path.join(artifacts_folder, f"{self.codeunit_name}.artifactsinformation.xml")
|
|
99
|
+
GeneralUtilities.ensure_file_exists(artifactsinformation_file)
|
|
100
|
+
artifacts_list = []
|
|
101
|
+
for artifact_folder in GeneralUtilities.get_direct_folders_of_folder(artifacts_folder):
|
|
102
|
+
artifact_name = os.path.basename(artifact_folder)
|
|
103
|
+
artifacts_list.append(f" <cps:artifact>{artifact_name}<cps:artifact>")
|
|
104
|
+
artifacts = '\n'.join(artifacts_list)
|
|
105
|
+
moment = GeneralUtilities.datetime_to_string(GeneralUtilities.get_now())
|
|
106
|
+
commit_id = self.sc.git_get_commit_id(self.repository_folder) # the actual commit-id (not the branch-name) which was checked-out while building this codeunit
|
|
107
|
+
# TODO implement usage of reference_latest_version_of_xsd_when_generating_xml
|
|
108
|
+
GeneralUtilities.write_text_to_file(artifactsinformation_file, f"""<?xml version="1.0" encoding="UTF-8" ?>
|
|
109
|
+
<cps:artifactsinformation xmlns:cps="https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure" artifactsinformationspecificationversion="1.0.0"
|
|
110
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/raw/main/Conventions/RepositoryStructure/CommonProjectStructure/artifactsinformation.xsd">
|
|
111
|
+
<cps:name>{self.codeunit_name}</cps:name>
|
|
112
|
+
<cps:version>{codeunit_version}</cps:version>
|
|
113
|
+
<cps:timestamp>{moment}</cps:timestamp>
|
|
114
|
+
<cps:targetenvironmenttype>{self.target_environment_type}</cps:targetenvironmenttype>
|
|
115
|
+
<cps:commitid>{commit_id}</cps:commitid>
|
|
116
|
+
<cps:artifacts>
|
|
117
|
+
{artifacts}
|
|
118
|
+
</cps:artifacts>
|
|
119
|
+
</cps:artifactsinformation>""")
|
|
120
|
+
# TODO validate artifactsinformation_file against xsd
|
|
121
|
+
if self.sc.log.loglevel == LogLevel.Debug:
|
|
122
|
+
artifacts_folder_size_bytes = sum(os.path.getsize(os.path.join(dirpath, f))
|
|
123
|
+
for dirpath, _, filenames in os.walk(artifacts_folder)
|
|
124
|
+
for f in filenames)
|
|
125
|
+
size_value: float = float(artifacts_folder_size_bytes)
|
|
126
|
+
size_unit: str = "B"
|
|
127
|
+
for candidate_unit in ("KB", "MB", "GB", "TB"):
|
|
128
|
+
if size_value < 1024:
|
|
129
|
+
break
|
|
130
|
+
size_value /= 1024
|
|
131
|
+
size_unit = candidate_unit
|
|
132
|
+
self.sc.log.log(f"Size of artifacts-folder of codeunit {self.codeunit_name}: {size_value:.2f} {size_unit}", LogLevel.Debug)
|
|
133
|
+
self.sc.log.log(f"Finished building codeunit {self.codeunit_name} without errors.")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@GeneralUtilities.check_arguments
|
|
137
|
+
def verify_artifact_exists(self, codeunit_folder: str, artifact_name_regexes: dict[str, bool]) -> None:
|
|
138
|
+
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
139
|
+
artifacts_folder = os.path.join(codeunit_folder, "Other/Artifacts")
|
|
140
|
+
existing_artifacts = [os.path.basename(x) for x in GeneralUtilities.get_direct_folders_of_folder(artifacts_folder)]
|
|
141
|
+
for artifact_name_regex, required in artifact_name_regexes.items():
|
|
142
|
+
artifact_exists = False
|
|
143
|
+
for existing_artifact in existing_artifacts:
|
|
144
|
+
pattern = re.compile(artifact_name_regex)
|
|
145
|
+
if pattern.match(existing_artifact):
|
|
146
|
+
artifact_exists = True
|
|
147
|
+
if not artifact_exists:
|
|
148
|
+
message = f"Codeunit {codeunit_name} does not contain an artifact which matches the name '{artifact_name_regex}'."
|
|
149
|
+
if required:
|
|
150
|
+
raise ValueError(message)
|
|
151
|
+
else:
|
|
152
|
+
self.sc.log.log(message, LogLevel.Warning)
|
|
153
|
+
|
|
154
|
+
@GeneralUtilities.check_arguments
|
|
155
|
+
def update_dependencies(self) -> None:
|
|
156
|
+
self.sc.log.log("Update dependencies for codeunit...")
|
|
157
|
+
self.sc.run_program(GeneralUtilities.get_python_executable(), "UpdateDependencies.py", os.path.join(self.codeunit_folder, "Other"),print_live_output=True)
|