Changeset 988 for vendor/current/script/autobuild.py
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/script/autobuild.py
r740 r988 8 8 from optparse import OptionParser 9 9 import smtplib 10 import email 10 11 from email.mime.text import MIMEText 11 12 samba_master = os.getenv('SAMBA_MASTER', 'git://git.samba.org/samba.git') 13 samba_master_ssh = os.getenv('SAMBA_MASTER_SSH', 'git+ssh://git.samba.org/data/git/samba.git') 12 from email.mime.base import MIMEBase 13 from email.mime.application import MIMEApplication 14 from email.mime.multipart import MIMEMultipart 15 from distutils.sysconfig import get_python_lib 16 import platform 17 18 # This speeds up testing remarkably. 19 os.environ['TDB_NO_FSYNC'] = '1' 14 20 15 21 cleanup_list = [] 16 22 17 os.environ['CC'] = "ccache gcc"18 19 23 builddirs = { 20 "samba3" : "source3", 21 "samba3-waf": "source3", 22 "samba4" : ".", 23 "ldb" : "source4/lib/ldb", 24 "ctdb" : "ctdb", 25 "samba" : ".", 26 "samba-xc" : ".", 27 "samba-ctdb" : ".", 28 "samba-libs" : ".", 29 "samba-static" : ".", 30 "ldb" : "lib/ldb", 24 31 "tdb" : "lib/tdb", 25 32 "talloc" : "lib/talloc", … … 32 39 } 33 40 34 defaulttasks = [ "samba3", "samba3-waf", "samba4", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ] 41 defaulttasks = [ "ctdb", "samba", "samba-xc", "samba-ctdb", "samba-libs", "samba-static", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ] 42 43 samba_configure_params = " --picky-developer ${PREFIX} --with-profiling-data" 44 45 samba_libs_envvars = "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH" 46 samba_libs_envvars += " PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig" 47 samba_libs_envvars += " ADDITIONAL_CFLAGS='-Wmissing-prototypes'" 48 samba_libs_configure_base = samba_libs_envvars + " ./configure --abi-check --enable-debug --picky-developer -C ${PREFIX}" 49 samba_libs_configure_libs = samba_libs_configure_base + " --bundled-libraries=NONE" 50 samba_libs_configure_samba = samba_libs_configure_base + " --bundled-libraries=!talloc,!pytalloc-util,!tdb,!pytdb,!ldb,!pyldb,!pyldb-util,!tevent,!pytevent" 35 51 36 52 tasks = { 37 "samba3" : [ ("autogen", "./autogen.sh", "text/plain"), 38 ("configure", "./configure.developer ${PREFIX}", "text/plain"), 39 ("make basics", "make basics", "text/plain"), 40 ("make", "make -j 4 everything", "text/plain"), # don't use too many processes 41 ("install", "make install", "text/plain"), 42 ("test", "TDB_NO_FSYNC=1 make test FAIL_IMMEDIATELY=1", "text/plain"), 43 ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"), 44 ("clean", "make clean", "text/plain") ], 45 46 "samba3-waf" : [ ("autogen", "./autogen-waf.sh", "text/plain"), 47 ("configure", "./configure.developer ${PREFIX}", "text/plain"), 48 ("make", "make -j", "text/plain"), 49 ("install", "make install", "text/plain"), 50 ("clean", "make clean", "text/plain") ], 53 "ctdb" : [ ("random-sleep", "../script/random-sleep.sh 60 600", "text/plain"), 54 ("configure", "./configure ${PREFIX}", "text/plain"), 55 ("make", "make all", "text/plain"), 56 ("install", "make install", "text/plain"), 57 ("test", "make autotest", "text/plain"), 58 ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"), 59 ("clean", "make clean", "text/plain") ], 51 60 52 61 # We have 'test' before 'install' because, 'test' should work without 'install' 53 "samba4" : [ ("configure", "./configure.developer ${PREFIX}", "text/plain"), 54 ("make", "make -j", "text/plain"), 55 ("test", "TDB_NO_FSYNC=1 make test FAIL_IMMEDIATELY=1", "text/plain"), 56 ("install", "make install", "text/plain"), 57 ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"), 58 ("clean", "make clean", "text/plain") ], 59 60 "ldb" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 61 ("make", "make -j", "text/plain"), 62 ("install", "make install", "text/plain"), 63 ("test", "TDB_NO_FSYNC=1 make test", "text/plain"), 64 ("check-clean-tree", "../../../script/clean-source-tree.sh", "text/plain"), 65 ("distcheck", "make distcheck", "text/plain"), 66 ("clean", "make clean", "text/plain") ], 67 68 # We don't use TDB_NO_FSYNC=1 here, because we want to test the transaction code 69 "tdb" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 70 ("make", "make -j", "text/plain"), 62 "samba" : [ ("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params, "text/plain"), 63 ("make", "make -j", "text/plain"), 64 ("test", "make test FAIL_IMMEDIATELY=1", "text/plain"), 65 ("install", "make install", "text/plain"), 66 ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"), 67 ("clean", "make clean", "text/plain") ], 68 69 # Test cross-compile infrastructure 70 "samba-xc" : [ ("configure-native", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params, "text/plain"), 71 ("configure-cross-execute", "./configure.developer -b ./bin-xe --cross-compile --cross-execute=script/identity_cc.sh" \ 72 " --cross-answers=./bin-xe/cross-answers.txt --with-selftest-prefix=./bin-xe/ab" + samba_configure_params, "text/plain"), 73 ("configure-cross-answers", "./configure.developer -b ./bin-xa --cross-compile" \ 74 " --cross-answers=./bin-xe/cross-answers.txt --with-selftest-prefix=./bin-xa/ab" + samba_configure_params, "text/plain"), 75 ("compare-results", "script/compare_cc_results.py ./bin/c4che/default.cache.py ./bin-xe/c4che/default.cache.py ./bin-xa/c4che/default.cache.py", "text/plain")], 76 77 78 "samba-ctdb" : [ ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"), 79 80 # make sure we have tdb around: 81 ("tdb-configure", "cd lib/tdb && PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --abi-check --enable-debug -C ${PREFIX}", "text/plain"), 82 ("tdb-make", "cd lib/tdb && make", "text/plain"), 83 ("tdb-install", "cd lib/tdb && make install", "text/plain"), 84 85 86 # build samba with cluster support (also building ctdb): 87 ("samba-configure", "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH} ./configure.developer --picky-developer ${PREFIX} --with-selftest-prefix=./bin/ab --with-cluster-support --bundled-libraries=!tdb", "text/plain"), 88 ("samba-make", "make", "text/plain"), 89 ("samba-check", "./bin/smbd -b | grep CLUSTER_SUPPORT", "text/plain"), 90 ("samba-install", "make install", "text/plain"), 91 ("ctdb-check", "test -e ${PREFIX_DIR}/sbin/ctdbd", "text/plain"), 92 93 # clean up: 94 ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"), 95 ("clean", "make clean", "text/plain"), 96 ("ctdb-clean", "cd ./ctdb && make clean", "text/plain") ], 97 98 "samba-libs" : [ 99 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"), 100 ("talloc-configure", "cd lib/talloc && " + samba_libs_configure_libs, "text/plain"), 101 ("talloc-make", "cd lib/talloc && make", "text/plain"), 102 ("talloc-install", "cd lib/talloc && make install", "text/plain"), 103 104 ("tdb-configure", "cd lib/tdb && " + samba_libs_configure_libs, "text/plain"), 105 ("tdb-make", "cd lib/tdb && make", "text/plain"), 106 ("tdb-install", "cd lib/tdb && make install", "text/plain"), 107 108 ("tevent-configure", "cd lib/tevent && " + samba_libs_configure_libs, "text/plain"), 109 ("tevent-make", "cd lib/tevent && make", "text/plain"), 110 ("tevent-install", "cd lib/tevent && make install", "text/plain"), 111 112 ("ldb-configure", "cd lib/ldb && " + samba_libs_configure_libs, "text/plain"), 113 ("ldb-make", "cd lib/ldb && make", "text/plain"), 114 ("ldb-install", "cd lib/ldb && make install", "text/plain"), 115 116 ("nondevel-configure", "./configure ${PREFIX}", "text/plain"), 117 ("nondevel-make", "make -j", "text/plain"), 118 ("nondevel-check", "./bin/smbd -b | grep WITH_NTVFS_FILESERVER && exit 1; exit 0", "text/plain"), 119 ("nondevel-install", "make install", "text/plain"), 120 ("nondevel-dist", "make dist", "text/plain"), 121 122 # retry with all modules shared 123 ("allshared-distclean", "make distclean", "text/plain"), 124 ("allshared-configure", samba_libs_configure_samba + " --with-shared-modules=ALL", "text/plain"), 125 ("allshared-make", "make -j", "text/plain")], 126 127 "samba-static" : [ 128 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"), 129 # build with all modules static 130 ("allstatic-configure", "./configure.developer " + samba_configure_params + " --with-static-modules=ALL", "text/plain"), 131 ("allstatic-make", "make -j", "text/plain"), 132 133 # retry without any required modules 134 ("none-distclean", "make distclean", "text/plain"), 135 ("none-configure", "./configure.developer " + samba_configure_params + " --with-static-modules=!FORCED,!DEFAULT --with-shared-modules=!FORCED,!DEFAULT", "text/plain"), 136 ("none-make", "make -j", "text/plain"), 137 138 # retry with nonshared smbd and smbtorture 139 ("nonshared-distclean", "make distclean", "text/plain"), 140 ("nonshared-configure", "./configure.developer " + samba_configure_params + " --bundled-libraries=talloc,tdb,pytdb,ldb,pyldb,tevent,pytevent --with-static-modules=ALL --nonshared-binary=smbtorture,smbd/smbd", "text/plain"), 141 ("nonshared-make", "make -j", "text/plain")], 142 143 "ldb" : [ 144 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"), 145 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 146 ("make", "make", "text/plain"), 71 147 ("install", "make install", "text/plain"), 72 148 ("test", "make test", "text/plain"), … … 75 151 ("clean", "make clean", "text/plain") ], 76 152 77 "talloc" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 78 ("make", "make -j", "text/plain"), 153 "tdb" : [ 154 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"), 155 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 156 ("make", "make", "text/plain"), 157 ("install", "make install", "text/plain"), 158 ("test", "make test", "text/plain"), 159 ("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"), 160 ("distcheck", "make distcheck", "text/plain"), 161 ("clean", "make clean", "text/plain") ], 162 163 "talloc" : [ 164 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"), 165 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 166 ("make", "make", "text/plain"), 79 167 ("install", "make install", "text/plain"), 80 168 ("test", "make test", "text/plain"), … … 83 171 ("clean", "make clean", "text/plain") ], 84 172 85 "replace" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 86 ("make", "make -j", "text/plain"), 173 "replace" : [ 174 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"), 175 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 176 ("make", "make", "text/plain"), 87 177 ("install", "make install", "text/plain"), 88 178 ("test", "make test", "text/plain"), … … 91 181 ("clean", "make clean", "text/plain") ], 92 182 93 "tevent" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 94 ("make", "make -j", "text/plain"), 183 "tevent" : [ 184 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"), 185 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"), 186 ("make", "make", "text/plain"), 95 187 ("install", "make install", "text/plain"), 96 188 ("test", "make test", "text/plain"), … … 99 191 ("clean", "make clean", "text/plain") ], 100 192 101 "pidl" : [ ("configure", "perl Makefile.PL PREFIX=${PREFIX_DIR}", "text/plain"), 193 "pidl" : [ 194 ("random-sleep", "../script/random-sleep.sh 60 600", "text/plain"), 195 ("configure", "perl Makefile.PL PREFIX=${PREFIX_DIR}", "text/plain"), 102 196 ("touch", "touch *.yp", "text/plain"), 103 197 ("make", "make", "text/plain"), 104 198 ("test", "make test", "text/plain"), 105 199 ("install", "make install", "text/plain"), 200 ("checkout-yapp-generated", "git checkout lib/Parse/Pidl/IDL.pm lib/Parse/Pidl/Expr.pm", "text/plain"), 106 201 ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"), 107 202 ("clean", "make clean", "text/plain") ], … … 111 206 'fail' : [ ("fail", 'echo failing && /bin/false', "text/plain") ] 112 207 } 113 114 retry_task = [ ( "retry",115 '''set -e116 git remote add -t master master %s117 git fetch master118 while :; do119 sleep 60120 git describe master/master > old_master.desc121 git fetch master122 git describe master/master > master.desc123 diff old_master.desc master.desc124 done125 ''' % samba_master, "test/plain" ) ]126 208 127 209 def run_cmd(cmd, dir=".", show=None, output=False, checkfail=True): … … 141 223 '''handle build of one directory''' 142 224 143 def __init__(self, name, sequence ):225 def __init__(self, name, sequence, cp=True): 144 226 self.name = name 145 227 self.dir = builddirs[name] … … 164 246 os.makedirs(self.sdir) 165 247 run_cmd("rm -rf %s" % self.sdir) 166 run_cmd("git clone --shared %s %s" % (test_master, self.sdir), dir=test_master, show=True) 248 if cp: 249 run_cmd("cp --recursive --link --archive %s %s" % (test_master, self.sdir), dir=test_master, show=True) 250 else: 251 run_cmd("git clone --recursive --shared %s %s" % (test_master, self.sdir), dir=test_master, show=True) 167 252 self.start_next() 168 253 … … 173 258 return 174 259 (self.stage, self.cmd, self.output_mime_type) = self.sequence[self.next] 260 self.cmd = self.cmd.replace("${PYTHON_PREFIX}", get_python_lib(standard_lib=1, prefix=self.prefix)) 175 261 self.cmd = self.cmd.replace("${PREFIX}", "--prefix=%s" % self.prefix) 176 262 self.cmd = self.cmd.replace("${PREFIX_DIR}", "%s" % self.prefix) … … 189 275 '''handle build of multiple directories''' 190 276 191 def __init__(self, tasklist, tasknames ):277 def __init__(self, tasklist, tasknames, rebase_url, rebase_branch="master"): 192 278 global tasks 193 279 self.tlist = [] … … 196 282 if tasknames == []: 197 283 tasknames = defaulttasks 284 else: 285 # If we are only running one test, 286 # do not sleep randomly to wait for it to start 287 os.environ['AUTOBUILD_RANDOM_SLEEP_OVERRIDE'] = '1' 288 198 289 for n in tasknames: 199 b = builder(n, tasks[n] )290 b = builder(n, tasks[n], cp=n is not "pidl") 200 291 self.tlist.append(b) 201 292 if options.retry: 202 self.retry = builder('retry', retry_task) 293 rebase_remote = "rebaseon" 294 retry_task = [ ("retry", 295 '''set -e 296 git remote add -t %s %s %s 297 git fetch %s 298 while :; do 299 sleep 60 300 git describe %s/%s > old_remote_branch.desc 301 git fetch %s 302 git describe %s/%s > remote_branch.desc 303 diff old_remote_branch.desc remote_branch.desc 304 done 305 ''' % ( 306 rebase_branch, rebase_remote, rebase_url, 307 rebase_remote, 308 rebase_remote, rebase_branch, 309 rebase_remote, 310 rebase_remote, rebase_branch 311 ), 312 "test/plain" ) ] 313 314 self.retry = builder('retry', retry_task, cp=False) 203 315 self.need_retry = False 204 316 … … 257 369 return (0, None, None, None, "All OK") 258 370 371 def write_system_info(self): 372 filename = 'system-info.txt' 373 f = open(filename, 'w') 374 for cmd in ['uname -a', 'free', 'cat /proc/cpuinfo']: 375 print >>f, '### %s' % cmd 376 print >>f, run_cmd(cmd, output=True, checkfail=False) 377 print >>f 378 f.close() 379 return filename 380 259 381 def tarlogs(self, fname): 260 382 tar = tarfile.open(fname, "w:gz") … … 264 386 if os.path.exists("autobuild.log"): 265 387 tar.add("autobuild.log") 388 sys_info = self.write_system_info() 389 tar.add(sys_info) 266 390 tar.close() 267 391 … … 327 451 328 452 329 def rebase_tree(url): 330 print("Rebasing on %s" % url) 453 def rebase_tree(rebase_url, rebase_branch = "master"): 454 rebase_remote = "rebaseon" 455 print("Rebasing on %s" % rebase_url) 331 456 run_cmd("git describe HEAD", show=True, dir=test_master) 332 run_cmd("git remote add -t master master %s" % url, show=True, dir=test_master) 333 run_cmd("git fetch master", show=True, dir=test_master) 457 run_cmd("git remote add -t %s %s %s" % 458 (rebase_branch, rebase_remote, rebase_url), 459 show=True, dir=test_master) 460 run_cmd("git fetch %s" % rebase_remote, show=True, dir=test_master) 334 461 if options.fix_whitespace: 335 run_cmd("git rebase --whitespace=fix master/master", show=True, dir=test_master) 462 run_cmd("git rebase --force-rebase --whitespace=fix %s/%s" % 463 (rebase_remote, rebase_branch), 464 show=True, dir=test_master) 336 465 else: 337 run_cmd("git rebase master/master", show=True, dir=test_master) 338 diff = run_cmd("git --no-pager diff HEAD master/master", dir=test_master, output=True) 466 run_cmd("git rebase --force-rebase %s/%s" % 467 (rebase_remote, rebase_branch), 468 show=True, dir=test_master) 469 diff = run_cmd("git --no-pager diff HEAD %s/%s" % 470 (rebase_remote, rebase_branch), 471 dir=test_master, output=True) 339 472 if diff == '': 340 print("No differences between HEAD and master/master - exiting") 473 print("No differences between HEAD and %s/%s - exiting" % 474 (rebase_remote, rebase_branch)) 341 475 sys.exit(0) 342 run_cmd("git describe master/master", show=True, dir=test_master) 476 run_cmd("git describe %s/%s" % 477 (rebase_remote, rebase_branch), 478 show=True, dir=test_master) 343 479 run_cmd("git describe HEAD", show=True, dir=test_master) 344 run_cmd("git --no-pager diff --stat HEAD master/master", show=True, dir=test_master) 345 346 def push_to(url): 347 print("Pushing to %s" % url) 480 run_cmd("git --no-pager diff --stat HEAD %s/%s" % 481 (rebase_remote, rebase_branch), 482 show=True, dir=test_master) 483 484 def push_to(push_url, push_branch = "master"): 485 push_remote = "pushto" 486 print("Pushing to %s" % push_url) 348 487 if options.mark: 349 488 run_cmd("git config --replace-all core.editor script/commit_mark.sh", dir=test_master) … … 351 490 # the notes method doesn't work yet, as metze hasn't allowed refs/notes/* in master 352 491 # run_cmd("EDITOR=script/commit_mark.sh git notes edit HEAD", dir=test_master) 353 run_cmd("git remote add -t master pushto %s" % url, show=True, dir=test_master) 354 run_cmd("git push pushto +HEAD:master", show=True, dir=test_master) 492 run_cmd("git remote add -t %s %s %s" % 493 (push_branch, push_remote, push_url), 494 show=True, dir=test_master) 495 run_cmd("git push %s +HEAD:%s" % 496 (push_remote, push_branch), 497 show=True, dir=test_master) 355 498 356 499 def_testbase = os.getenv("AUTOBUILD_TESTBASE", "/memdisk/%s" % os.getenv('USER')) 500 501 gitroot = find_git_root() 502 if gitroot is None: 503 raise Exception("Failed to find git root") 357 504 358 505 parser = OptionParser() … … 367 514 parser.add_option("", "--rebase", help="rebase on the given tree before testing", 368 515 default=None, type='str') 369 parser.add_option("", "--rebase-master", help="rebase on %s before testing" % samba_master,370 default=False, action='store_true')371 516 parser.add_option("", "--pushto", help="push to a git url on success", 372 517 default=None, type='str') 373 parser.add_option("", "--push-master", help="push to %s on success" % samba_master_ssh,374 default=False, action='store_true')375 518 parser.add_option("", "--mark", help="add a Tested-By signoff before pushing", 376 519 default=False, action="store_true") … … 381 524 parser.add_option("", "--email", help="send email to the given address on failure", 382 525 type='str', default=None) 526 parser.add_option("", "--email-from", help="send email from the given address", 527 type='str', default="autobuild@samba.org") 528 parser.add_option("", "--email-server", help="send email via the given server", 529 type='str', default='localhost') 383 530 parser.add_option("", "--always-email", help="always send email, even on success", 384 531 action="store_true") 385 532 parser.add_option("", "--daemon", help="daemonize after initial setup", 386 533 action="store_true") 387 388 389 def email_failure(status, failed_task, failed_stage, failed_tag, errstr): 534 parser.add_option("", "--branch", help="the branch to work on (default=master)", 535 default="master", type='str') 536 parser.add_option("", "--log-base", help="location where the logs can be found (default=cwd)", 537 default=gitroot, type='str') 538 parser.add_option("", "--attach-logs", help="Attach logs to mails sent on success/failure?", 539 default=False, action="store_true") 540 541 def send_email(subject, text, log_tar): 542 outer = MIMEMultipart() 543 outer['Subject'] = subject 544 outer['To'] = options.email 545 outer['From'] = options.email_from 546 outer['Date'] = email.utils.formatdate(localtime = True) 547 outer.preamble = 'Autobuild mails are now in MIME because we optionally attach the logs.\n' 548 outer.attach(MIMEText(text, 'plain')) 549 if options.attach_logs: 550 fp = open(log_tar, 'rb') 551 msg = MIMEApplication(fp.read(), 'gzip', email.encoders.encode_base64) 552 fp.close() 553 # Set the filename parameter 554 msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(log_tar)) 555 outer.attach(msg) 556 content = outer.as_string() 557 s = smtplib.SMTP(options.email_server) 558 s.sendmail(options.email_from, [options.email], content) 559 s.set_debuglevel(1) 560 s.quit() 561 562 def email_failure(status, failed_task, failed_stage, failed_tag, errstr, 563 elapsed_time, log_base=None): 390 564 '''send an email to options.email about the failure''' 565 elapsed_minutes = elapsed_time / 60.0 391 566 user = os.getenv("USER") 567 if log_base is None: 568 log_base = gitroot 392 569 text = ''' 393 570 Dear Developer, 394 571 395 Your autobuild failed when trying to test %s with the following error: 572 Your autobuild on %s failed after %.1f minutes 573 when trying to test %s with the following error: 574 396 575 %s 397 576 … … 400 579 A summary of the autobuild process is here: 401 580 402 http://git.samba.org/%s/samba-autobuild/autobuild.log403 ''' % ( failed_task, errstr, user)404 581 %s/autobuild.log 582 ''' % (platform.node(), elapsed_minutes, failed_task, errstr, log_base) 583 405 584 if failed_task != 'rebase': 406 585 text += ''' 407 586 You can see logs of the failed task here: 408 587 409 http://git.samba.org/%s/samba-autobuild/%s.stdout410 http://git.samba.org/%s/samba-autobuild/%s.stderr588 %s/%s.stdout 589 %s/%s.stderr 411 590 412 591 or you can get full logs of all tasks in this job here: 413 592 414 http://git.samba.org/%s/samba-autobuild/logs.tar.gz593 %s/logs.tar.gz 415 594 416 595 The top commit for the tree that was built was: … … 418 597 %s 419 598 420 ''' % (user, failed_tag, user, failed_tag, user, top_commit_msg) 421 msg = MIMEText(text) 422 msg['Subject'] = 'autobuild failure for task %s during %s' % (failed_task, failed_stage) 423 msg['From'] = 'autobuild@samba.org' 424 msg['To'] = options.email 425 426 s = smtplib.SMTP() 427 s.connect() 428 s.sendmail(msg['From'], [msg['To']], msg.as_string()) 429 s.quit() 430 431 def email_success(): 599 ''' % (log_base, failed_tag, log_base, failed_tag, log_base, top_commit_msg) 600 601 logs = os.path.join(gitroot, 'logs.tar.gz') 602 send_email('autobuild failure on %s for task %s during %s' 603 % (platform.node(), failed_task, failed_stage), 604 text, logs) 605 606 def email_success(elapsed_time, log_base=None): 432 607 '''send an email to options.email about a successful build''' 433 608 user = os.getenv("USER") 609 if log_base is None: 610 log_base = gitroot 434 611 text = ''' 435 612 Dear Developer, 436 613 437 Your autobuild has succeeded.438 439 ''' 614 Your autobuild on %s has succeeded after %.1f minutes. 615 616 ''' % (platform.node(), elapsed_time / 60.) 440 617 441 618 if options.keeplogs: … … 444 621 you can get full logs of all tasks in this job here: 445 622 446 http://git.samba.org/%s/samba-autobuild/logs.tar.gz447 448 ''' % user623 %s/logs.tar.gz 624 625 ''' % log_base 449 626 450 627 text += ''' … … 454 631 ''' % top_commit_msg 455 632 456 msg = MIMEText(text) 457 msg['Subject'] = 'autobuild success' 458 msg['From'] = 'autobuild@samba.org' 459 msg['To'] = options.email 460 461 s = smtplib.SMTP() 462 s.connect() 463 s.sendmail(msg['From'], [msg['To']], msg.as_string()) 464 s.quit() 633 logs = os.path.join(gitroot, 'logs.tar.gz') 634 send_email('autobuild sucess on %s ' % platform.node(), 635 text, logs) 465 636 466 637 … … 468 639 469 640 if options.retry: 470 if not options.rebase_master andoptions.rebase is None:641 if options.rebase is None: 471 642 raise Exception('You can only use --retry if you also rebase') 472 643 473 644 testbase = "%s/b%u" % (options.testbase, os.getpid()) 474 645 test_master = "%s/master" % testbase 475 476 gitroot = find_git_root()477 if gitroot is None:478 raise Exception("Failed to find git root")479 646 480 647 # get the top commit message, for emails … … 494 661 write_pidfile(gitroot + "/autobuild.pid") 495 662 663 start_time = time.time() 664 496 665 while True: 497 666 try: 498 667 run_cmd("rm -rf %s" % test_master) 499 668 cleanup_list.append(test_master) 500 run_cmd("git clone -- shared %s %s" % (gitroot, test_master), show=True, dir=gitroot)501 except :669 run_cmd("git clone --recursive --shared %s %s" % (gitroot, test_master), show=True, dir=gitroot) 670 except Exception: 502 671 cleanup() 503 672 raise … … 506 675 try: 507 676 if options.rebase is not None: 508 rebase_tree(options.rebase) 509 elif options.rebase_master: 510 rebase_tree(samba_master) 511 except: 512 email_failure(-1, 'rebase', 'rebase', 'rebase', 'rebase on master failed') 677 rebase_tree(options.rebase, rebase_branch=options.branch) 678 except Exception: 679 cleanup_list.append(gitroot + "/autobuild.pid") 680 cleanup() 681 elapsed_time = time.time() - start_time 682 email_failure(-1, 'rebase', 'rebase', 'rebase', 683 'rebase on %s failed' % options.branch, 684 elapsed_time, log_base=options.log_base) 513 685 sys.exit(1) 514 blist = buildlist(tasks, args )686 blist = buildlist(tasks, args, options.rebase, rebase_branch=options.branch) 515 687 if options.tail: 516 688 blist.start_tail() … … 519 691 break 520 692 cleanup() 521 except :693 except Exception: 522 694 cleanup() 523 695 raise … … 530 702 time.sleep(1) 531 703 704 elapsed_time = time.time() - start_time 532 705 if status == 0: 533 706 print errstr … … 536 709 run_cmd(options.passcmd, dir=test_master) 537 710 if options.pushto is not None: 538 push_to(options.pushto) 539 elif options.push_master: 540 push_to(samba_master_ssh) 541 if options.keeplogs: 711 push_to(options.pushto, push_branch=options.branch) 712 if options.keeplogs or options.attach_logs: 542 713 blist.tarlogs("logs.tar.gz") 543 714 print("Logs in logs.tar.gz") 544 715 if options.always_email: 545 email_success( )716 email_success(elapsed_time, log_base=options.log_base) 546 717 blist.remove_logs() 547 718 cleanup() … … 553 724 554 725 if options.email is not None: 555 email_failure(status, failed_task, failed_stage, failed_tag, errstr) 726 email_failure(status, failed_task, failed_stage, failed_tag, errstr, 727 elapsed_time, log_base=options.log_base) 728 else: 729 elapsed_minutes = elapsed_time / 60.0 730 print ''' 731 732 #################################################################### 733 734 AUTOBUILD FAILURE 735 736 Your autobuild on %s failed after %.1f minutes 737 when trying to test %s with the following error: 738 739 %s 740 741 the autobuild has been abandoned. Please fix the error and resubmit. 742 743 #################################################################### 744 745 ''' % (platform.node(), elapsed_minutes, failed_task, errstr) 556 746 557 747 cleanup()
Note:
See TracChangeset
for help on using the changeset viewer.