Skip to contentSkip to conversation

1/4] autobuilder/lib: Add buildsteps module for provide helpers

PATCH New Aníbal Limón 2 participants 6 messages Feb 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 1/4] autobuilder/lib: Add buildsteps module for provide helpers

Add ShellCommandCleanEnv helper for run command in a clean enviroment a shell for run the command can be specified also the variables to preserve in the new enviroment.

---
 .../site-packages/autobuilder/lib/buildsteps.py    | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 lib/python2.7/site-packages/autobuilder/lib/buildsteps.py
lib/python2.7/site-packages/autobuilder/lib/buildsteps.py new file +42 -0
new file mode 100644
index 0000000..3693a7a
@@ -0,0 +1,42 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+import os
+from buildbot.steps.shell import ShellCommand
+
+DEFAULT_SHELL = 'bash'
+
+class ShellCommandCleanEnv(ShellCommand):
+    def __init__(self, factory, argdict=None, **kwargs):
+        shell = DEFAULT_SHELL
+        if 'SHELL' in kwargs:
+            shell = kwargs['SHELL']
+            del kwargs['SHELL']
+
+        if 'PENV' in kwargs:
+            preserve_env = kwargs['PENV']
+            del kwargs['PENV']
+        else:
+            preserve_env = ['HOME', 'PWD', 'PATH',
+                            'http_proxy', 'https_proxy',
+                            'ftp_proxy', 'no_proxy', 'GIT_PROXY_COMMAND']
+
+        env_command = self._get_env_cleaned_command(shell, preserve_env)
+        self.command = "%s \'%s\'" % (env_command, self.command)
+        ShellCommand.__init__(self, **kwargs)
+
+    def _get_env_cleaned_command(self, shell, preserve_env):
+        pe_cmd = ''
+        for pe in preserve_env:
+            pe_cmd += "%s=\"$%s\" " % (pe, pe)
+
+        return "env -i %s %s -c " % (pe_cmd, shell)
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/1 2/4] autobuilder/buildsteps: Add Toaster buildsteps.

Adds Toaster buildsteps for setup toaster environment (installs requirements), start/stop a toaster instance and run tests.

---
 .../autobuilder/buildsteps/ToasterRunTests.py      | 31 ++++++++++++++++++++
 .../autobuilder/buildsteps/ToasterSetupVenv.py     | 31 ++++++++++++++++++++
 .../autobuilder/buildsteps/ToasterStart.py         | 32 +++++++++++++++++++++
 .../autobuilder/buildsteps/ToasterStop.py          | 33 ++++++++++++++++++++++
 4 files changed, 127 insertions(+)
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterRunTests.py
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterSetupVenv.py
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStart.py
 create mode 100644 lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStop.py
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterRunTests.py new file +31 -0
new file mode 100644
index 0000000..141768c
@@ -0,0 +1,31 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+from lib.buildsteps import ShellCommandCleanEnv
+import os
+
+class ToasterRunTests(ShellCommandCleanEnv):
+    haltOnFailure = True
+    flunkOnFailure = True
+    name = "ToasterRunTests"
+
+    def __init__(self, factory, argdict=None, **kwargs):
+        self.factory = factory
+        self.description = "Running toaster tests..."
+
+        oe_cmd = "source ./oe-init-build-env;"
+        venv_cmd = "source venv/bin/activate;"
+        cmd = "DISPLAY=:1 toaster-test --run-all-tests --verbose"
+
+        self.command = oe_cmd + venv_cmd + cmd
+
+        ShellCommandCleanEnv.__init__(self, factory, argdict, **kwargs)
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterSetupVenv.py new file +31 -0
new file mode 100644
index 0000000..54cf1e7
@@ -0,0 +1,31 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+from lib.buildsteps import ShellCommandCleanEnv
+
+class ToasterSetupVenv(ShellCommandCleanEnv):
+    haltOnFailure = True
+    flunkOnFailure = True
+    name = "ToasterSetupVenv"
+
+    def __init__(self, factory, argdict=None, **kwargs):
+        self.factory = factory
+        self.description = "Creating virtualenv..."
+
+        oe_cmd = "source ./oe-init-build-env;"
+        venv_cmd = "virtualenv venv; source venv/bin/activate;"
+        install_cmd = "pip install -r ../bitbake/toaster-requirements.txt;"
+        install_tests_cmd = "pip install -r ../bitbake/toaster-tests-requirements.txt;"
+
+        self.command = oe_cmd + venv_cmd + install_cmd + install_tests_cmd 
+
+        ShellCommandCleanEnv.__init__(self, factory, argdict, **kwargs)
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStart.py new file +32 -0
new file mode 100644
index 0000000..14cf9db3
@@ -0,0 +1,32 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+from lib.buildsteps import ShellCommandCleanEnv
+import os
+
+class ToasterStart(ShellCommandCleanEnv):
+    haltOnFailure = True
+    flunkOnFailure = True
+    name = "ToasterStart"
+
+    def __init__(self, factory, argdict=None, **kwargs):
+        self.factory = factory
+        self.description = "Starting toaster..."
+
+        oe_cmd = "source ./oe-init-build-env;"
+        venv_cmd = "source venv/bin/activate;"
+        start_cmd = "../bitbake/lib/toaster/tests/helpers.py -a start" \
+            " -d $(readlink -e ../)"
+
+        self.command = oe_cmd + venv_cmd + start_cmd
+
+        ShellCommandCleanEnv.__init__(self, factory, argdict, **kwargs)
lib/python2.7/site-packages/autobuilder/buildsteps/ToasterStop.py new file +33 -0
new file mode 100644
index 0000000..6fda0e8
@@ -0,0 +1,33 @@
+'''
+Created on Feb 15, 2016
+
+__author__ = "Anibal (alimon) Limon"
+__copyright__ = "Copyright 2016, Intel Corp."
+__credits__ = ["Anibal Limon"]
+__license__ = "GPL"
+__version__ = "2.0"
+__maintainer__ = "Anibal Limon"
+__email__ = "[email protected]"
+'''
+
+from lib.buildsteps import ShellCommandCleanEnv
+import os
+
+class ToasterStop(ShellCommandCleanEnv):
+    alwaysRun = True
+    haltOnFailure = True
+    flunkOnFailure = True
+    name = "ToasterStop"
+
+    def __init__(self, factory, argdict=None, **kwargs):
+        self.factory = factory
+        self.description = "Stopping toaster..."
+
+        oe_cmd = "source ./oe-init-build-env;"
+        venv_cmd = "source venv/bin/activate;"
+        start_cmd = "../bitbake/lib/toaster/tests/helpers.py -a stop" \
+            " -d $(readlink -e ../)"
+
+        self.command = oe_cmd + venv_cmd + start_cmd
+
+        ShellCommandCleanEnv.__init__(self, factory, argdict, **kwargs)
Signature · 1 line
2.1.4
#2 lore raw

