use the new image_naming
This commit is contained in:
parent
6b1ffb6e99
commit
9c44bebd5d
9 changed files with 104 additions and 52 deletions
115
build.py
115
build.py
|
@ -22,63 +22,71 @@ from ddadevops import *
|
||||||
use_plugin("python.core")
|
use_plugin("python.core")
|
||||||
use_plugin("copy_resources")
|
use_plugin("copy_resources")
|
||||||
use_plugin("filter_resources")
|
use_plugin("filter_resources")
|
||||||
#use_plugin("python.unittest")
|
# use_plugin("python.unittest")
|
||||||
#use_plugin("python.coverage")
|
# use_plugin("python.coverage")
|
||||||
use_plugin("python.distutils")
|
use_plugin("python.distutils")
|
||||||
|
|
||||||
#use_plugin("python.install_dependencies")
|
# use_plugin("python.install_dependencies")
|
||||||
|
|
||||||
default_task = "dev"
|
default_task = "dev"
|
||||||
|
|
||||||
name = "ddadevops"
|
name = "ddadevops"
|
||||||
MODULE = "not-used"
|
MODULE = "not-used"
|
||||||
PROJECT_ROOT_PATH = "."
|
PROJECT_ROOT_PATH = "."
|
||||||
version = "4.0.15-dev"
|
version = "4.0.17-dev3"
|
||||||
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
|
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
|
||||||
description = __doc__
|
description = __doc__
|
||||||
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]
|
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]
|
||||||
url = "https://repo.prod.meissa.de/meissa/dda-devops-build"
|
url = "https://repo.prod.meissa.de/meissa/dda-devops-build"
|
||||||
requires_python = ">=3.10" # CHECK IF NEW VERSION EXISTS
|
requires_python = ">=3.10" # CHECK IF NEW VERSION EXISTS
|
||||||
license = "Apache Software License"
|
license = "Apache Software License"
|
||||||
|
|
||||||
|
|
||||||
@init
|
@init
|
||||||
def initialize(project):
|
def initialize(project):
|
||||||
#project.build_depends_on('mockito')
|
# project.build_depends_on('mockito')
|
||||||
#project.build_depends_on('unittest-xml-reporting')
|
# project.build_depends_on('unittest-xml-reporting')
|
||||||
project.build_depends_on("ddadevops>=4.0.0")
|
project.build_depends_on("ddadevops>=4.0.0")
|
||||||
|
|
||||||
project.set_property("verbose", True)
|
project.set_property("verbose", True)
|
||||||
project.get_property("filter_resources_glob").append("main/python/ddadevops/__init__.py")
|
project.get_property("filter_resources_glob").append(
|
||||||
|
"main/python/ddadevops/__init__.py"
|
||||||
|
)
|
||||||
project.set_property("dir_source_unittest_python", "src/test/python")
|
project.set_property("dir_source_unittest_python", "src/test/python")
|
||||||
|
|
||||||
project.set_property("copy_resources_target", "$dir_dist/ddadevops")
|
project.set_property("copy_resources_target", "$dir_dist/ddadevops")
|
||||||
project.get_property("copy_resources_glob").append("LICENSE")
|
project.get_property("copy_resources_glob").append("LICENSE")
|
||||||
project.get_property("copy_resources_glob").append("src/main/resources/terraform/*")
|
project.get_property("copy_resources_glob").append("src/main/resources/terraform/*")
|
||||||
project.get_property("copy_resources_glob").append("src/main/resources/docker/image/resources/*")
|
project.get_property("copy_resources_glob").append(
|
||||||
|
"src/main/resources/docker/image/resources/*"
|
||||||
|
)
|
||||||
project.include_file("ddadevops", "LICENSE")
|
project.include_file("ddadevops", "LICENSE")
|
||||||
project.include_file("ddadevops", "src/main/resources/terraform/*")
|
project.include_file("ddadevops", "src/main/resources/terraform/*")
|
||||||
project.include_file("ddadevops", "src/main/resources/docker/image/resources/*")
|
project.include_file("ddadevops", "src/main/resources/docker/image/resources/*")
|
||||||
|
|
||||||
#project.set_property('distutils_upload_sign', True)
|
# project.set_property('distutils_upload_sign', True)
|
||||||
#project.set_property('distutils_upload_sign_identity', '')
|
# project.set_property('distutils_upload_sign_identity', '')
|
||||||
project.set_property("distutils_readme_description", True)
|
project.set_property("distutils_readme_description", True)
|
||||||
project.set_property("distutils_description_overwrite", True)
|
project.set_property("distutils_description_overwrite", True)
|
||||||
project.set_property("distutils_classifiers", [
|
project.set_property(
|
||||||
'License :: OSI Approved :: Apache Software License',
|
"distutils_classifiers",
|
||||||
'Programming Language :: Python',
|
[
|
||||||
'Programming Language :: Python :: 3',
|
"License :: OSI Approved :: Apache Software License",
|
||||||
'Programming Language :: Python :: 3.8',
|
"Programming Language :: Python",
|
||||||
'Programming Language :: Python :: 3.10',
|
"Programming Language :: Python :: 3",
|
||||||
'Operating System :: POSIX :: Linux',
|
"Programming Language :: Python :: 3.8",
|
||||||
'Operating System :: OS Independent',
|
"Programming Language :: Python :: 3.10",
|
||||||
'Development Status :: 5 - Production/Stable',
|
"Operating System :: POSIX :: Linux",
|
||||||
'Environment :: Console',
|
"Operating System :: OS Independent",
|
||||||
'Intended Audience :: Developers',
|
"Development Status :: 5 - Production/Stable",
|
||||||
'License :: OSI Approved :: Apache Software License',
|
"Environment :: Console",
|
||||||
'Topic :: Software Development :: Build Tools',
|
"Intended Audience :: Developers",
|
||||||
'Topic :: Software Development :: Quality Assurance',
|
"License :: OSI Approved :: Apache Software License",
|
||||||
'Topic :: Software Development :: Testing'
|
"Topic :: Software Development :: Build Tools",
|
||||||
])
|
"Topic :: Software Development :: Quality Assurance",
|
||||||
|
"Topic :: Software Development :: Testing",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -88,52 +96,83 @@ def initialize(project):
|
||||||
"build_types": [],
|
"build_types": [],
|
||||||
"mixin_types": ["RELEASE"],
|
"mixin_types": ["RELEASE"],
|
||||||
"release_primary_build_file": "build.py",
|
"release_primary_build_file": "build.py",
|
||||||
|
"release_secondary_build_files": [
|
||||||
|
"infrastructure/python/build.py",
|
||||||
|
"infrastructure/dind/build.py",
|
||||||
|
"infrastructure/ddadevops/build.py",
|
||||||
|
"infrastructure/clojure/build.py",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
build = ReleaseMixin(project, input)
|
build = ReleaseMixin(project, input)
|
||||||
build.initialize_build_dir()
|
build.initialize_build_dir()
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def test(project):
|
def test(project):
|
||||||
run("pytest", check=True)
|
run("pytest", check=True)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def lint(project):
|
def lint(project):
|
||||||
run("flake8 --max-line-length=120 --count --select=E9,F63,F7,F82 "+
|
run(
|
||||||
"--show-source --statistics src/main/python/ddadevops/", shell=True, check=True)
|
"flake8 --max-line-length=120 --count --select=E9,F63,F7,F82 "
|
||||||
run("flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 "+
|
+ "--show-source --statistics src/main/python/ddadevops/",
|
||||||
"--per-file-ignores=\"__init__.py:F401\" "+
|
shell=True,
|
||||||
"--ignore=E722,W503 --statistics src/main/python/ddadevops/", shell=True, check=True)
|
check=True,
|
||||||
run("python -m mypy src/main/python/ddadevops/ --ignore-missing-imports "+
|
)
|
||||||
"--disable-error-code=attr-defined --disable-error-code=union-attr", shell=True, check=True)
|
run(
|
||||||
run("pylint -d W0511,R0903,C0301,W0614,C0114,C0115,C0116,similarities,W1203,W0702,W0702,"+
|
"flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 "
|
||||||
"R0913,R0902,R0914,R1732,R1705,W0707,C0123,W0703,C0103 src/main/python/ddadevops/", shell=True, check=True)
|
+ '--per-file-ignores="__init__.py:F401" '
|
||||||
|
+ "--ignore=E722,W503 --statistics src/main/python/ddadevops/",
|
||||||
|
shell=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
run(
|
||||||
|
"python -m mypy src/main/python/ddadevops/ --ignore-missing-imports "
|
||||||
|
+ "--disable-error-code=attr-defined --disable-error-code=union-attr",
|
||||||
|
shell=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
run(
|
||||||
|
"pylint -d W0511,R0903,C0301,W0614,C0114,C0115,C0116,similarities,W1203,W0702,W0702,"
|
||||||
|
+ "R0913,R0902,R0914,R1732,R1705,W0707,C0123,W0703,C0103 src/main/python/ddadevops/",
|
||||||
|
shell=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def patch(project):
|
def patch(project):
|
||||||
build(project, "PATCH")
|
build(project, "PATCH")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def minor(project):
|
def minor(project):
|
||||||
build(project, "MINOR")
|
build(project, "MINOR")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def major(project):
|
def major(project):
|
||||||
build(project, "MAJOR")
|
build(project, "MAJOR")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def dev(project):
|
def dev(project):
|
||||||
build(project, "NONE")
|
build(project, "NONE")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def nothing(project):
|
def nothing(project):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def prepare_release(project):
|
def prepare_release(project):
|
||||||
build = get_devops_build(project)
|
build = get_devops_build(project)
|
||||||
build.prepare_release()
|
build.prepare_release()
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def tag_bump_and_push_release(project):
|
def tag_bump_and_push_release(project):
|
||||||
build = get_devops_build(project)
|
build = get_devops_build(project)
|
||||||
|
|
|
@ -5,7 +5,7 @@ from ddadevops import *
|
||||||
name = "ddadevops"
|
name = "ddadevops"
|
||||||
MODULE = "clojure"
|
MODULE = "clojure"
|
||||||
PROJECT_ROOT_PATH = "../.."
|
PROJECT_ROOT_PATH = "../.."
|
||||||
|
version = "4.0.0-dev73"
|
||||||
|
|
||||||
@init
|
@init
|
||||||
def initialize(project):
|
def initialize(project):
|
||||||
|
|
|
@ -5,6 +5,7 @@ from ddadevops import *
|
||||||
name = "ddadevops"
|
name = "ddadevops"
|
||||||
MODULE = ""
|
MODULE = ""
|
||||||
PROJECT_ROOT_PATH = "../.."
|
PROJECT_ROOT_PATH = "../.."
|
||||||
|
version = "4.0.0-dev73"
|
||||||
|
|
||||||
|
|
||||||
@init
|
@init
|
||||||
|
|
|
@ -5,6 +5,7 @@ from ddadevops import *
|
||||||
name = "devops-build"
|
name = "devops-build"
|
||||||
MODULE = "image"
|
MODULE = "image"
|
||||||
PROJECT_ROOT_PATH = "../.."
|
PROJECT_ROOT_PATH = "../.."
|
||||||
|
version = "4.0.0-dev73"
|
||||||
|
|
||||||
|
|
||||||
@init
|
@init
|
||||||
|
|
|
@ -5,6 +5,7 @@ from ddadevops import *
|
||||||
name = "ddadevops"
|
name = "ddadevops"
|
||||||
MODULE = "dind"
|
MODULE = "dind"
|
||||||
PROJECT_ROOT_PATH = "../.."
|
PROJECT_ROOT_PATH = "../.."
|
||||||
|
version = "4.0.0-dev73"
|
||||||
|
|
||||||
|
|
||||||
@init
|
@init
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
from os import environ
|
from os import environ
|
||||||
|
from datetime import datetime
|
||||||
from pybuilder.core import task, init
|
from pybuilder.core import task, init
|
||||||
from ddadevops import *
|
from ddadevops import *
|
||||||
|
|
||||||
name = "ddadevops"
|
name = "ddadevops"
|
||||||
MODULE = "python"
|
MODULE = "python"
|
||||||
PROJECT_ROOT_PATH = "../.."
|
PROJECT_ROOT_PATH = "../.."
|
||||||
|
version = "4.0.15-dev"
|
||||||
|
|
||||||
@init
|
@init
|
||||||
def initialize(project):
|
def initialize(project):
|
||||||
|
|
||||||
|
image_version = version
|
||||||
|
if "dev" in image_version:
|
||||||
|
image_version += datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
|
||||||
|
|
||||||
input = {
|
input = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"module": MODULE,
|
"module": MODULE,
|
||||||
|
@ -17,6 +22,8 @@ def initialize(project):
|
||||||
"project_root_path": PROJECT_ROOT_PATH,
|
"project_root_path": PROJECT_ROOT_PATH,
|
||||||
"build_types": ["IMAGE"],
|
"build_types": ["IMAGE"],
|
||||||
"mixin_types": [],
|
"mixin_types": [],
|
||||||
|
'image_naming': "NAME_AND_MODULE",
|
||||||
|
"image_version": f"{image_version}",
|
||||||
}
|
}
|
||||||
|
|
||||||
project.build_depends_on("ddadevops>=4.0.0")
|
project.build_depends_on("ddadevops>=4.0.0")
|
||||||
|
|
0
infrastructure/python/test/dummy
Normal file
0
infrastructure/python/test/dummy
Normal file
|
@ -46,10 +46,12 @@ class ImageBuildService:
|
||||||
self.file_api.cp_recursive("test", build_path)
|
self.file_api.cp_recursive("test", build_path)
|
||||||
|
|
||||||
def image(self, devops: Devops):
|
def image(self, devops: Devops):
|
||||||
self.image_api.image(devops.name, devops.build_path())
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
|
self.image_api.image(image.image_name(), devops.build_path())
|
||||||
|
|
||||||
def drun(self, devops: Devops):
|
def drun(self, devops: Devops):
|
||||||
self.image_api.drun(devops.name)
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
|
self.image_api.drun(image.image_name())
|
||||||
|
|
||||||
def dockerhub_login(self, devops: Devops):
|
def dockerhub_login(self, devops: Devops):
|
||||||
image = devops.specialized_builds[BuildType.IMAGE]
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
|
@ -60,8 +62,9 @@ class ImageBuildService:
|
||||||
def dockerhub_publish(self, devops: Devops):
|
def dockerhub_publish(self, devops: Devops):
|
||||||
image = devops.specialized_builds[BuildType.IMAGE]
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
self.image_api.dockerhub_publish(
|
self.image_api.dockerhub_publish(
|
||||||
devops.name, image.image_dockerhub_user, image.image_tag
|
image.image_name(), image.image_dockerhub_user, image.image_tag
|
||||||
)
|
)
|
||||||
|
|
||||||
def test(self, devops: Devops):
|
def test(self, devops: Devops):
|
||||||
self.image_api.test(devops.name, devops.build_path())
|
image = devops.specialized_builds[BuildType.IMAGE]
|
||||||
|
self.image_api.test(image.image_name(), devops.build_path())
|
||||||
|
|
|
@ -53,37 +53,37 @@ class ImageApi:
|
||||||
self.execution_api = ExecutionApi()
|
self.execution_api = ExecutionApi()
|
||||||
|
|
||||||
def image(self, name: str, path: Path):
|
def image(self, name: str, path: Path):
|
||||||
self.execution_api.execute(
|
self.execution_api.execute_live(
|
||||||
f"docker build -t {name} --file {path}/image/Dockerfile {path}/image"
|
f"docker build -t {name} --file {path}/image/Dockerfile {path}/image"
|
||||||
)
|
)
|
||||||
|
|
||||||
def drun(self, name: str):
|
def drun(self, name: str):
|
||||||
self.execution_api.execute(
|
self.execution_api.execute_live(
|
||||||
f'docker run -it --entrypoint="" {name} /bin/bash'
|
f'docker run -it --entrypoint="" {name} /bin/bash'
|
||||||
)
|
)
|
||||||
|
|
||||||
def dockerhub_login(self, username: str, password: str):
|
def dockerhub_login(self, username: str, password: str):
|
||||||
self.execution_api.execute(
|
self.execution_api.execute_live(
|
||||||
f"docker login --username {username} --password {password}"
|
f"docker login --username {username} --password {password}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def dockerhub_publish(self, name: str, username: str, tag=None):
|
def dockerhub_publish(self, name: str, username: str, tag=None):
|
||||||
if tag is not None:
|
if tag is not None:
|
||||||
self.execution_api.execute(
|
self.execution_api.execute_live(
|
||||||
f"docker tag {name} {username}/{name}:{tag}"
|
f"docker tag {name} {username}/{name}:{tag}"
|
||||||
)
|
)
|
||||||
self.execution_api.execute(
|
self.execution_api.execute_live(
|
||||||
f"docker push {username}/{name}:{tag}"
|
f"docker push {username}/{name}:{tag}"
|
||||||
)
|
)
|
||||||
self.execution_api.execute(
|
self.execution_api.execute_live(
|
||||||
f"docker tag {name} {username}/{name}:latest"
|
f"docker tag {name} {username}/{name}:latest"
|
||||||
)
|
)
|
||||||
self.execution_api.execute(
|
self.execution_api.execute_live(
|
||||||
f"docker push {username}/{name}:latest"
|
f"docker push {username}/{name}:latest"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test(self, name: str, path: Path):
|
def test(self, name: str, path: Path):
|
||||||
self.execution_api.execute(
|
self.execution_api.execute_live(
|
||||||
f"docker build -t {name} -test --file {path}/test/Dockerfile {path}/test"
|
f"docker build -t {name} -test --file {path}/test/Dockerfile {path}/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue