Compare commits

...

3 commits

7 changed files with 39 additions and 4 deletions

View file

@ -176,6 +176,7 @@ def prepare(project):
def tag(project):
build = get_devops_build(project)
build.tag_bump_and_push_release()
#TODO: build.publish_artifacts()
def release(project):

View file

@ -1,18 +1,25 @@
from typing import List
from pathlib import Path
from ..infrastructure import GitApi, BuildFileRepository
from ..infrastructure import GitApi, ArtifactDeploymentApi, BuildFileRepository
from ..domain import Version, Release, ReleaseType
class ReleaseService:
def __init__(self, git_api: GitApi, build_file_repository: BuildFileRepository):
def __init__(
self,
git_api: GitApi,
build_file_repository: BuildFileRepository,
artifact_deployment_api: ArtifactDeploymentApi,
):
self.git_api = git_api
self.artifact_deployment_api = artifact_deployment_api
self.build_file_repository = build_file_repository
@classmethod
def prod(cls, base_dir: str):
return cls(
GitApi(),
ArtifactDeploymentApi(),
BuildFileRepository(base_dir),
)
@ -53,6 +60,12 @@ class ReleaseService:
)
self.git_api.push_follow_tags()
def publish_artifacts(self, release: Release):
self.artifact_deployment_api.calculate_checksums(artifact_path=)
# create release
# add artifacts to release
pass
def __set_version_and_commit__(
self, version: Version, build_file_ids: List[str], message: str
):

View file

@ -7,5 +7,6 @@ from .infrastructure import (
CredentialsApi,
GitApi,
TerraformApi,
ArtifactDeploymentApi,
)
from .repository import DevopsRepository, BuildFileRepository

View file

@ -231,6 +231,6 @@ class ArtifactDeploymentApi:
+ '-H "Content-Type: multipart/form-data" '
+ f'-F "attachment=@{attachment};type={attachment_type}"')
def calculate_checksums(self, build_path: str):
def calculate_checksums(self, artifact_path: str):
self.execution_api.execute(f"find {build_path} -type f -exec sha256sum {{}}; | sort > {build_path} sha256sum.lst")
self.execution_api.execute(f"find {build_path} -type f -exec sha512sum {{}}; | sort > {build_path} sha512sum.lst")

View file

@ -26,3 +26,8 @@ class ReleaseMixin(DevopsBuild):
devops = self.devops_repo.get_devops(self.project)
release = devops.mixins[MixinType.RELEASE]
self.release_service.tag_bump_and_push_release(release)
def publish_artifacts(self):
devops = self.devops_repo.get_devops(self.project)
release = devops.mixins[MixinType.RELEASE]
self.release_service.publish_artifacts(release)

View file

@ -7,12 +7,13 @@ from src.main.python.ddadevops.domain import (
from src.test.python.domain.helper import (
BuildFileRepositoryMock,
GitApiMock,
ArtifactDeploymentApiMock,
build_devops,
)
from src.main.python.ddadevops.application import ReleaseService
def test_sould_update_release_type():
sut = ReleaseService(GitApiMock(), BuildFileRepositoryMock("build.py"))
sut = ReleaseService(GitApiMock(), ArtifactDeploymentApiMock(), BuildFileRepositoryMock("build.py"))
devops = build_devops({})
release = devops.mixins[MixinType.RELEASE]
sut.update_release_type(release, "MAJOR")

View file

@ -150,3 +150,17 @@ class GitApiMock:
def checkout(self, branch: str):
pass
class ArtifactDeploymentApiMock:
def __init__(self):
pass
def post_release(self, target_url: str, tag: str, token: str):
pass
def post_asset(self, target_url: str, release_id: str, attachment: str, attachment_type: str, token: str):
pass
def calculate_checksums(self, build_path: str):
pass