Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: buildbot/cbuildbot.py

Issue 6519035: Hide archive build output unless it fails. (Closed) Base URL: http://git.chromium.org/git/chromite.git@master
Patch Set: Fix logic Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/cros_build_lib.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import re 11 import re
12 import optparse 12 import optparse
13 import os 13 import os
14 import shutil 14 import shutil
15 import sys 15 import sys
16 16
17 if __name__ == '__main__': 17 if __name__ == '__main__':
18 import constants 18 import constants
19 sys.path.append(constants.SOURCE_ROOT) 19 sys.path.append(constants.SOURCE_ROOT)
20 20
21 import cbuildbot_comm 21 import cbuildbot_comm
22 from cbuildbot_config import config 22 from cbuildbot_config import config
23 from chromite.lib.cros_build_lib import (Die, Info, ReinterpretPathForChroot, 23 from chromite.lib.cros_build_lib import (Die, Info, ReinterpretPathForChroot,
24 OldRunCommand, Warning) 24 OldRunCommand, Warning, RunCommand)
25 25
26 _DEFAULT_RETRIES = 3 26 _DEFAULT_RETRIES = 3
27 _PACKAGE_FILE = '%(buildroot)s/src/scripts/cbuildbot_package.list' 27 _PACKAGE_FILE = '%(buildroot)s/src/scripts/cbuildbot_package.list'
28 ARCHIVE_BASE = '/var/www/archive' 28 ARCHIVE_BASE = '/var/www/archive'
29 ARCHIVE_COUNT = 10 29 ARCHIVE_COUNT = 10
30 PUBLIC_OVERLAY = '%(buildroot)s/src/third_party/chromiumos-overlay' 30 PUBLIC_OVERLAY = '%(buildroot)s/src/third_party/chromiumos-overlay'
31 PRIVATE_OVERLAY = '%(buildroot)s/src/private-overlays/chromeos-overlay' 31 PRIVATE_OVERLAY = '%(buildroot)s/src/private-overlays/chromeos-overlay'
32 CHROME_KEYWORDS_FILE = ('/build/%(board)s/etc/portage/package.keywords/chrome') 32 CHROME_KEYWORDS_FILE = ('/build/%(board)s/etc/portage/package.keywords/chrome')
33 33
34 _FULL_BINHOST = 'PORTAGE_BINHOST' 34 _FULL_BINHOST = 'PORTAGE_BINHOST'
35 _PREFLIGHT_BINHOST = 'PREFLIGHT_BINHOST' 35 _PREFLIGHT_BINHOST = 'PREFLIGHT_BINHOST'
36 _CHROME_BINHOST = 'CHROME_BINHOST' 36 _CHROME_BINHOST = 'CHROME_BINHOST'
37 _CROS_ARCHIVE_URL = 'CROS_ARCHIVE_URL'
37 38
38 # ======================== Utility functions ================================ 39 # ======================== Utility functions ================================
39 40
40 def _PrintFile(path): 41 def _PrintFile(path):
41 """Prints out the contents of a file to stderr.""" 42 """Prints out the contents of a file to stderr."""
42 file_handle = open(path) 43 file_handle = open(path)
43 print >> sys.stderr, file_handle.read() 44 print >> sys.stderr, file_handle.read()
44 file_handle.close() 45 file_handle.close()
45 sys.stderr.flush() 46 sys.stderr.flush()
46 47
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 ] 495 ]
495 if dryrun: 496 if dryrun:
496 cmd.append('--dryrun') 497 cmd.append('--dryrun')
497 498
498 cmd.append('push') 499 cmd.append('push')
499 OldRunCommand(cmd, cwd=cwd) 500 OldRunCommand(cmd, cwd=cwd)
500 501
501 502
502 def _LegacyArchiveBuild(buildroot, bot_id, buildconfig, buildnumber, 503 def _LegacyArchiveBuild(buildroot, bot_id, buildconfig, buildnumber,
503 test_tarball, debug=False): 504 test_tarball, debug=False):
504 """Adds a step to the factory to archive a build.""" 505 """Archives build artifacts and returns URL to archived location."""
505 506
506 # Fixed properties 507 # Fixed properties
507 keep_max = 3 508 keep_max = 3
508 gsutil_archive = 'gs://chromeos-archive/' + bot_id 509 gsutil_archive = 'gs://chromeos-archive/' + bot_id
509 cwd = os.path.join(buildroot, 'src', 'scripts') 510 cwd = os.path.join(buildroot, 'src', 'scripts')
510 cmd = ['./archive_build.sh', 511 cmd = ['./archive_build.sh',
511 '--build_number', str(buildnumber), 512 '--build_number', str(buildnumber),
512 '--to', '/var/www/archive/' + bot_id, 513 '--to', '/var/www/archive/' + bot_id,
513 '--keep_max', str(keep_max), 514 '--keep_max', str(keep_max),
514 '--board', buildconfig['board'], 515 '--board', buildconfig['board'],
515 '--acl', '/home/chrome-bot/slave_archive_acl', 516 '--acl', '/home/chrome-bot/slave_archive_acl',
516 '--gsutil_archive', gsutil_archive, 517 '--gsutil_archive', gsutil_archive,
517 '--gsd_gen_index', 518 '--gsd_gen_index',
518 '/b/scripts/gsd_generate_index/gsd_generate_index.py', 519 '/b/scripts/gsd_generate_index/gsd_generate_index.py',
519 '--gsutil', '/b/scripts/slave/gsutil', 520 '--gsutil', '/b/scripts/slave/gsutil',
520 ] 521 ]
521 # Give the right args to archive_build. 522 # Give the right args to archive_build.
522 if buildconfig['archive_build_prebuilts']: cmd.append('--prebuilt_upload') 523 if buildconfig['archive_build_prebuilts']: cmd.append('--prebuilt_upload')
523 if buildconfig.get('factory_test_mod', True): cmd.append('--factory_test_mod') 524 if buildconfig.get('factory_test_mod', True): cmd.append('--factory_test_mod')
524 if not buildconfig['archive_build_debug']: cmd.append('--noarchive_debug') 525 if not buildconfig['archive_build_debug']: cmd.append('--noarchive_debug')
525 if not buildconfig.get('test_mod'): cmd.append('--notest_mod') 526 if not buildconfig.get('test_mod'): cmd.append('--notest_mod')
526 if test_tarball: cmd.extend(['--test_tarball', test_tarball]) 527 if test_tarball: cmd.extend(['--test_tarball', test_tarball])
527 if debug: cmd.append('--debug') 528 if debug: cmd.append('--debug')
528 if buildconfig.get('factory_install_mod', True): 529 if buildconfig.get('factory_install_mod', True):
529 cmd.append('--factory_install_mod') 530 cmd.append('--factory_install_mod')
530 531
531 OldRunCommand(cmd, cwd=cwd) 532 try:
533 result = RunCommand(cmd, cwd=cwd, redirect_stdout=True,
petkov 2011/02/17 19:31:14 Does this print the command? If not, can you Info
534 redirect_stderr=True, combine_stdout_stderr=True)
535 except:
536 Warning(result.stdout)
537 raise
538
539 archive_url = None
540 key_re = re.compile('^%s=(.*)$' % _CROS_ARCHIVE_URL)
541 for line in result.output.splitlines():
542 line_match = key_re.match(line)
543 if line_match:
544 archive_url = line_match.group(1)
545
546 assert archive_url, 'Archive Build Failed to Provide Archive URL'
547 return archive_url
532 548
533 549
534 def _ArchiveTestResults(buildroot, test_results_dir): 550 def _ArchiveTestResults(buildroot, test_results_dir):
535 """Archives the test results into a tarball and returns a path to it. 551 """Archives the test results into a tarball and returns a path to it.
536 552
537 Arguments: 553 Arguments:
538 buildroot: Root directory where build occurs 554 buildroot: Root directory where build occurs
539 test_results_dir: Path from buildroot/chroot to find test results. 555 test_results_dir: Path from buildroot/chroot to find test results.
540 This must a subdir of /tmp. 556 This must a subdir of /tmp.
541 Returns: 557 Returns:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 parser.add_option('-u', '--url', dest='url', 695 parser.add_option('-u', '--url', dest='url',
680 default='http://git.chromium.org/git/manifest', 696 default='http://git.chromium.org/git/manifest',
681 help='Run the buildbot on internal manifest') 697 help='Run the buildbot on internal manifest')
682 698
683 (options, args) = parser.parse_args() 699 (options, args) = parser.parse_args()
684 700
685 buildroot = os.path.abspath(options.buildroot) 701 buildroot = os.path.abspath(options.buildroot)
686 revisionfile = options.revisionfile 702 revisionfile = options.revisionfile
687 tracking_branch = options.tracking_branch 703 tracking_branch = options.tracking_branch
688 chrome_atom_to_build = None 704 chrome_atom_to_build = None
705 archive_url = None
689 706
690 if len(args) >= 1: 707 if len(args) >= 1:
691 bot_id = args[-1] 708 bot_id = args[-1]
692 buildconfig = _GetConfig(bot_id) 709 buildconfig = _GetConfig(bot_id)
693 else: 710 else:
694 Warning('Missing configuration description') 711 Warning('Missing configuration description')
695 parser.print_usage() 712 parser.print_usage()
696 sys.exit(1) 713 sys.exit(1)
697 714
698 try: 715 try:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 776
760 if buildconfig['vm_tests'] and options.tests: 777 if buildconfig['vm_tests'] and options.tests:
761 _BuildVMImageForTesting(buildroot) 778 _BuildVMImageForTesting(buildroot)
762 test_results_dir = '/tmp/run_remote_tests.%s' % options.buildnumber 779 test_results_dir = '/tmp/run_remote_tests.%s' % options.buildnumber
763 try: 780 try:
764 _RunSmokeSuite(buildroot, test_results_dir) 781 _RunSmokeSuite(buildroot, test_results_dir)
765 _RunAUTest(buildroot, buildconfig['board']) 782 _RunAUTest(buildroot, buildconfig['board'])
766 finally: 783 finally:
767 test_tarball = _ArchiveTestResults(buildroot, 784 test_tarball = _ArchiveTestResults(buildroot,
768 test_results_dir=test_results_dir) 785 test_results_dir=test_results_dir)
769 _LegacyArchiveBuild(buildroot, bot_id, buildconfig, options.buildnumber, 786 archive_url = _LegacyArchiveBuild(buildroot, bot_id, buildconfig,
770 test_tarball, options.debug) 787 options.buildnumber, test_tarball,
788 options.debug)
771 789
772 # Don't push changes for developers. 790 # Don't push changes for developers.
773 if buildconfig['master']: 791 if buildconfig['master']:
774 # Master bot needs to check if the other slaves completed. 792 # Master bot needs to check if the other slaves completed.
775 if cbuildbot_comm.HaveSlavesCompleted(config): 793 if cbuildbot_comm.HaveSlavesCompleted(config):
776 if not options.debug and options.prebuilts: 794 if not options.debug and options.prebuilts:
777 _UploadPrebuilts(buildroot, board, buildconfig['rev_overlays'], 795 _UploadPrebuilts(buildroot, board, buildconfig['rev_overlays'],
778 [new_binhost], options.chrome_rev) 796 [new_binhost], options.chrome_rev)
779 _UprevPush(buildroot, tracking_branch, buildconfig['board'], 797 _UprevPush(buildroot, tracking_branch, buildconfig['board'],
780 push_overlays, options.debug) 798 push_overlays, options.debug)
781 else: 799 else:
782 Die('CBUILDBOT - One of the slaves has failed!!!') 800 Die('CBUILDBOT - One of the slaves has failed!!!')
783 801
784 else: 802 else:
785 # Publish my status to the master if its expecting it. 803 # Publish my status to the master if its expecting it.
786 if buildconfig['important'] and not options.debug: 804 if buildconfig['important'] and not options.debug:
787 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) 805 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE)
788 806
789 except: 807 except:
790 # Send failure to master bot. 808 # Send failure to master bot.
791 if not buildconfig['master'] and buildconfig['important']: 809 if not buildconfig['master'] and buildconfig['important']:
792 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) 810 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED)
793 811
794 raise 812 raise
795 813
814 finally:
815 if archive_url:
816 Info('BUILD ARTIFACTS FOR THIS BUILD CAN BE FOUND AT:')
817 Info(archive_url)
818
796 819
797 if __name__ == '__main__': 820 if __name__ == '__main__':
798 main() 821 main()
OLDNEW
« no previous file with comments | « no previous file | lib/cros_build_lib.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698