PATCH v2 1/1 3/4] buildset-config.toaster: Add toaster-tests.conf buildset.

In reply to Aníbal Limón

The toaster-tests buildset contains steps for run toaster tests in a clean way, a Sleep step is needed after setup toaster for give certain time to let toaster ends setup.

---
 buildset-config.toaster/toaster-tests.conf | 21 +++++++++++++++++++++
 buildset-config.toaster/yoctoAB.conf       |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 buildset-config.toaster/toaster-tests.conf
buildset-config.toaster/toaster-tests.conf new file +21 -0
new file mode 100644
index 0000000..0aa6b46
@@ -0,0 +1,21 @@
+[toaster-tests]
+builders: 'example-worker'
+repos: [{'poky':
+            {'repourl':'git://git.yoctoproject.org/poky',
+             'layerversion':{'core':'meta', 'yoctobsp':'meta-yocto-bsp', 'yocto':'meta-yocto', 'poky':'meta-poky'},
+             'branch':'master' }}]
+steps: [{'SetDest':{}},
+        {'CheckOutLayers': {}},
+        {'RunPreamble': {}},
+        {'GetDistroVersion' : {'distro': 'poky'}},
+        {'CreateAutoConf': {'machine': 'qemux86', 'SDKMACHINE' : 'i686',
+                            'distro': 'poky', 'buildhistory' : True}},
+        {'CreateBBLayersConf': {'buildprovider' : 'yocto'}},
+        {'SyncPersistDB' : {'distro' : 'poky'}},
+        {'GetBitbakeVersion': {}},
+	{'ToasterSetupVenv': {}},
+	{'ToasterStart': {}},
+	{'Sleep': {'time': '120'}},
+	{'ToasterRunTests': {}},
+	{'ToasterStop': {}},
+       ]
buildset-config.toaster/yoctoAB.conf +1 -1
index 4f3fa00..614e39c 100644
@@ -1,2 +1,2 @@
 [BuildSets]
-order: [] 
+order: ['toaster-tests']
Signature · 1 line
2.1.4
#3 lore raw

PATCH v2 1/1 4/4] buildset-config.toaster: Remove unused template toaster-build.

In reply to Aníbal Limón
---
 buildset-config.toaster/toaster-build.conf | 29 -----------------------------
 1 file changed, 29 deletions(-)
 delete mode 100644 buildset-config.toaster/toaster-build.conf
