diff releasetalos.py @ 0:642e1f903bd0

initial commit of talos, mozutils port of http://k0s.org/mozilla/talos/new-talos-zip-bug.py
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 22 Jan 2013 12:10:40 -0800
parents
children af3e9bef7722
line wrap: on
line diff
--- /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()
+