Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """CBuildbot is wrapper around the build process used by the pre-flight queue""" | 7 """CBuildbot is wrapper around the build process used by the pre-flight queue""" |
| 8 | 8 |
| 9 import errno | 9 import errno |
| 10 import heapq | 10 import heapq |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 '--overlays=%s' % ':'.join(overlays), | 478 '--overlays=%s' % ':'.join(overlays), |
| 479 '--tracking_branch=%s' % tracking_branch | 479 '--tracking_branch=%s' % tracking_branch |
| 480 ] | 480 ] |
| 481 if dryrun: | 481 if dryrun: |
| 482 cmd.append('--dryrun') | 482 cmd.append('--dryrun') |
| 483 | 483 |
| 484 cmd.append('push') | 484 cmd.append('push') |
| 485 RunCommand(cmd, cwd=cwd) | 485 RunCommand(cmd, cwd=cwd) |
| 486 | 486 |
| 487 | 487 |
| 488 def _LegacyArchiveBuild(bot_id, buildconfig, buildnumber, debug = False): | |
|
sosa
2011/01/26 00:40:04
no spaces in keyval args in params
| |
| 489 """Adds a step to the factory to archive a build.""" | |
| 490 | |
| 491 # Fixed properties | |
| 492 keep_max = 3 | |
| 493 gsutil_archive = 'gs://chromeos-archive/' + bot_id | |
| 494 | |
| 495 cmd = ['./archive_build.sh', | |
| 496 '--build_number', str(buildnumber), | |
| 497 '--to', '/var/www/archive/' + bot_id, | |
| 498 '--keep_max', str(keep_max), | |
| 499 '--prebuilt_upload', | |
| 500 '--board', buildconfig['board'], | |
| 501 | |
| 502 '--acl', '/home/chrome-bot/slave_archive_acl', | |
| 503 '--gsutil_archive', gsutil_archive, | |
| 504 '--gsd_gen_index', | |
| 505 '/b/scripts/gsd_generate_index/gsd_generate_index.py', | |
| 506 '--gsutil', '/b/scripts/slave/gsutil', | |
| 507 '--test_mod' | |
| 508 ] | |
| 509 | |
| 510 if buildconfig.get('test_mod', True): | |
| 511 cmd.append('--test_mod') | |
| 512 | |
| 513 if buildconfig.get('factory_install_mod', True): | |
| 514 cmd.append('--factory_install_mod') | |
| 515 | |
| 516 if buildconfig.get('factory_test_mod', True): | |
| 517 cmd.append('--factory_test_mod') | |
| 518 | |
| 519 if debug: | |
| 520 Warning('***** ***** LegacyArchiveBuild CMD: ' + ' '.join(cmd)) | |
| 521 else: | |
| 522 RunCommand(cmd) | |
| 523 | |
| 488 def _ArchiveTestResults(buildroot, board, test_results_dir, | 524 def _ArchiveTestResults(buildroot, board, test_results_dir, |
| 489 gsutil, archive_dir, acl): | 525 gsutil, archive_dir, acl): |
| 490 """Archives the test results into Google Storage | 526 """Archives the test results into Google Storage |
| 491 | 527 |
| 492 Takes the results from the test_results_dir and the last qemu image and | 528 Takes the results from the test_results_dir and the last qemu image and |
| 493 uploads them to Google Storage. | 529 uploads them to Google Storage. |
| 494 | 530 |
| 495 Arguments: | 531 Arguments: |
| 496 buildroot: Root directory where build occurs | 532 buildroot: Root directory where build occurs |
| 497 board: Board to find the qemu image. | 533 board: Board to find the qemu image. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 | 637 |
| 602 RunCommand(cmd, cwd=cwd) | 638 RunCommand(cmd, cwd=cwd) |
| 603 | 639 |
| 604 | 640 |
| 605 def main(): | 641 def main(): |
| 606 # Parse options | 642 # Parse options |
| 607 usage = "usage: %prog [options] cbuildbot_config" | 643 usage = "usage: %prog [options] cbuildbot_config" |
| 608 parser = optparse.OptionParser(usage=usage) | 644 parser = optparse.OptionParser(usage=usage) |
| 609 parser.add_option('-a', '--acl', default='private', | 645 parser.add_option('-a', '--acl', default='private', |
| 610 help='ACL to set on GSD archives') | 646 help='ACL to set on GSD archives') |
| 647 parser.add_option('--archive_build', action='store_true', default=False, | |
| 648 help='Run the archive_build script.') | |
| 611 parser.add_option('-r', '--buildroot', | 649 parser.add_option('-r', '--buildroot', |
| 612 help='root directory where build occurs', default=".") | 650 help='root directory where build occurs', default=".") |
| 613 parser.add_option('-n', '--buildnumber', | 651 parser.add_option('-n', '--buildnumber', |
| 614 help='build number', type='int', default=0) | 652 help='build number', type='int', default=0) |
| 615 parser.add_option('--chrome_rev', default=None, type='string', | 653 parser.add_option('--chrome_rev', default=None, type='string', |
| 616 dest='chrome_rev', | 654 dest='chrome_rev', |
| 617 help=('Chrome_rev of type [tot|latest_release|' | 655 help=('Chrome_rev of type [tot|latest_release|' |
| 618 'sticky_release]')) | 656 'sticky_release]')) |
| 619 parser.add_option('-g', '--gsutil', default='', help='Location of gsutil') | 657 parser.add_option('-g', '--gsutil', default='', help='Location of gsutil') |
| 620 parser.add_option('-c', '--gsutil_archive', default='', | 658 parser.add_option('-c', '--gsutil_archive', default='', |
| 621 help='Datastore archive location') | 659 help='Datastore archive location') |
| 622 parser.add_option('--clobber', action='store_true', dest='clobber', | 660 parser.add_option('--clobber', action='store_true', dest='clobber', |
| 623 default=False, | 661 default=False, |
| 624 help='Clobbers an old checkout before syncing') | 662 help='Clobbers an old checkout before syncing') |
| 625 parser.add_option('--debug', action='store_true', dest='debug', | 663 parser.add_option('--debug', action='store_true', dest='debug', |
| 626 default=False, | 664 default=False, |
| 627 help='Override some options to run as a developer.') | 665 help='Override some options to run as a developer.') |
| 666 parser.add_option('--nobuild', action='store_false', dest='build', | |
| 667 default=True, | |
| 668 help="Don't actually build (for cbuildbot dev") | |
| 628 parser.add_option('--noprebuilts', action='store_false', dest='prebuilts', | 669 parser.add_option('--noprebuilts', action='store_false', dest='prebuilts', |
| 629 default=True, | 670 default=True, |
| 630 help="Don't upload prebuilts.") | 671 help="Don't upload prebuilts.") |
| 631 parser.add_option('--nosync', action='store_false', dest='sync', | 672 parser.add_option('--nosync', action='store_false', dest='sync', |
| 632 default=True, | 673 default=True, |
| 633 help="Don't sync before building.") | 674 help="Don't sync before building.") |
| 634 parser.add_option('--notests', action='store_false', dest='tests', | 675 parser.add_option('--notests', action='store_false', dest='tests', |
| 635 default=True, | 676 default=True, |
| 636 help='Override values from buildconfig and run no tests.') | 677 help='Override values from buildconfig and run no tests.') |
| 637 parser.add_option('-f', '--revisionfile', | 678 parser.add_option('-f', '--revisionfile', |
| 638 help='file where new revisions are stored') | 679 help='file where new revisions are stored') |
| 639 parser.add_option('-t', '--tracking-branch', dest='tracking_branch', | 680 parser.add_option('-t', '--tracking-branch', dest='tracking_branch', |
| 640 default='cros/master', help='Run the buildbot on a branch') | 681 default='cros/master', help='Run the buildbot on a branch') |
| 641 parser.add_option('-u', '--url', dest='url', | 682 parser.add_option('-u', '--url', dest='url', |
| 642 default='http://git.chromium.org/git/manifest', | 683 default='http://git.chromium.org/git/manifest', |
| 643 help='Run the buildbot on internal manifest') | 684 help='Run the buildbot on internal manifest') |
| 644 | 685 |
| 645 (options, args) = parser.parse_args() | 686 (options, args) = parser.parse_args() |
| 646 | 687 |
| 647 buildroot = os.path.abspath(options.buildroot) | 688 buildroot = os.path.abspath(options.buildroot) |
| 648 revisionfile = options.revisionfile | 689 revisionfile = options.revisionfile |
| 649 tracking_branch = options.tracking_branch | 690 tracking_branch = options.tracking_branch |
| 650 chrome_atom_to_build = None | 691 chrome_atom_to_build = None |
| 651 | 692 |
| 652 if len(args) >= 1: | 693 if len(args) >= 1: |
| 653 buildconfig = _GetConfig(args[-1]) | 694 bot_id = args[-1] |
| 695 buildconfig = _GetConfig(bot_id) | |
| 654 else: | 696 else: |
| 655 Warning('Missing configuration description') | 697 Warning('Missing configuration description') |
| 656 parser.print_usage() | 698 parser.print_usage() |
| 657 sys.exit(1) | 699 sys.exit(1) |
| 658 | 700 |
| 659 try: | 701 try: |
| 660 # Calculate list of overlay directories. | 702 # Calculate list of overlay directories. |
| 661 rev_overlays = _ResolveOverlays(buildroot, buildconfig['rev_overlays']) | 703 rev_overlays = _ResolveOverlays(buildroot, buildconfig['rev_overlays']) |
| 662 push_overlays = _ResolveOverlays(buildroot, buildconfig['push_overlays']) | 704 push_overlays = _ResolveOverlays(buildroot, buildconfig['push_overlays']) |
| 663 # We cannot push to overlays that we don't rev. | 705 # We cannot push to overlays that we don't rev. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 options.chrome_rev, board) | 741 options.chrome_rev, board) |
| 700 # If we found nothing to rev, we're done here. | 742 # If we found nothing to rev, we're done here. |
| 701 if not chrome_atom_to_build: | 743 if not chrome_atom_to_build: |
| 702 return | 744 return |
| 703 | 745 |
| 704 elif buildconfig['uprev']: | 746 elif buildconfig['uprev']: |
| 705 _UprevPackages(buildroot, tracking_branch, revisionfile, | 747 _UprevPackages(buildroot, tracking_branch, revisionfile, |
| 706 buildconfig['board'], rev_overlays) | 748 buildconfig['board'], rev_overlays) |
| 707 | 749 |
| 708 _EnableLocalAccount(buildroot) | 750 _EnableLocalAccount(buildroot) |
| 709 _Build(buildroot, emptytree) | 751 |
| 752 if options.build: | |
| 753 _Build(buildroot, emptytree) | |
| 710 | 754 |
| 711 if buildconfig['unittests'] and options.tests: | 755 if buildconfig['unittests'] and options.tests: |
| 712 _RunUnitTests(buildroot) | 756 _RunUnitTests(buildroot) |
| 713 | 757 |
| 714 _BuildImage(buildroot) | 758 _BuildImage(buildroot) |
| 715 | 759 |
| 716 if buildconfig['tests'] and options.tests: | 760 if buildconfig['tests'] and options.tests: |
| 717 _BuildVMImageForTesting(buildroot) | 761 _BuildVMImageForTesting(buildroot) |
| 718 test_results_dir = '/tmp/run_remote_tests.%s' % options.buildnumber | 762 test_results_dir = '/tmp/run_remote_tests.%s' % options.buildnumber |
| 719 try: | 763 try: |
| 720 _RunSmokeSuite(buildroot, test_results_dir) | 764 _RunSmokeSuite(buildroot, test_results_dir) |
| 721 _RunAUTest(buildroot, buildconfig['board']) | 765 _RunAUTest(buildroot, buildconfig['board']) |
| 722 finally: | 766 finally: |
| 723 if not options.debug: | 767 if not options.debug: |
| 724 archive_full_path = os.path.join(options.gsutil_archive, | 768 archive_full_path = os.path.join(options.gsutil_archive, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 739 [new_binhost]) | 783 [new_binhost]) |
| 740 _UprevPush(buildroot, tracking_branch, buildconfig['board'], | 784 _UprevPush(buildroot, tracking_branch, buildconfig['board'], |
| 741 push_overlays, options.debug) | 785 push_overlays, options.debug) |
| 742 else: | 786 else: |
| 743 Die('CBUILDBOT - One of the slaves has failed!!!') | 787 Die('CBUILDBOT - One of the slaves has failed!!!') |
| 744 | 788 |
| 745 else: | 789 else: |
| 746 # Publish my status to the master if its expecting it. | 790 # Publish my status to the master if its expecting it. |
| 747 if buildconfig['important'] and not options.debug: | 791 if buildconfig['important'] and not options.debug: |
| 748 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) | 792 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) |
| 749 | 793 |
| 794 if options.archive_build: | |
| 795 _LegacyArchiveBuild(bot_id, | |
| 796 buildconfig, | |
| 797 options.buildnumber, | |
| 798 options.debug) | |
| 750 except: | 799 except: |
| 751 # Send failure to master bot. | 800 # Send failure to master bot. |
| 752 if not buildconfig['master'] and buildconfig['important']: | 801 if not buildconfig['master'] and buildconfig['important']: |
| 753 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 802 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
| 754 | 803 |
| 755 raise | 804 raise |
| 756 | 805 |
| 757 | 806 |
| 758 if __name__ == '__main__': | 807 if __name__ == '__main__': |
| 759 main() | 808 main() |
| OLD | NEW |