From e9c6c95299961b46c3161350582f78a00430a931 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 13 Jul 2023 10:58:16 +0200 Subject: [PATCH 01/11] Update docker ci build --- .gitlab-ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 33aa37a..be7f4fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: "domaindrivenarchitecture/devops-build:4.0.8" +image: "domaindrivenarchitecture/devops-build:latest" before_script: - python --version @@ -9,9 +9,6 @@ before_script: - export IMAGE_DOCKERHUB_USER=$DOCKERHUB_USER - export IMAGE_DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD -variables: - DOCKER_HOST: tcp://localhost:2375/ - stages: - lint&test - upload From a6f6b9715e1329cb25b450b8d6fc4043bcb1cffe Mon Sep 17 00:00:00 2001 From: erik Date: Thu, 13 Jul 2023 11:07:59 +0200 Subject: [PATCH 02/11] Add execute_handled --- .../infrastructure/infrastructure.py | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/main/python/ddadevops/infrastructure/infrastructure.py b/src/main/python/ddadevops/infrastructure/infrastructure.py index aa3f137..2a9eda6 100644 --- a/src/main/python/ddadevops/infrastructure/infrastructure.py +++ b/src/main/python/ddadevops/infrastructure/infrastructure.py @@ -1,4 +1,4 @@ -from subprocess import Popen, PIPE, run +from subprocess import Popen, PIPE, run, CalledProcessError from pathlib import Path from sys import stdout from os import chmod, environ @@ -53,37 +53,37 @@ class ImageApi: self.execution_api = ExecutionApi() def image(self, name: str, path: Path): - self.execution_api.execute( + self.execution_api.execute_handled( f"docker build -t {name} --file {path}/image/Dockerfile {path}/image" ) def drun(self, name: str): - self.execution_api.execute( + self.execution_api.execute_handled( f'docker run -it --entrypoint="" {name} /bin/bash' ) def dockerhub_login(self, username: str, password: str): - self.execution_api.execute( + self.execution_api.execute_handled( f"docker login --username {username} --password {password}" ) def dockerhub_publish(self, name: str, username: str, tag=None): if tag is not None: - self.execution_api.execute( + self.execution_api.execute_handled( f"docker tag {name} {username}/{name}:{tag}" ) - self.execution_api.execute( + self.execution_api.execute_handled( f"docker push {username}/{name}:{tag}" ) - self.execution_api.execute( + self.execution_api.execute_handled( f"docker tag {name} {username}/{name}:latest" ) - self.execution_api.execute( + self.execution_api.execute_handled( f"docker push {username}/{name}:latest" ) def test(self, name: str, path: Path): - self.execution_api.execute( + self.execution_api.execute_handled( f"docker build -t {name} -test --file {path}/test/Dockerfile {path}/test" ) @@ -101,7 +101,7 @@ class ExecutionApi: output = output.rstrip() return output - def execute_live(self, command, dry_run=False, shell=True): + def execute_live(self, command: str, dry_run=False, shell=True): if dry_run: print(command) else: @@ -111,6 +111,21 @@ class ExecutionApi: process.stdout.close() process.wait() + def execute_handled(self, command: str, dry_run=False, shell=True, check=True): + if dry_run: + print(command) + else: + try: + run( + command, + shell=shell, + check=check, + stderr=PIPE, + text=True) + except CalledProcessError as exc: + print("Command failed with code: ", exc.returncode, " and message:", exc.stderr) + raise exc + class EnvironmentApi: def get(self, key): From 9341c147ae7b727740396b6be818af9f7276337c Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 13 Jul 2023 11:10:24 +0200 Subject: [PATCH 03/11] release: 4.0.15 --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index f1d0b48..7bbf24a 100644 --- a/build.py +++ b/build.py @@ -33,7 +33,7 @@ default_task = "dev" name = "ddadevops" MODULE = "not-used" PROJECT_ROOT_PATH = "." -version = "4.0.15-dev" +version = "4.0.15" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" description = __doc__ authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] From 0a44d6e36344b34b8dfa1ceb7a194b9b4cca7aa2 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 13 Jul 2023 11:10:24 +0200 Subject: [PATCH 04/11] bump version to: 4.0.16-dev --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 7bbf24a..b725a0e 100644 --- a/build.py +++ b/build.py @@ -33,7 +33,7 @@ default_task = "dev" name = "ddadevops" MODULE = "not-used" PROJECT_ROOT_PATH = "." -version = "4.0.15" +version = "4.0.16-dev" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" description = __doc__ authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] From 153d4bbf9a6768f1c85739fb0207d33fcb348c49 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 13 Jul 2023 12:02:02 +0200 Subject: [PATCH 05/11] Add docker service to CI Enables CI to actually build docker images --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be7f4fe..c4522ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,8 @@ image: "domaindrivenarchitecture/devops-build:latest" +services: + - docker:dind + before_script: - python --version - python -m pip install --upgrade pip From 55daeb69f143c04bd7c197c6575766f92226101d Mon Sep 17 00:00:00 2001 From: erik Date: Thu, 13 Jul 2023 12:13:00 +0200 Subject: [PATCH 06/11] release: 4.0.16 --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index b725a0e..36f0367 100644 --- a/build.py +++ b/build.py @@ -33,7 +33,7 @@ default_task = "dev" name = "ddadevops" MODULE = "not-used" PROJECT_ROOT_PATH = "." -version = "4.0.16-dev" +version = "4.0.16" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" description = __doc__ authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] From 6332b738e332379caf6965520aec276d78ff1aa9 Mon Sep 17 00:00:00 2001 From: erik Date: Thu, 13 Jul 2023 12:13:00 +0200 Subject: [PATCH 07/11] bump version to: 4.0.17-dev --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 36f0367..eb989a9 100644 --- a/build.py +++ b/build.py @@ -33,7 +33,7 @@ default_task = "dev" name = "ddadevops" MODULE = "not-used" PROJECT_ROOT_PATH = "." -version = "4.0.16" +version = "4.0.17-dev" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" description = __doc__ authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] From 901659283229ce878dafb38d4b2db12a133ea837 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 13 Jul 2023 13:09:16 +0200 Subject: [PATCH 08/11] Use correct CI variable for Image tag --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4522ba..fe83c8d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ before_script: - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install ddadevops --upgrade - - export IMAGE_TAG=$CI_IMAGE_TAG + - export IMAGE_TAG=$CI_COMMIT_TAG - export IMAGE_DOCKERHUB_USER=$DOCKERHUB_USER - export IMAGE_DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD From 039b9fe2f04fe26c4697a6508f2e3069ba267cb7 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 13 Jul 2023 13:12:02 +0200 Subject: [PATCH 09/11] Remove redundant pip install --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe83c8d..c065128 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,6 @@ before_script: - python --version - python -m pip install --upgrade pip - pip install -r requirements.txt - - pip install ddadevops --upgrade - export IMAGE_TAG=$CI_COMMIT_TAG - export IMAGE_DOCKERHUB_USER=$DOCKERHUB_USER - export IMAGE_DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD From ac06c71a1adf12337529254a1cff52aab39779e6 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 13 Jul 2023 13:12:24 +0200 Subject: [PATCH 10/11] Pin devops-build Image version --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c065128..fc18d57 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: "domaindrivenarchitecture/devops-build:latest" +image: "domaindrivenarchitecture/devops-build:4.0.8" services: - docker:dind From b7acaab2a9e94c4394d122aa917cedad7371a754 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 13 Jul 2023 13:20:57 +0200 Subject: [PATCH 11/11] Merge release tasks into one --- README.md | 2 +- build.py | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index accbf00..c3de758 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ def destroy(project): pyb dev publish upload pip3 install --upgrade ddadevops --pre -pyb [patch|minor|major] prepare_release tag_bump_and_push_release +pyb [patch|minor|major] release pip3 install --upgrade ddadevops ``` diff --git a/build.py b/build.py index eb989a9..a6bd26b 100644 --- a/build.py +++ b/build.py @@ -130,16 +130,11 @@ def nothing(project): pass @task -def prepare_release(project): +def release(project): build = get_devops_build(project) build.prepare_release() - -@task -def tag_bump_and_push_release(project): - build = get_devops_build(project) build.tag_bump_and_push_release() - def build(project, release_type): build = get_devops_build(project) build.update_release_type(release_type)