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): def tag(project):
build = get_devops_build(project) build = get_devops_build(project)
build.tag_bump_and_push_release() build.tag_bump_and_push_release()
#TODO: build.publish_artifacts()
def release(project): def release(project):

View file

@ -1,18 +1,25 @@
from typing import List from typing import List
from pathlib import Path from pathlib import Path
from ..infrastructure import GitApi, BuildFileRepository from ..infrastructure import GitApi, ArtifactDeploymentApi, BuildFileRepository
from ..domain import Version, Release, ReleaseType from ..domain import Version, Release, ReleaseType
class ReleaseService: 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.git_api = git_api
self.artifact_deployment_api = artifact_deployment_api
self.build_file_repository = build_file_repository self.build_file_repository = build_file_repository
@classmethod @classmethod
def prod(cls, base_dir: str): def prod(cls, base_dir: str):
return cls( return cls(
GitApi(), GitApi(),
ArtifactDeploymentApi(),
BuildFileRepository(base_dir), BuildFileRepository(base_dir),
) )
@ -53,6 +60,12 @@ class ReleaseService:
) )
self.git_api.push_follow_tags() 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__( def __set_version_and_commit__(
self, version: Version, build_file_ids: List[str], message: str self, version: Version, build_file_ids: List[str], message: str
): ):

View file

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

View file

@ -231,6 +231,6 @@ class ArtifactDeploymentApi:
+ '-H "Content-Type: multipart/form-data" ' + '-H "Content-Type: multipart/form-data" '
+ f'-F "attachment=@{attachment};type={attachment_type}"') + 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 sha256sum {{}}; | sort > {build_path} sha256sum.lst")
self.execution_api.execute(f"find {build_path} -type f -exec sha512sum {{}}; | sort > {build_path} sha512sum.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) devops = self.devops_repo.get_devops(self.project)
release = devops.mixins[MixinType.RELEASE] release = devops.mixins[MixinType.RELEASE]
self.release_service.tag_bump_and_push_release(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 ( from src.test.python.domain.helper import (
BuildFileRepositoryMock, BuildFileRepositoryMock,
GitApiMock, GitApiMock,
ArtifactDeploymentApiMock,
build_devops, build_devops,
) )
from src.main.python.ddadevops.application import ReleaseService from src.main.python.ddadevops.application import ReleaseService
def test_sould_update_release_type(): def test_sould_update_release_type():
sut = ReleaseService(GitApiMock(), BuildFileRepositoryMock("build.py")) sut = ReleaseService(GitApiMock(), ArtifactDeploymentApiMock(), BuildFileRepositoryMock("build.py"))
devops = build_devops({}) devops = build_devops({})
release = devops.mixins[MixinType.RELEASE] release = devops.mixins[MixinType.RELEASE]
sut.update_release_type(release, "MAJOR") sut.update_release_type(release, "MAJOR")

View file

@ -150,3 +150,17 @@ class GitApiMock:
def checkout(self, branch: str): def checkout(self, branch: str):
pass 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