view sendchanges/sendchanges.py @ 4:d097e46e37d6 default tip

add jhfords script
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 15 Feb 2011 17:06:48 -0800
parents 0b8ad10a510e
children
line wrap: on
line source

#!/usr/bin/env python

# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
# 
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
# 
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
# 
# The Original Code is mozilla.org code.
# 
# The Initial Developer of the Original Code is
# Mozilla.org.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
# 
# Contributor(s):
#     Alice Nodelman <anodelman@mozilla.com> (Original author)
#     Jeff Hammel <jhammel@mozilla.com>     
# 
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
# 
# ***** END LICENSE BLOCK *****

"""
forces sendchanges to test mozilla-central builds for all platforms
usage:
sendchanges [options]
"""

# imports
import sys
from getlatesttinderbox import GetLatestTinderbox
from optparse import OptionParser
from subprocess import check_call

# globals
platforms = ['win32', 'linux', 'linux64', 'macosx64']
branches = ['talos', 'opt-unittest', 'debug-unittest']
ports = ['9010', '9012']


def main(args=sys.argv[1:]):

  # parse options
  parser = OptionParser(description=__doc__)
  parser.add_option('-p', '--port', dest='port',
                    choices=ports, type='choice',
                    help='buildbot masteir port number to push sendchanges to (choices: %s)' % ports)
  parser.add_option('-b', '--branch', dest='branch',
                    choices=branches, type='choice',
                    help='which branch to push (choices: %s)' % branches)
  parser.add_option('-u', '--url', dest='url',
                    default=None,
                    help='base url where the builds live')
  parser.add_option('--platform', dest='platforms', action='append',
                    help='which platforms to run on, all by default (choices: %s)' % platforms)
  parser.add_option('--username', dest='username', default='sendchange_script',
                    help="user name to send changes as")
  options, args = parser.parse_args(args)

  # check options
  if not options.platforms:
    options.platforms = platforms
  if not options.port:
    parser.error("Error - please specify a buildbot master port number to push sendchanges to (9010 or 9012)")
  if not options.branch:
    parser.error("Error - please specify your branch")

  # get the changes
  changes = {}
  for platform in options.platforms:
    if args:
      changes[platform] = args
      continue
    if options.branch == 'debug-unittest':
      latest = GetLatestTinderbox(platform=platform, debug=True)
    else:
      latest = GetLatestTinderbox(platform=platform)
    _changes = [ latest.latest_build_url(options.url) ]
    if options.branch != 'talos':
      _changes.append(latest.latest_tests_url(options.url))
      _changes.append(latest.latest_symbols_url(options.url))
    if None in _changes:
      raise AssertionError("You mess something up! %s %s %s" % (platform, options.url, _changes))
    changes[platform] = _changes

  # send the changes
  for platform in options.platforms:
    check_call(['buildbot', 'sendchange',
                '--user', options.username,
                '--master', 'localhost:%d' % int(options.port),
                '--branch', 'mozilla-central-%s-%s' % (platform, options.branch)]
               + changes[platform])

if __name__ == '__main__':
  main()