Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Copyright 2018 The WPT Dashboard Project. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from buildbot.plugins import steps
from buildbot.plugins import util
import os
class WptRunStep(steps.ShellCommand):
name = util.Interpolate(
'WPT Run ' +
'(%(prop:browser_name)s, %(prop:this_chunk)s of %(prop:total_chunks)s)'
)
def __init__(self, *args, **kwargs):
kwargs['name'] = self.name
kwargs['command'] = self.makeWptRunCommand
kwargs['logfiles'] = {
'sauce-connect-log': {
'filename': '/var/log/sauce-connect/sc.log',
'follow': True
},
'xvfb-log': {
'filename': '/var/log/xvfb/xvfb.log',
'follow': True
}
command=["/bin/sh", "find.sh"],
workdir="build/files/"))
factory.addStep(steps.ShellCommand(name="Building kernel",
command=["/bin/sh", "../build-kernel.sh", arch],
workdir="build/files/linux-" + version + "/",
haltOnFailure=True))
factory.addStep(steps.ShellCommand(name="Building modules",
command=["/bin/sh", "../build-kernel.sh", arch, "modules"],
workdir="build/files/linux-" + version + "/",
haltOnFailure=True))
factory.addStep(steps.ShellCommand(name="Booting with QEMU",
command=["/usr/bin/python", "qemu_check.py", arch,
util.Property('buildername'), util.Property('buildnumber')],
workdir="build/files/", timeout=3600))
factory.addStep(steps.ShellCommand(name="Cleanup",
command=["/bin/sh", "clean.sh"],
workdir="build/",
alwaysRun=True))
return factory
def __init__(self, name, **kwargs):
kwargs = self.extract_attrs(name, **kwargs)
return worker.HyperLatentWorker.__init__(
self,
name,
kube_config=kube_config,
image=util.Interpolate("%(prop:DOCKER_IMAGE:-buildbot/metabbotcfg)s"),
masterFQDN="buildbot.buildbot.net",
**kwargs)
def test_gentoo_sources():
factory = util.BuildFactory()
factory.addStep(steps.GitHub(name="Fetching repository",
repourl=pull_repourl,
mode='incremental', workdir="build/gentoo", shallow=50))
factory.addStep(steps.FileDownload(mastersrc="config/files/qemu_check.py",
workerdest="files/qemu_check.py"))
factory.addStep(steps.FileDownload(mastersrc="config/files/stabilize-packages.py",
workerdest="files/stabilize-packages.py"))
factory.addStep(steps.FileDownload(mastersrc="config/files/clean.sh",
workerdest="clean.sh",
alwaysRun=True))
factory.addStep(steps.FileDownload(mastersrc="config/files/clean.py",
workerdest="clean.py",
alwaysRun=True))
factory.addStep(steps.ShellCommand(name="Stabilizing package",
command=filterFiles,
workdir="build/files/"))
def getPushChangeFilter(self):
filt = dict(repository=self.repository)
if self.branch is not None:
filt['branch'] = self.branch
return util.ChangeFilter(**filt)
def __init__(self, *args, project, repository, button_name=None,
label=None, **kwargs):
"""Improves the default form of ForceScheduler"""
codebase = util.CodebaseParameter(
codebase='',
label='',
project=util.FixedParameter(name='project', default=project),
repository=util.FixedParameter(name='repository',
default=repository),
branch=util.StringParameter(name='branch',
default='master',
required=True),
# required, otherwise status push reporter fails with a
# non-descriptive exception
revision=util.StringParameter(name='revision', default='HEAD',
required=True)
)
kwargs['buttonName'] = button_name or f'Build {project}'
kwargs['label'] = label or f'Manual {project} build'
super().__init__(*args, codebases=[codebase], **kwargs)
def mkcoveragefactory():
f = util.BuildFactory()
f.addSteps([
gitStep,
VirtualenvSetup(name='virtualenv setup',
no_site_packages=True,
virtualenv_packages=['coverage', 'mock',
'--editable=master',
'--editable=slave'],
virtualenv_dir='sandbox',
haltOnFailure=True),
steps.ShellCommand(command=textwrap.dedent("""
PYTHON=sandbox/bin/python;
sandbox/bin/coverage run --rcfile=common/coveragerc \
sandbox/bin/trial buildbot.test buildslave.test \
|| exit 1;
sandbox/bin/coverage html -i --rcfile=.coveragerc \
-d /home/buildbot/www/buildbot.buildbot.net/static/coverage \
def __init__(self, *args, project, repository, button_name=None,
label=None, **kwargs):
"""Improves the default form of ForceScheduler"""
codebase = util.CodebaseParameter(
codebase='',
label='',
project=util.FixedParameter(name='project', default=project),
repository=util.FixedParameter(name='repository',
default=repository),
branch=util.StringParameter(name='branch',
default='master',
required=True),
# required, otherwise status push reporter fails with a
# non-descriptive exception
revision=util.StringParameter(name='revision', default='HEAD',
required=True)
)
kwargs['buttonName'] = button_name or f'Build {project}'
kwargs['label'] = label or f'Manual {project} build'
super().__init__(*args, codebases=[codebase], **kwargs)
),
hideStepIf=lambda results, s: results == SKIPPED or results == SUCCESS,
)
# load builders.json with definitions on how to build things
parent_path = os.path.dirname(__file__)
with open(os.path.join(parent_path, "volk_builders.json"), "r") as builders_file:
build_config = json.loads(builders_file.read())
trigger_builds = custom_steps.BuildTrigger(
name="trigger the right builders",
build_config=build_config,
schedulerNames=["trigger"],
runner="pull",
set_properties={
"pr_base": util.Property("github.base.ref"),
"src_dir": util.Interpolate(os.path.join(
_PULL_SRC_BASE, "%(prop:github.number)s"))
},
updateSourceStamp=False,
waitForFinish=True
)
factory = util.BuildFactory()
factory.addStep(create_src)
factory.addStep(clone_step)
factory.addStep(rm_src_dir)
factory.addStep(copy_src)
factory.addStep(trigger_builds)
return factory