# HG changeset patch # User Jeff Hammel # Date 1358885440 28800 # Node ID 642e1f903bd05983f6ee8569ac3a7dca5d0e7ea4 initial commit of talos, mozutils port of http://k0s.org/mozilla/talos/new-talos-zip-bug.py diff -r 000000000000 -r 642e1f903bd0 README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.txt Tue Jan 22 12:10:40 2013 -0800 @@ -0,0 +1,11 @@ +ReleaseTalos +=========== + +create a bug to deploy a new talos.zip + +---- + +Jeff Hammel + +http://k0s.org/mozilla/hg/ReleaseTalos + diff -r 000000000000 -r 642e1f903bd0 releasetalos.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/releasetalos.py Tue Jan 22 12:10:40 2013 -0800 @@ -0,0 +1,93 @@ +#!/usr/bin/env python + +""" +releasetalos +create a bug to deploy a new talos.zip +""" + +import bzconsole +import datetime +import sys +import talostry + +from bzconsole.command import read_dotfile +from mozillatry import ConfigurationError + +comment = """ +A new talos.zip should be deployed for m-c. +The zip should be uploaded to people.mozilla.org and the link posted here. +The zip should then be copied to http://build.mozilla.org/talos/zips/ . +talos.json should be updated with this location: +https://hg.mozilla.org/mozilla-central/file/tip/testing/talos/talos.json +""" + + +class ReleaseTalos(talostry.TalosTryConfiguration): + __doc__ = __doc__ + + options = talostry.TalosTryConfiguration + options.update({'cc': {'default': [':jmaher', ':armenzg', ':edmorley'], + 'help': 'cc to the bug'}, + 'title': {'default': "Deploy new talos.zip for %s" % (datetime.datetime.now().strftime("%Y-%m-%d")), + 'help' 'title of bug'}, + }) + + def validate(self): + """validate configuration""" + + talostry.TalosTryConfiguration.validate(self) + + # bugzilla credentials keys + credentials = set(['username', 'password']) + + # parse bzconsole auth from ~/.bz + # TODO: should be inputtable alternatively directly from configuration + data = read_dotfile() + for key in credentials: + if key in data and key not in self.config: + self.config[key] = data[key] + + # ensure bugzilla credentials are given + if not credentials.issubset(self.config.keys()) + raise ConfigurationError("Missing bugzilla credentials: %s" % + ', '.join([i for i in credentials + if i not in self.config.keys()])) + + + + def generate_bug(self): + """ + generate a bug to release a new talos; + returns the bug number + """ + + bzapi = bzconsole.BZapi(username=self.config['username'], + password=self.config['password']) + url = bzapi.new(component='Release Engineering: Automation (General)', + title=self.config['title'], + description=comment.strip(), + cc=self.config['cc']) + print url + bug = int(url.rsplit('/', 1)[-1]) + + +def main(args=sys.argv[1:]): + + # parse command line arguments + releasetalos = ReleaseTalos() + options, args = parser.parse_args(args) + if args: + parser.print_help() + parser.exit(1) + + # generate bug + releasetalos.generate_bug() + + ### TODO: + # - deduce and mark bugs from this talos.zip from last talos.zip + # - upload talos.zip to people.mozilla.org + # - push to try if talos tests are given + +if __name__ == '__main__': + main() + diff -r 000000000000 -r 642e1f903bd0 setup.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setup.py Tue Jan 22 12:10:40 2013 -0800 @@ -0,0 +1,36 @@ +import os +from setuptools import setup + +try: + here = os.path.dirname(os.path.abspath(__file__)) + description = file(os.path.join(here, 'README.txt')).read() +except IOError: + description = None + +version = '0.0' + +deps = ['bzconsole', + 'talostry'] + +setup(name='releasetalos', + version=version, + description="create a bug to deploy a new talos.zip", + long_description=description, + classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers + keywords='mozilla', + author='Jeff Hammel', + author_email='jhammel@mozilla.com', + url='http://k0s.org/mozilla/hg/ReleaseTalos', + license='', + py_modules=['releasetalos'], + packages=[], + include_package_data=True, + zip_safe=False, + install_requires=deps, + entry_points=""" + # -*- Entry points: -*- + [console_scripts] + releasetalos = releasetalos:main + """, + ) + diff -r 000000000000 -r 642e1f903bd0 tests/doctest.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/doctest.txt Tue Jan 22 12:10:40 2013 -0800 @@ -0,0 +1,11 @@ +Test ReleaseTalos +================ + +The obligatory imports: + + >>> import releasetalos + +Run some tests. This test will fail, please fix it: + + >>> assert True == False + diff -r 000000000000 -r 642e1f903bd0 tests/test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test.py Tue Jan 22 12:10:40 2013 -0800 @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +""" +doctest runner +""" + +import doctest +import os +import sys +from optparse import OptionParser + + +def run_tests(raise_on_error=False, report_first=False): + + # add results here + results = {} + + # doctest arguments + directory = os.path.dirname(os.path.abspath(__file__)) + extraglobs = {'here': directory} + doctest_args = dict(extraglobs=extraglobs, raise_on_error=raise_on_error) + if report_first: + doctest_args['optionflags'] = doctest.REPORT_ONLY_FIRST_FAILURE + + # gather tests + tests = [ test for test in os.listdir(directory) + if test.endswith('.txt') ] + + # run the tests + for test in tests: + try: + results[test] = doctest.testfile(test, **doctest_args) + except doctest.DocTestFailure, failure: + raise + except doctest.UnexpectedException, failure: + raise failure.exc_info[0], failure.exc_info[1], failure.exc_info[2] + + return results + +def main(args=sys.argv[1:]): + + # parse command line args + parser = OptionParser(description=__doc__) + parser.add_option('--raise', dest='raise_on_error', + default=False, action='store_true', + help="raise on first error") + parser.add_option('--report-first', dest='report_first', + default=False, action='store_true', + help="report the first error only (all tests will still run)") + options, args = parser.parse_args(args) + + # run the tests + results = run_tests(**options.__dict__) + if sum([i.failed for i in results.values()]): + sys.exit(1) # error + + +if __name__ == '__main__': + main() +