introduce build_file ids

This commit is contained in:
Michael Jerger 2023-05-12 14:57:23 +02:00
parent 1e2fcce452
commit 17f41dbd7a
3 changed files with 24 additions and 3 deletions

View file

@ -20,7 +20,8 @@ class Release(Validateable):
self.release_type = ReleaseType[input.get("release_type", "NONE")]
self.release_main_branch = input.get("release_main_branch", "main")
self.release_current_branch = input.get("release_current_branch")
self.release_config_file = input.get("release_config_file", "./project.clj")
self.release_primary_build_file = input.get("release_primary_build_file", "./project.clj")
self.release_secondary_build_files = input.get("release_secondary_build_files", [])
self.version = version
def validate(self):
@ -28,8 +29,17 @@ class Release(Validateable):
result += self.__validate_is_not_empty__("release_type")
result += self.__validate_is_not_empty__("release_main_branch")
result += self.__validate_is_not_empty__("release_current_branch")
result += self.__validate_is_not_empty__("release_config_file")
result += self.__validate_is_not_empty__("release_primary_build_file")
result += self.__validate_is_not_empty__("version")
try:
Path(self.release_primary_build_file)
except Exception as e:
result.append(f"release_primary_build_file must be a valid path but was {e}")
for path in self.release_secondary_build_files:
try:
Path(path)
except Exception as e:
result.append(f"release_secondary_build_file must be contain valid paths but was {e}")
if self.version:
result += self.version.validate()
if (

View file

@ -21,7 +21,8 @@ def devops_config(overrides: dict) -> dict:
"release_type": "NONE",
"release_main_branch": "main",
"release_current_branch": "my_feature",
"release_config_file": "./project.clj",
"release_primary_build_file": "./project.clj",
"release_secondary_build_file": [],
}
input = default.copy()
input.update(overrides)

View file

@ -38,3 +38,13 @@ def test_sould_validate_release():
Version.from_str("1.3.1-SNAPSHOT"),
)
assert not sut.is_valid()
sut = Release(
devops_config(
{
"release_primary_build_file": 1,
}
),
Version.from_str("1.3.1-SNAPSHOT"),
)
assert not sut.is_valid()