Skip to content

Commit

Permalink
Merge branch other/next-release into main
Browse files Browse the repository at this point in the history
  • Loading branch information
anionDev committed Jan 22, 2023
2 parents 6596cba + 8f7fa78 commit 747baab
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 44 deletions.
5 changes: 5 additions & 0 deletions Other/Resources/Changelog/v3.3.53.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release notes

## Changes

- Updates for building .NET-projects.
2 changes: 1 addition & 1 deletion ScriptCollection/Other/Hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Requirements

The following tools from the [tools-list](https://github.com/anionDev/ScriptCollection/blob/main/ScriptCollection/Other/Reference/ReferenceContent/articles/RequiredToolsForCommonProjectStructure.md#Tools) are required to build this code-unit:
The following tools from the [tools-list](https://github.com/anionDev/ScriptCollection/blob/main/ScriptCollection/Other/Reference/ReferenceContent/Articles/RequiredToolsForCommonProjectStructure.md#Tools) are required to build this code-unit:

- `coverage`
- `docfx`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<coverage version="1.0" date="2023-01-22_23-44-01" tag="v3.3.53">
<assembly name="ScriptCollection">
<class name="Executables.py" coveredlines="0" coverablelines="233" totallines="336" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
<class name="GeneralUtilities.py" coveredlines="424" coverablelines="680" totallines="810" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
<class name="Hardening.py" coveredlines="0" coverablelines="32" totallines="59" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
<class name="ProgramRunnerBase.py" coveredlines="22" coverablelines="28" totallines="42" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
<class name="ProgramRunnerEpew.py" coveredlines="40" coverablelines="103" totallines="122" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
<class name="ProgramRunnerPopen.py" coveredlines="25" coverablelines="37" totallines="50" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
<class name="ScriptCollectionCore.py" coveredlines="490" coverablelines="1090" totallines="1440" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
<class name="TasksForCommonProjectStructure.py" coveredlines="248" coverablelines="997" totallines="1353" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
<class name="UpdateCertificates.py" coveredlines="0" coverablelines="105" totallines="128" coveredbranches="0" totalbranches="0" coveredcodeelements="0" totalcodeelements="0" />
</assembly>
</coverage>
2 changes: 1 addition & 1 deletion ScriptCollection/ScriptCollection.codeunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<cps:codeunit xmlns:cps="https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure" codeunitspecificationversion="1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/raw/main/Conventions/RepositoryStructure/CommonProjectStructure/codeunit.xsd">
<cps:name>ScriptCollection</cps:name>
<cps:version>3.3.52</cps:version>
<cps:version>3.3.53</cps:version>
<cps:minimalcodecoverageinpercent>30</cps:minimalcodecoverageinpercent>
<cps:dependentcodeunits></cps:dependentcodeunits>
</cps:codeunit>
2 changes: 1 addition & 1 deletion ScriptCollection/ScriptCollection/ScriptCollectionCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument


version = "3.3.52"
version = "3.3.53"
__version__ = version


Expand Down
55 changes: 15 additions & 40 deletions ScriptCollection/ScriptCollection/TasksForCommonProjectStructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,6 @@ def get_version_of_codeunit_folder(self, codeunit_folder: str) -> None:
codeunit_file = os.path.join(codeunit_folder, f"{os.path.basename(codeunit_folder)}.codeunit.xml")
return self.get_version_of_codeunit(codeunit_file)

@staticmethod
@GeneralUtilities.check_arguments
def get_buildconfigurationdevelopment_from_commandline_arguments(commandline_arguments: list[str], default_value: str) -> str:
return TasksForCommonProjectStructure.get_string_value_from_commandline_arguments(commandline_arguments, "buildconfigurationdevelopment", default_value)

@staticmethod
@GeneralUtilities.check_arguments
def get_buildconfigurationqualitycheck_from_commandline_arguments(commandline_arguments: list[str], default_value: str) -> str:
return TasksForCommonProjectStructure.get_string_value_from_commandline_arguments(commandline_arguments, "buildconfigurationqualitycheck", default_value)

@staticmethod
@GeneralUtilities.check_arguments
def get_buildconfigurationproductive_from_commandline_arguments(commandline_arguments: list[str], default_value: str) -> str:
return TasksForCommonProjectStructure.get_string_value_from_commandline_arguments(commandline_arguments, "buildconfigurationproductive", default_value)

@staticmethod
@GeneralUtilities.check_arguments
def get_string_value_from_commandline_arguments(commandline_arguments: list[str], property_name: str, default_value: str) -> str:
Expand Down Expand Up @@ -379,8 +364,10 @@ def standardized_tasks_generate_reference_by_docfx(self, generate_reference_scri
GeneralUtilities.ensure_directory_does_not_exist(obj_folder)

@GeneralUtilities.check_arguments
def __standardized_tasks_build_for_dotnet_build(self, csproj_file: str, buildconfiguration: str, originaloutputfolder: str, files_to_sign: dict[str, str], commitid: str,
verbosity: int, runtimes: list[str]):
def __standardized_tasks_build_for_dotnet_build(self, csproj_file: str, originaloutputfolder: str, files_to_sign: dict[str, str], commitid: str,
verbosity: int, runtimes: list[str], target_environmenttype: str, target_environmenttype_mapping: dict[str, str],
commandline_arguments: list[str]):
dotnet_build_configuration: str = target_environmenttype_mapping[target_environmenttype]
for runtime in runtimes:
outputfolder = originaloutputfolder+runtime
csproj_file_folder = os.path.dirname(csproj_file)
Expand All @@ -390,8 +377,8 @@ def __standardized_tasks_build_for_dotnet_build(self, csproj_file: str, buildcon
GeneralUtilities.ensure_directory_does_not_exist(os.path.join(csproj_file_folder, "obj"))
GeneralUtilities.ensure_directory_does_not_exist(outputfolder)
GeneralUtilities.ensure_directory_exists(outputfolder)
# TODO pass commitid, timestamp and if desired something like keypair, certificate to the src-code
self.__sc.run_program("dotnet", f"build {csproj_file_name} -c {buildconfiguration} -o {outputfolder} --runtime {runtime}", csproj_file_folder, verbosity=verbosity)
self.__sc.run_program("dotnet", f"build {csproj_file_name} -c {dotnet_build_configuration} -o {outputfolder} --runtime {runtime}",
csproj_file_folder, verbosity=verbosity)
for file, keyfile in files_to_sign.items():
self.__sc.dotnet_sign_file(os.path.join(outputfolder, file), keyfile, verbosity)

Expand All @@ -416,16 +403,6 @@ def standardized_tasks_build_for_dotnet_library_project(self, buildscript_file:
buildscript_file, target_environmenttype_mapping, default_target_environmenttype, verbosity, target_environmenttype, runtimes, commandline_arguments)
self.__standardized_tasks_build_nupkg_for_dotnet_create_package(buildscript_file, verbosity, commandline_arguments)

@GeneralUtilities.check_arguments
def __get_dotnet_buildconfiguration_by_target_environmenttype(self, targetenvironmenttype: str, default_value: str, commandline_arguments: list[str]):
if targetenvironmenttype == TasksForCommonProjectStructure.get_development_environment_name():
return self.get_buildconfigurationdevelopment_from_commandline_arguments(commandline_arguments, default_value)
if targetenvironmenttype == TasksForCommonProjectStructure.get_qualitycheck_environment_name():
return self.get_buildconfigurationqualitycheck_from_commandline_arguments(commandline_arguments, default_value)
if targetenvironmenttype == TasksForCommonProjectStructure.get_productive_environment_name():
return self.get_buildconfigurationproductive_from_commandline_arguments(commandline_arguments, "Release")
raise ValueError(f"Unknown build-environmenttype: {targetenvironmenttype}")

@GeneralUtilities.check_arguments
def get_default_target_environmenttype_mapping(self) -> dict[str, str]:
return {
Expand All @@ -436,10 +413,9 @@ def get_default_target_environmenttype_mapping(self) -> dict[str, str]:

@GeneralUtilities.check_arguments
def __standardized_tasks_build_for_dotnet_project(self, buildscript_file: str, target_environmenttype_mapping: dict[str, str],
default_build_configuration: str, verbosity: int, target_environmenttype: str,
target_environment_type: str, verbosity: int, target_environmenttype: str,
runtimes: list[str], commandline_arguments: list[str]) -> None:
self.copy_source_files_to_output_directory(buildscript_file)
dotnet_build_configuration: str = target_environmenttype_mapping[target_environmenttype]
codeunitname: str = os.path.basename(str(Path(os.path.dirname(buildscript_file)).parent.parent.absolute()))
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, verbosity)
files_to_sign: dict[str, str] = TasksForCommonProjectStructure.get_filestosign_from_commandline_arguments(commandline_arguments, dict())
Expand All @@ -448,14 +424,13 @@ def __standardized_tasks_build_for_dotnet_project(self, buildscript_file: str, t
outputfolder = GeneralUtilities.resolve_relative_path("../Artifacts", os.path.dirname(buildscript_file))
codeunit_folder = os.path.join(repository_folder, codeunitname)
csproj_file = os.path.join(codeunit_folder, codeunitname, codeunitname+".csproj")
csproj_test_file = os.path.join(codeunit_folder, codeunitname+"Tests", codeunitname+"Tests.csproj")
buildconfiguration = self.__get_dotnet_buildconfiguration_by_target_environmenttype(dotnet_build_configuration, default_build_configuration, commandline_arguments)
# csproj_test_file = os.path.join(codeunit_folder, codeunitname+"Tests", codeunitname+"Tests.csproj")

self.__sc.run_program("dotnet", "restore", codeunit_folder, verbosity=verbosity)
self.__standardized_tasks_build_for_dotnet_build(csproj_file, buildconfiguration,
os.path.join(outputfolder, "BuildResult_DotNet_"), files_to_sign, commitid, verbosity, runtimes)
self.__standardized_tasks_build_for_dotnet_build(csproj_test_file, buildconfiguration,
os.path.join(outputfolder, "BuildResult_DotNetTests_"), files_to_sign, commitid, verbosity, runtimes)
self.__standardized_tasks_build_for_dotnet_build(csproj_file, os.path.join(outputfolder, "BuildResult_DotNet_"), files_to_sign, commitid,
verbosity, runtimes, target_environment_type, target_environmenttype_mapping, commandline_arguments)
# self.__standardized_tasks_build_for_dotnet_build(csproj_test_file, os.path.join(outputfolder, "BuildResult_DotNetTests_"), files_to_sign, commitid,
# verbosity, runtimes, target_environment_type, target_environmenttype_mapping, commandline_arguments)
self.generate_sbom_for_dotnet_project(codeunit_folder, verbosity, commandline_arguments)

@GeneralUtilities.check_arguments
Expand Down Expand Up @@ -559,16 +534,16 @@ def standardized_tasks_generate_coverage_report(self, repository_folder: str, co

@GeneralUtilities.check_arguments
def standardized_tasks_run_testcases_for_dotnet_project(self, runtestcases_file: str, targetenvironmenttype: str, verbosity: int, generate_badges: bool,
target_environmenttype_mapping: dict[str, str], target_environmenttype: str,
commandline_arguments: list[str]):
dotnet_build_configuration: str = target_environmenttype_mapping[target_environmenttype]
codeunit_name: str = os.path.basename(str(Path(os.path.dirname(runtestcases_file)).parent.parent.absolute()))
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, verbosity)
repository_folder: str = str(Path(os.path.dirname(runtestcases_file)).parent.parent.parent.absolute())
testprojectname = codeunit_name+"Tests"
coverage_file_folder = os.path.join(repository_folder, codeunit_name, "Other/Artifacts/TestCoverage")
coveragefiletarget = os.path.join(coverage_file_folder, "TestCoverage.xml")
buildconfiguration = self.__get_dotnet_buildconfiguration_by_target_environmenttype(targetenvironmenttype, codeunit_name, commandline_arguments)
with tempfile.TemporaryDirectory() as temp_directory:
self.__sc.run_program_argsasarray("dotnet", ["test", f"{testprojectname}/{testprojectname}.csproj", "-c", buildconfiguration,
self.__sc.run_program_argsasarray("dotnet", ["test", "-c", dotnet_build_configuration,
"--verbosity", "normal", "--collect", "XPlat Code Coverage", "--results-directory", temp_directory],
os.path.join(repository_folder, codeunit_name), verbosity=verbosity)
temp_directory_subdir = GeneralUtilities.get_direct_folders_of_folder(temp_directory)[0]
Expand Down
2 changes: 1 addition & 1 deletion ScriptCollection/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ScriptCollection
version = 3.3.52
version = 3.3.53
author = Marius Göcke
author_email = [email protected]
description = The ScriptCollection is the place for reusable scripts.
Expand Down

0 comments on commit 747baab

Please sign in to comment.