ScriptCollection 4.3.31__py3-none-any.whl → 4.3.33__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/Executables.py +5 -1
- ScriptCollection/ScriptCollectionCore.py +1 -1
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +21 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py +20 -44
- {scriptcollection-4.3.31.dist-info → scriptcollection-4.3.33.dist-info}/METADATA +1 -1
- {scriptcollection-4.3.31.dist-info → scriptcollection-4.3.33.dist-info}/RECORD +9 -9
- {scriptcollection-4.3.31.dist-info → scriptcollection-4.3.33.dist-info}/WHEEL +0 -0
- {scriptcollection-4.3.31.dist-info → scriptcollection-4.3.33.dist-info}/entry_points.txt +0 -0
- {scriptcollection-4.3.31.dist-info → scriptcollection-4.3.33.dist-info}/top_level.txt +0 -0
ScriptCollection/Executables.py
CHANGED
|
@@ -279,6 +279,7 @@ def BuildCodeUnits() -> int:
|
|
|
279
279
|
def BuildCodeUnitsC() -> int:
|
|
280
280
|
parser = argparse.ArgumentParser()
|
|
281
281
|
parser.add_argument('-r','--repositoryfolder', required=False, default=".")
|
|
282
|
+
parser.add_argument('-b','--basemountfolder', required=False, default=None)
|
|
282
283
|
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
|
283
284
|
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
|
284
285
|
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
|
@@ -292,8 +293,11 @@ def BuildCodeUnitsC() -> int:
|
|
|
292
293
|
GeneralUtilities.reconfigure_standard_input_and_outputs()
|
|
293
294
|
repo:str=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
|
|
294
295
|
verbosity=LogLevel(int(args.verbosity))
|
|
296
|
+
base_mount_folder:str=args.basemountfolder
|
|
297
|
+
if base_mount_folder is None:
|
|
298
|
+
base_mount_folder=repo
|
|
295
299
|
t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,args.ispremerge,args.assertnonewchanges,args.addreadytomergeflag)
|
|
296
|
-
success, _ = t.build_codeunits_in_container()
|
|
300
|
+
success, _ = t.build_codeunits_in_container(base_mount_folder)
|
|
297
301
|
return 0 if success else 1
|
|
298
302
|
|
|
299
303
|
def UpdateDependencies() -> int:
|
|
@@ -371,6 +371,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
371
371
|
if not result1[0]:
|
|
372
372
|
hints: str = "\n".join(result1[2])
|
|
373
373
|
raise ValueError(f"'{csproj_file}' with content '{GeneralUtilities.read_text_from_file(csproj_file)}' does not match the standardized .csproj-file-format which is defined by the regex '{result1[1]}'.\n{hints}")
|
|
374
|
+
self.__check_csproj_urls(csproj_file)
|
|
374
375
|
|
|
375
376
|
test_csproj_project_name = csproj_project_name+"Tests"
|
|
376
377
|
test_csproj_file = os.path.join(codeunit_folder, test_csproj_project_name, test_csproj_project_name+".csproj")
|
|
@@ -378,6 +379,26 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
378
379
|
if not result2[0]:
|
|
379
380
|
hints: str = "\n".join(result2[2])
|
|
380
381
|
raise ValueError(f"'{test_csproj_file}' with content '{GeneralUtilities.read_text_from_file(test_csproj_file)}' does not match the standardized .csproj-file-format which is defined by the regex '{result2[1]}'.\n{hints}")
|
|
382
|
+
self.__check_csproj_urls(test_csproj_file)
|
|
383
|
+
|
|
384
|
+
@GeneralUtilities.check_arguments
|
|
385
|
+
def __check_csproj_urls(self, csproj_file: str) -> None:
|
|
386
|
+
remote_address: str = self.get_remote_address()
|
|
387
|
+
root: etree._ElementTree = etree.parse(csproj_file)
|
|
388
|
+
package_project_url: str = self.__get_unique_csproj_property_value(root, csproj_file, "PackageProjectUrl")
|
|
389
|
+
repository_url: str = self.__get_unique_csproj_property_value(root, csproj_file, "RepositoryUrl")
|
|
390
|
+
if package_project_url != remote_address:
|
|
391
|
+
raise ValueError(f"The PackageProjectUrl-value '{package_project_url}' in '{csproj_file}' is not equal to the remote-address '{remote_address}' which is defined in the ProductInformation.xml-file of the repository.")
|
|
392
|
+
expected_repository_url: str = package_project_url+".git"
|
|
393
|
+
if repository_url != expected_repository_url:
|
|
394
|
+
raise ValueError(f"The RepositoryUrl-value '{repository_url}' in '{csproj_file}' is not equal to the expected value '{expected_repository_url}'.")
|
|
395
|
+
|
|
396
|
+
@GeneralUtilities.check_arguments
|
|
397
|
+
def __get_unique_csproj_property_value(self, root: etree._ElementTree, csproj_file: str, property_name: str) -> str:
|
|
398
|
+
values: list[str] = [str(value).strip() for value in root.xpath(f"/Project/PropertyGroup/{property_name}/text()")]
|
|
399
|
+
if len(values) != 1:
|
|
400
|
+
raise ValueError(f"'{csproj_file}' must contain exactly one {property_name}-element but contains {len(values)} of them.")
|
|
401
|
+
return values[0]
|
|
381
402
|
|
|
382
403
|
def __standardized_task_verify_standard_format_for_project_csproj_file(self, csproj_file: str, codeunit_folder: str, codeunit_name: str, codeunit_version: str) -> tuple[bool, str, str]:
|
|
383
404
|
codeunit_name_regex = re.escape(codeunit_name)
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import json
|
|
3
3
|
import re
|
|
4
|
-
import shutil
|
|
5
4
|
import socket
|
|
6
|
-
import uuid
|
|
7
5
|
from datetime import datetime, timedelta,timezone
|
|
8
6
|
import xmlschema
|
|
9
7
|
import yaml
|
|
@@ -170,8 +168,15 @@ class TFCPS_CodeUnit_BuildCodeUnits:
|
|
|
170
168
|
return self.build_codeunits_in_container()
|
|
171
169
|
|
|
172
170
|
@GeneralUtilities.check_arguments
|
|
173
|
-
def build_codeunits_in_container(self) -> tuple[bool, str]:
|
|
174
|
-
|
|
171
|
+
def build_codeunits_in_container(self,base_mount_folder:str) -> tuple[bool, str]:
|
|
172
|
+
#base_mount_folder is assumed to be an absolute path set correctly by the caller (see BuildCodeUnitsC in Executables.py, which defaults it to the repository itself).
|
|
173
|
+
#it may be the repository itself or any parent-folder of it, which allows the caller to mount not only the repository but the whole surrounding folder-structure into the container.
|
|
174
|
+
normalized_base_mount_folder = os.path.normpath(base_mount_folder)
|
|
175
|
+
normalized_repository = os.path.normpath(self.repository)
|
|
176
|
+
relative_repository_path = os.path.relpath(normalized_repository, normalized_base_mount_folder).replace(os.sep, "/")
|
|
177
|
+
GeneralUtilities.assert_condition(relative_repository_path == "." or not relative_repository_path.startswith(".."), f"The repository '{self.repository}' is not located inside the base-mount-folder '{base_mount_folder}'.")
|
|
178
|
+
container_base_mount_folder = f"/Workspace/Project/{os.path.basename(normalized_base_mount_folder)}"
|
|
179
|
+
container_repository_folder = container_base_mount_folder if relative_repository_path == "." else f"{container_base_mount_folder}/{relative_repository_path}"
|
|
175
180
|
image = self.tfcps_tools_general.oci_image_manager.get_registry_address_for_image_with_default_tag(self.repository, "SCBuilder")
|
|
176
181
|
|
|
177
182
|
#build the scbuildcodeunits-arguments based on the current state (analogous to the arguments accepted by the scbuildcodeunits-executable). each token must be a separate argument because run_program_argsasarray passes every list-element verbatim and does not split on spaces.
|
|
@@ -187,56 +192,27 @@ class TFCPS_CodeUnit_BuildCodeUnits:
|
|
|
187
192
|
if GeneralUtilities.string_has_content(self.additionalargumentsfile):
|
|
188
193
|
scbuildcodeunits_arguments += ["-a", self.__translate_path_into_container(self.additionalargumentsfile, container_repository_folder)]
|
|
189
194
|
|
|
190
|
-
#if the repository is a git-submodule then "<repository>/.git" is
|
|
191
|
-
#
|
|
192
|
-
#
|
|
193
|
-
#
|
|
194
|
-
#
|
|
195
|
-
#
|
|
196
|
-
# - the gitdir's "config" by a copy whose "core.worktree" points at the in-container working-tree.
|
|
197
|
-
#The config-override is required because the submodule-gitdir's original "core.worktree" references the original (now wrong)
|
|
198
|
-
#location: git itself could be told via GIT_WORK_TREE, but gitversion (libgit2) reads core.worktree from the config and ignores
|
|
199
|
-
#GIT_WORK_TREE - it would otherwise fail with "doesn't point at a valid Git repository or workdir". For a normal repository (own
|
|
200
|
-
#".git"-directory) nothing additional is required.
|
|
201
|
-
git_dir_docker_arguments: list[str] = []
|
|
202
|
-
staged_git_pointer_file: str = None
|
|
203
|
-
staged_git_config_file: str = None
|
|
204
|
-
if os.path.isfile(os.path.join(self.repository, ".git")):
|
|
205
|
-
real_git_folder = self.sc.get_real_git_folder(self.repository)
|
|
206
|
-
container_git_dir = "/Workspace/RepositoryGitDir"
|
|
207
|
-
staged_git_pointer_file = os.path.join(GeneralUtilities.get_temp_folder(), f"sc-container-gitpointer-{uuid.uuid4()}")
|
|
208
|
-
GeneralUtilities.write_text_to_file(staged_git_pointer_file, f"gitdir: {container_git_dir}\n")
|
|
209
|
-
staged_git_config_file = os.path.join(GeneralUtilities.get_temp_folder(), f"sc-container-gitconfig-{uuid.uuid4()}")
|
|
210
|
-
shutil.copyfile(os.path.join(real_git_folder, "config"), staged_git_config_file)
|
|
211
|
-
self.sc.run_program_argsasarray("git", ["config", "--file", staged_git_config_file, "core.worktree", container_repository_folder], GeneralUtilities.get_temp_folder())
|
|
212
|
-
git_dir_docker_arguments = [
|
|
213
|
-
"-v", f"{real_git_folder}:{container_git_dir}",
|
|
214
|
-
"-v", f"{staged_git_config_file}:{container_git_dir}/config",
|
|
215
|
-
"-v", f"{staged_git_pointer_file}:{container_repository_folder}/.git",
|
|
216
|
-
]
|
|
217
|
-
|
|
195
|
+
#if the repository is a git-submodule then "<repository>/.git" is a pointer-file referencing its gitdir via a path relative to the repository
|
|
196
|
+
#(for example "gitdir: ../../.git/modules/Submodules/<product>"), and the gitdir's own "core.worktree" points back at the repository via a
|
|
197
|
+
#path relative to the gitdir. Both references are relative, so they resolve correctly inside the container as long as the mounted folder-structure
|
|
198
|
+
#preserves that relative path - which is what base_mount_folder is for: the caller has to mount a folder that also contains the repository's real
|
|
199
|
+
#gitdir (typically the parent-repository the submodule belongs to). No file-rewriting is required; a base_mount_folder that does not cover the
|
|
200
|
+
#real gitdir results in failing git-commands inside the container.
|
|
218
201
|
test=True#TODO remove this
|
|
219
202
|
if test:
|
|
220
203
|
scbuildcodeunits_arguments=["bash","-c", "pip3 install scriptcollection --upgrade && scshowversion && "+" ".join(scbuildcodeunits_arguments)]
|
|
221
|
-
|
|
222
|
-
#run scbuildcodeunits inside the SCBuilder-image.
|
|
204
|
+
|
|
205
|
+
#run scbuildcodeunits inside the SCBuilder-image. base_mount_folder is mounted into the container (covering the repository and, for submodules, its real gitdir) and the docker-socket is forwarded because codeunit-builds often start containers (for example local test-services).
|
|
223
206
|
docker_arguments = [
|
|
224
207
|
"run", "--rm",
|
|
225
|
-
"-v", f"{
|
|
208
|
+
"-v", f"{base_mount_folder}:{container_base_mount_folder}",
|
|
226
209
|
"-v", "/var/run/docker.sock:/var/run/docker.sock",
|
|
227
|
-
] + git_dir_docker_arguments + [
|
|
228
210
|
"-w", container_repository_folder,
|
|
229
211
|
image,
|
|
230
212
|
] + scbuildcodeunits_arguments
|
|
231
213
|
self.sc.log.log(f"Build codeunits in container using image \"{image}\"...")
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
result=self.sc.run_program_argsasarray("docker", docker_arguments, throw_exception_if_exitcode_is_not_zero=False, print_live_output=True)
|
|
235
|
-
finally:
|
|
236
|
-
if staged_git_pointer_file is not None:
|
|
237
|
-
GeneralUtilities.ensure_file_does_not_exist(staged_git_pointer_file)
|
|
238
|
-
if staged_git_config_file is not None:
|
|
239
|
-
GeneralUtilities.ensure_file_does_not_exist(staged_git_config_file)
|
|
214
|
+
# the exitcode is evaluated by the caller (returned as part of the result-tuple), so the program-runner must not raise on a non-zero exitcode here.
|
|
215
|
+
result=self.sc.run_program_argsasarray("docker", docker_arguments, throw_exception_if_exitcode_is_not_zero=False, print_live_output=True)
|
|
240
216
|
exit_code:int=result[0]
|
|
241
217
|
stdout:str=result[1] or GeneralUtilities.empty_string
|
|
242
218
|
stderr:str=result[2] or GeneralUtilities.empty_string
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptcollection
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.33
|
|
4
4
|
Summary: The ScriptCollection is the place for reusable scripts.
|
|
5
5
|
Author-email: Marius Göcke <marius.goecke@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
ScriptCollection/AnionBuildPlatform.py,sha256=GP-jnb1GbvT8jzlH-cqnxgOzBzeUdiaWnDXtKNjsxiA,12153
|
|
2
2
|
ScriptCollection/CertificateUpdater.py,sha256=dR5JpJDlZdjD4_pgMz7zCrt1IM7VfatmK6pULSczxQw,9693
|
|
3
|
-
ScriptCollection/Executables.py,sha256=
|
|
3
|
+
ScriptCollection/Executables.py,sha256=bIeZZwmMFeTAyaqREHzsfgHrbyNSLMKwhGGW2sFnS_o,67929
|
|
4
4
|
ScriptCollection/GeneralUtilities.py,sha256=qYhrKkwbEewGIppuxYRmGhLP50C443tw7sBlwH7Mkbc,71606
|
|
5
5
|
ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
|
|
6
6
|
ScriptCollection/ProcessesRunner.py,sha256=yYaC95h40uszuZPggn2kK3qXIN2ZjGMCavo-NQ53ElQ,1537
|
|
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
|
|
|
9
9
|
ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
|
|
10
10
|
ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
|
|
11
11
|
ScriptCollection/SCLog.py,sha256=LdzSJy3NnnwYCCefz2h4tiTy4BjT8lOz3IBG_bMOg9E,4821
|
|
12
|
-
ScriptCollection/ScriptCollectionCore.py,sha256=
|
|
12
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=hW-WGzTm5vDD0pPLaI3S9MJVjK5c0ED9_WOUlB5l1qQ,246436
|
|
13
13
|
ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
|
|
14
14
|
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=WO2M28c2tUwsXFNa2L9zqMhdlyObWm3qpPE0LdIs7SE,2315
|
|
@@ -35,7 +35,7 @@ ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz
|
|
|
35
35
|
ScriptCollection/TFCPS/SCTaskRunnerServer.py,sha256=rpuwSsQ6YQfZS2LGnvOH5ql8zs_-cHU4LQttS7XNT60,11272
|
|
36
36
|
ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=H9FWlS6BPK-UWJXdWN686ePky4Hq-Q13T0Kx8HSJu7s,34990
|
|
37
37
|
ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=Ll5EOkpVpPiFrM2mLeQXolaF7075IwgtnHXvfdpkH4k,9904
|
|
38
|
-
ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=
|
|
38
|
+
ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=Fl9WakuMYzmvkLg_DXVm76RtTOpnCvwRqNL55ARwIcM,30249
|
|
39
39
|
ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=X2NgZgbOkJsdZ6wMHB_RuS_rQCuz5oQCqzYrxyXBN9Q,6680
|
|
40
40
|
ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=5vCFfDiU8bvfcnoKNs2ATS8nsl6mYXcIuX7XfYE0tvg,2116
|
|
41
41
|
ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=zp7n0Li7GTi4tERDMgDcJ-o3m6131m31zvkat0lALEc,7781
|
|
@@ -49,7 +49,7 @@ ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
|
49
49
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py,sha256=bT6Gd5pQpZCw4OQz6HWkPCSn5z__eUUEisABLDSxd0o,200
|
|
50
50
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=QyjOfMY22JWCvKjMelHiDWbJiWqotOfebpJpgDUaoO4,237
|
|
51
51
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
|
|
52
|
-
ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=
|
|
52
|
+
ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=guriYXXDif2QSSlGUpVBS_G6fQr6kivS9RiIQ7_zdEI,45538
|
|
53
53
|
ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
54
|
ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=d8U-sIhsneMplYkG73BJRQQZh4uLoX7QiOhbnZNuOM8,8540
|
|
55
55
|
ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -63,8 +63,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=Bd1gxCk9Fb
|
|
|
63
63
|
ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
64
64
|
ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
|
|
65
65
|
ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
66
|
-
scriptcollection-4.3.
|
|
67
|
-
scriptcollection-4.3.
|
|
68
|
-
scriptcollection-4.3.
|
|
69
|
-
scriptcollection-4.3.
|
|
70
|
-
scriptcollection-4.3.
|
|
66
|
+
scriptcollection-4.3.33.dist-info/METADATA,sha256=cQnGOXjabT63Ca4ipUwFMVHkqkYORsp7RpW-PdqELhA,7816
|
|
67
|
+
scriptcollection-4.3.33.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
68
|
+
scriptcollection-4.3.33.dist-info/entry_points.txt,sha256=Iq9YMSTWNCAJpBzM5L9CQx80tL9-XUu6MzDRAdBrIPg,5875
|
|
69
|
+
scriptcollection-4.3.33.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
70
|
+
scriptcollection-4.3.33.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|