view releasetalos.py @ 1:af3e9bef7722 default tip

comment
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 24 Jan 2013 09:51:32 -0800
parents 642e1f903bd0
children
line wrap: on
line source

#!/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
    # -- these should be blocking bugs for this bug
    # - upload talos.zip to people.mozilla.org
    # - push to try if talos tests are given

if __name__ == '__main__':
    main()