buildset-config.toaster/toaster-build.conf deleted +0 -29
deleted file mode 100644
index 09a03e2..0000000
@@ -1,29 +0,0 @@
-[toaster-build]
-builders: 'example-worker'
-props: [{'atext':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'atext',
-                       'default': '',
-                       'label':'<hr><h3> auto.conf:</h3>'}},
-        {'bbtext':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'bbtext',
-                       'default': '',
-                       'label':'<hr><h3> bblayers.conf:</h3>'}},
-        {'images':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'images',
-                       'default': '',
-                       'label':'<hr><h3> images:</h3>'}},
-        {'layers':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'layers',
-                       'default': '',
-                       'label':'<hr><h3> repo string (ast):</h3>'}}]
-steps: [{'SetDest':{}},
-        {'CheckOutToasterLayers': {}},
-        {'RunPreamble': {}},
-        {'GetDistroVersion' : {'distro': 'poky'}},
-        {'CreateAutoConf': {'atext' : '#TOASTER'}},
-        {'CreateBBLayersConf': {'bbtext' : '#TOASTER'}},
-        {'BuildImages': {'images': '#TOASTER'}}]
Signature · 1 line
2.1.4
#4 lore raw

Re: [[PATCHv2][autobuilder] 4/4] buildset-config.toaster: Remove unused template toaster-build.

I'm going to pull all but this patch (4/4), because I'll eventually need this configuration.

-b

Quoted 44 lines · Aníbal Limón
---
 buildset-config.toaster/toaster-build.conf | 29 -----------------------------
 1 file changed, 29 deletions(-)
 delete mode 100644 buildset-config.toaster/toaster-build.conf
buildset-config.toaster/toaster-build.conf deleted +0 -30
deleted file mode 100644
index 09a03e2..0000000
@@ -1,29 +0,0 @@
-[toaster-build]
-builders: 'example-worker'
-props: [{'atext':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'atext',
-                       'default': '',
-                       'label':'<hr><h3> auto.conf:</h3>'}},
-        {'bbtext':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'bbtext',
-                       'default': '',
-                       'label':'<hr><h3> bblayers.conf:</h3>'}},
-        {'images':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'images',
-                       'default': '',
-                       'label':'<hr><h3> images:</h3>'}},
-        {'layers':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'layers',
-                       'default': '',
-                       'label':'<hr><h3> repo string (ast):</h3>'}}]
-steps: [{'SetDest':{}},
-        {'CheckOutToasterLayers': {}},
-        {'RunPreamble': {}},
-        {'GetDistroVersion' : {'distro': 'poky'}},
-        {'CreateAutoConf': {'atext' : '#TOASTER'}},
-        {'CreateBBLayersConf': {'bbtext' : '#TOASTER'}},
-        {'BuildImages': {'images': '#TOASTER'}}]
--

2.1.4

Signature · 3 lines
Elizabeth Flanagan
Yocto Project
Build and Release
#5 lore raw

Re: [[PATCHv2][autobuilder] 4/4] buildset-config.toaster: Remove unused template toaster-build.

Agree.

Quoted 53 lines · Elizabeth

I'm going to pull all but this patch (4/4), because I'll eventually need this configuration.

-b

Quoted 44 lines · Aníbal Limón
---
 buildset-config.toaster/toaster-build.conf | 29 -----------------------------
 1 file changed, 29 deletions(-)
 delete mode 100644 buildset-config.toaster/toaster-build.conf
buildset-config.toaster/toaster-build.conf deleted +0 -30
deleted file mode 100644
index 09a03e2..0000000
@@ -1,29 +0,0 @@
-[toaster-build]
-builders: 'example-worker'
-props: [{'atext':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'atext',
-                       'default': '',
-                       'label':'<hr><h3> auto.conf:</h3>'}},
-        {'bbtext':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'bbtext',
-                       'default': '',
-                       'label':'<hr><h3> bblayers.conf:</h3>'}},
-        {'images':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'images',
-                       'default': '',
-                       'label':'<hr><h3> images:</h3>'}},
-        {'layers':{'prop_type':'StringParameter',
-                       'size': 15,
-                       'name': 'layers',
-                       'default': '',
-                       'label':'<hr><h3> repo string (ast):</h3>'}}]
-steps: [{'SetDest':{}},
-        {'CheckOutToasterLayers': {}},
-        {'RunPreamble': {}},
-        {'GetDistroVersion' : {'distro': 'poky'}},
-        {'CreateAutoConf': {'atext' : '#TOASTER'}},
-        {'CreateBBLayersConf': {'bbtext' : '#TOASTER'}},
-        {'BuildImages': {'images': '#TOASTER'}}]
--

2.1.4