fixing configuration issues

This commit is contained in:
Muzahid 2022-02-03 21:54:11 +05:30
parent 6039d3a39b
commit b0feb4ea90
Signed by untrusted user: cis-muzahid
GPG Key ID: 1DC85E7D3AB613EA

View File

@ -10,8 +10,8 @@ Requires docker
# TODO: write hook job, maybe also a dockerfile? # TODO: write hook job, maybe also a dockerfile?
# TODO: what to do about non-docker jobs # TODO: what to do about non-docker jobs
from os import walk from os import listdir, walk
from os.path import exists, isfile, join, listdir from os.path import exists, isfile, join
import requests import requests
import re import re
from buildbot.plugins import steps, util from buildbot.plugins import steps, util
@ -66,6 +66,7 @@ ENTRYPOINT /usr/local/bin/buildbot_entrypoint.sh "$BUILDMASTER" "$WORKERNAME" "$
""" """
path =".buildbot"
def list_jobs(directory=".buildbot"): def list_jobs(directory=".buildbot"):
""" """
@ -92,11 +93,11 @@ def find_artifacts(directory="out"):
return join(directory, _) return join(directory, _)
def get_dockerfile_contents(path, os_codename): def get_dockerfile_contents(props):
""" """
Read contents of a Dockerfile and add extra contents for the given os_codename Read contents of a Dockerfile and add extra contents for the given os_codename
""" """
with open(path, "r") as file: with open(join(path + props.getProperty('jobname', default=None)), "r") as file:
contents = file.read() contents = file.read()
# remove any line containing CMD or ENTRYFILE keywords # remove any line containing CMD or ENTRYFILE keywords
re.sub(r"(?m)^(CMD|ENTRYFILE).*$", "", contents) re.sub(r"(?m)^(CMD|ENTRYFILE).*$", "", contents)
@ -104,7 +105,7 @@ def get_dockerfile_contents(path, os_codename):
return contents + { return contents + {
"focal": dockerfile_extra_contents_focal, "focal": dockerfile_extra_contents_focal,
"bionic": dockerfile_extra_contents_bionic, "bionic": dockerfile_extra_contents_bionic,
}[os_codename] }[util.Interpolate("%(prop:os_codename)s")]
def trigger_child_hooks(buildbotUrl: str, os_codename: str, repository, branch, jobname, directory=".buildbot"): def trigger_child_hooks(buildbotUrl: str, os_codename: str, repository, branch, jobname, directory=".buildbot"):
@ -164,28 +165,28 @@ def add_parent_step(build_factory, jobname, repository, branch):
) )
def add_child_build_sh_step(build_factory, job, directory=".buildbot"): def add_child_build_sh_step(build_factory, directory=".buildbot"):
""" """
Add a step to the build factory Add a step to the build factory
""" """
build_factory.addStep( build_factory.addStep(
steps.ShellCommand( steps.ShellCommand(
name="build_" + job, name="build_" + util.Interpolate("%(prop:jobname)s"),
command=["bash", "-c", join(directory, job, "build.sh")], command=["bash", "-c", join(directory, util.Interpolate("%(prop:jobname)s"), "build.sh")],
doStepIf=is_build_script_available, doStepIf=is_build_script_available,
hideStepIf=isnt_build_script_available, hideStepIf=isnt_build_script_available,
) )
) )
def add_child_test_sh_step(build_factory, job, directory=".buildbot"): def add_child_test_sh_step(build_factory, directory=".buildbot"):
""" """
Add a step to the build factory Add a step to the build factory
""" """
build_factory.addStep( build_factory.addStep(
steps.ShellCommand( steps.ShellCommand(
name="test_" + job, name="test_" + util.Interpolate("%(prop:jobname)s"),
command=["bash", "-c", join(directory, job, "test.sh")], command=["bash", "-c", join(directory, util.Interpolate("%(prop:jobname)s"), "test.sh")],
doStepIf=is_test_script_available, doStepIf=is_test_script_available,
hideStepIf=isnt_test_script_available, hideStepIf=isnt_test_script_available,
) )