bring release_mixin partially back to work

This commit is contained in:
Michael Jerger 2023-05-02 08:55:09 +02:00
parent 8a864153d9
commit df1200de4a
2 changed files with 45 additions and 32 deletions

View file

@ -15,19 +15,21 @@ class ReleaseMixin(DevopsBuild):
raise ValueError(f"ReleaseMixin requires MixinType.RELEASE") raise ValueError(f"ReleaseMixin requires MixinType.RELEASE")
# TODO: move this to service # TODO: move this to service
release = devops.mixins[MixinType.RELEASE]
env_key = EnvironmentKeys.DDADEVOPS_RELEASE_TYPE.name env_key = EnvironmentKeys.DDADEVOPS_RELEASE_TYPE.name
environment_val_set = environment_api.get(env_key) != "" and environment_api.get(env_key) is not None environment_val_set = environment_api.get(env_key) != "" and environment_api.get(env_key) is not None
if environment_val_set: if environment_val_set:
release_type_repo = ReleaseTypeRepository.from_environment(environment_api) release_type_repo = ReleaseTypeRepository.from_environment(environment_api)
else: else:
release_type_repo = ReleaseTypeRepository.from_git(git_api) release_type_repo = ReleaseTypeRepository.from_git(git_api)
version_repo = VersionRepository(release.config_file) version_repo = VersionRepository(release.release_config_file)
self.release_repo = ReleaseContextRepository(version_repo, release_type_repo) self.release_repo = ReleaseContextRepository(version_repo, release_type_repo)
# Here the initialization can happen # Here the initialization can happen
self.prepare_release_service = PrepareReleaseService() self.prepare_release_service = PrepareReleaseService()
def prepare_release(self): def prepare_release(self):
release = self.release_repo.get_release(self.main_branch) devops = self.repo.get_devops(self.project)
release = devops.mixins[MixinType.RELEASE]
self.prepare_release_service.write_and_commit_release(release, self.release_repo.version_repository) self.prepare_release_service.write_and_commit_release(release, self.release_repo.version_repository)
self.prepare_release_service.write_and_commit_bump(release, self.release_repo.version_repository) self.prepare_release_service.write_and_commit_bump(release, self.release_repo.version_repository)

View file

@ -18,11 +18,30 @@ PROJECT_ROOT_PATH = "."
MODULE = "test" MODULE = "test"
BUILD_DIR_NAME = "build_dir" BUILD_DIR_NAME = "build_dir"
# def change_test_dir( tmp_path: Path, monkeypatch: pt.MonkeyPatch):
# monkeypatch.chdir(tmp_path)
# class MyBuild(ReleaseMixin): def change_test_dir(tmp_path: Path, monkeypatch: pt.MonkeyPatch):
# pass monkeypatch.chdir(tmp_path)
def initialize_with_object(project, CONFIG_FILE):
project.build_depends_on("ddadevops>=3.1.2")
build = ReleaseMixin(
project,
devops_config(
{
"name": "release_test",
"stage": "test",
"module": MODULE,
"project_root_path": PROJECT_ROOT_PATH,
"build_types": [],
"mixin_types": ["RELEASE"],
"build_dir_name": BUILD_DIR_NAME,
"release_main_branch": MAIN_BRANCH,
"release_config_file": CONFIG_FILE,
}
),
)
return build
def test_release_mixin(tmp_path): def test_release_mixin(tmp_path):
@ -39,39 +58,31 @@ def test_release_mixin(tmp_path):
} }
), ),
) )
sut.initialize_build_dir() assert sut is not None
assert os.path.exists(f"{devops_build.build_path()}")
# def initialize_with_object(project, CONFIG_FILE): def test_release_mixin_git(tmp_path: Path, monkeypatch: pt.MonkeyPatch):
# project.build_depends_on('ddadevops>=3.1.2') # init
# devops = Devops(STAGE, PROJECT_ROOT_PATH, MODULE, "release_test", BUILD_DIR_NAME) th = ResourceHelper()
# release = Release(devops, MAIN_BRANCH, CONFIG_FILE) th.copy_files(th.TEST_FILE_PATH, tmp_path)
# build = MyBuild(project, release) th.TEST_FILE_PATH = tmp_path / th.TEST_FILE_NAME
# return build
# def test_release_mixin_git(tmp_path: Path, monkeypatch: pt.MonkeyPatch): change_test_dir(tmp_path, monkeypatch)
project = Project(tmp_path)
# # init git_api = GitApi()
# th = Helper() git_api.init()
# th.copy_files(th.TEST_FILE_PATH, tmp_path) git_api.set_user_config("ex.ample@mail.com", "Ex Ample")
# th.TEST_FILE_PATH = tmp_path / th.TEST_FILE_NAME git_api.add_file(th.TEST_FILE_NAME)
git_api.commit("MAJOR release")
# change_test_dir(tmp_path, monkeypatch) build = initialize_with_object(project, th.TEST_FILE_PATH)
# project = Project(tmp_path) build.prepare_release()
release_version = build.release_repo.version_repository.get_version()
# git_api = GitApi() # test
# git_api.init() assert "124.0.1-SNAPSHOT" in release_version.get_version_string()
# git_api.set_user_config("ex.ample@mail.com", "Ex Ample")
# git_api.add_file(th.TEST_FILE_NAME)
# git_api.commit("MAJOR release")
# build = initialize_with_object(project, th.TEST_FILE_PATH)
# build.prepare_release()
# release_version = build.release_repo.version_repository.get_version()
# # test
# assert "124.0.1-SNAPSHOT" in release_version.get_version_string()
# def test_release_mixin_environment(tmp_path: Path, monkeypatch: pt.MonkeyPatch): # def test_release_mixin_environment(tmp_path: Path, monkeypatch: pt.MonkeyPatch):