diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e5cbeae..2bed781 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -80,3 +80,10 @@ ddadevops-image-publish: stage: image script: - cd infrastructure/ddadevops && pyb image publish + +kotlin-image-publish: + <<: *img + <<: *tag_only + stage: image + script: + - cd infrastructure/kotlin && pyb image publish diff --git a/build.py b/build.py index 874d668..672dcbd 100644 --- a/build.py +++ b/build.py @@ -33,7 +33,7 @@ default_task = "dev" name = "ddadevops" MODULE = "not-used" PROJECT_ROOT_PATH = "." -version = "4.9.2-dev" +version = "4.9.4-dev" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" description = __doc__ authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] diff --git a/infrastructure/clj-cljs/build.py b/infrastructure/clj-cljs/build.py index 6a4609a..43499e4 100644 --- a/infrastructure/clj-cljs/build.py +++ b/infrastructure/clj-cljs/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = "ddadevops" MODULE = "clj-cljs" PROJECT_ROOT_PATH = "../.." -version = "4.9.2-dev" +version = "4.9.4-dev" @init def initialize(project): diff --git a/infrastructure/clj/build.py b/infrastructure/clj/build.py index 9dff5e1..7824356 100644 --- a/infrastructure/clj/build.py +++ b/infrastructure/clj/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = "ddadevops" MODULE = "clj" PROJECT_ROOT_PATH = "../.." -version = "4.9.2-dev" +version = "4.9.4-dev" @init def initialize(project): diff --git a/infrastructure/ddadevops/build.py b/infrastructure/ddadevops/build.py index 62b22f4..92a2937 100644 --- a/infrastructure/ddadevops/build.py +++ b/infrastructure/ddadevops/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = "ddadevops" MODULE = "ddadevops" PROJECT_ROOT_PATH = "../.." -version = "4.9.2-dev" +version = "4.9.4-dev" @init diff --git a/infrastructure/dind/build.py b/infrastructure/dind/build.py index a481601..c7c3292 100644 --- a/infrastructure/dind/build.py +++ b/infrastructure/dind/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = "ddadevops" MODULE = "dind" PROJECT_ROOT_PATH = "../.." -version = "4.9.2-dev" +version = "4.9.4-dev" @init diff --git a/infrastructure/kotlin/build.py b/infrastructure/kotlin/build.py index 25df4e9..5af0c91 100644 --- a/infrastructure/kotlin/build.py +++ b/infrastructure/kotlin/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = "ddadevops" MODULE = "kotlin" PROJECT_ROOT_PATH = "../.." -version = "4.9.2-dev" +version = "4.9.4-dev" @init diff --git a/infrastructure/python/build.py b/infrastructure/python/build.py index 0327217..23d7303 100644 --- a/infrastructure/python/build.py +++ b/infrastructure/python/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = "ddadevops" MODULE = "python" PROJECT_ROOT_PATH = "../.." -version = "4.9.2-dev" +version = "4.9.4-dev" @init diff --git a/src/main/python/ddadevops/domain/build_file.py b/src/main/python/ddadevops/domain/build_file.py index c159ca6..3b41577 100644 --- a/src/main/python/ddadevops/domain/build_file.py +++ b/src/main/python/ddadevops/domain/build_file.py @@ -48,11 +48,11 @@ class BuildFile(Validateable): def __get_file_type_regex_str(self, file_type: BuildFileType): match file_type: case BuildFileType.JAVA_GRADLE: - return "[0-9]*\\.[0-9]*\\.[0-9]*(-SNAPSHOT)?" + return r'(?P\bversion\s?=\s?)\"(?P\d*\.\d*\.\d*(-SNAPSHOT)?)\"' case BuildFileType.PYTHON: - return "[0-9]*\\.[0-9]*\\.[0-9]*(-SNAPSHOT)?(-dev)?[0-9]*" + return r'(?P\bversion\s?=\s?)\"(?P\d*\.\d*\.\d*(-SNAPSHOT|-dev\d*)?)\"' case BuildFileType.JAVA_CLOJURE: - return r'(?P\(defproject\s(\S)*\s)\"(?P\d*\.\d*\.\d*(-SNAPSHOT)?)\"' + return r'(?P\(defproject\s(\S)*\s)\"(?P\d*\.\d*\.\d*(-SNAPSHOT)?)\"' case _: return "" @@ -62,24 +62,7 @@ class BuildFile(Validateable): match build_file_type: case BuildFileType.JS: version_str = json.loads(self.content)["version"] - case BuildFileType.JAVA_GRADLE: - # TODO: '\nversion = ' will not parse all ?! - version_line = re.search("\nversion = .*", self.content) - version_line_group = version_line.group() - version_string = re.search( - self.__get_file_type_regex_str(build_file_type), version_line_group - ) - version_str = version_string.group() - case BuildFileType.PYTHON: - # TODO: '\nversion = ' will not parse all ?! - version_line = re.search("\nversion = .*\n", self.content) - version_line_group = version_line.group() - version_string = re.search( - self.__get_file_type_regex_str(build_file_type), - version_line_group, - ) - version_str = version_string.group() - case BuildFileType.JAVA_CLOJURE: + case BuildFileType.JAVA_GRADLE | BuildFileType.PYTHON | BuildFileType.JAVA_CLOJURE: version_str = re.search(self.__get_file_type_regex_str(build_file_type), self.content).group("version") except: raise RuntimeError(f"Version not found in file {self.file_path}") @@ -101,24 +84,10 @@ class BuildFile(Validateable): json_data = json.loads(self.content) json_data["version"] = new_version.to_string() self.content = json.dumps(json_data, indent=4) - case BuildFileType.JAVA_GRADLE: - substitute = re.sub( - f'\nversion = "{self.__get_file_type_regex_str(build_file_type)}"', - f'\nversion = "{new_version.to_string()}"', - self.content, - ) - self.content = substitute - case BuildFileType.PYTHON: - substitute = re.sub( - f'\nversion = "{self.__get_file_type_regex_str(build_file_type)}"', - f'\nversion = "{new_version.to_string()}"', - self.content, - ) - self.content = substitute - case BuildFileType.JAVA_CLOJURE: + case BuildFileType.JAVA_GRADLE | BuildFileType.PYTHON | BuildFileType.JAVA_CLOJURE: substitute = re.sub( self.__get_file_type_regex_str(build_file_type), - fr'\g"{new_version.to_string()}"', + fr'\g"{new_version.to_string()}"', self.content, 1, ) diff --git a/src/test/python/domain/test_build_file.py b/src/test/python/domain/test_build_file.py index 7e199ba..1bee1e0 100644 --- a/src/test/python/domain/test_build_file.py +++ b/src/test/python/domain/test_build_file.py @@ -182,3 +182,43 @@ def test_should_parse_and_set_version_for_clj(): '\n(defproject org.domaindrivenarchitecture/c4k-jira "2.0.0"\n:dependencies [[org.clojure/clojure "1.11.0"]]\n)\n ' == sut.content ) + +def test_should_throw_for_clj_wrong_version(): + sut = BuildFile( + Path("./project.clj"), + """ +(defproject org.domaindrivenarchitecture/c4k-jira "1.1.5-Snapshot" + :description "jira c4k-installation package" + :url "https://domaindrivenarchitecture.org" +) +""", + ) + + with pytest.raises(RuntimeError): + sut.get_version() + +def test_should_ignore_first_version_for_py(): + sut = BuildFile( + Path("./build.py"), + """ +from pybuilder.core import init, use_plugin, Author +use_plugin("python.core") + +name = "ddadevops" +project_version = "0.0.2-dev1" +version = "1.1.5-dev12" +summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" +""", + ) + assert sut.get_version() == Version.from_str("1.1.5-dev12", "dev") + +def test_should_ignore_first_version_for_gradle(): + sut = BuildFile( + Path("./build.gradle"), + """ +kotlin_version = "3.3.3" +version = "1.1.5-SNAPSHOT" + +""", + ) + assert sut.get_version() == Version.from_str("1.1.5-SNAPSHOT", "SNAPSHOT") \ No newline at end of file