def add_component(comp, sb): aspects = get_vcs_component_aspects(comp, sb) for a in aspects: path = sb.get_component_path(comp, a) txt = vcs.add(path) if txt: print(txt)
def _check_remoting_info(): if sadm_prompt.prompter.get_mode() == sadm_prompt.AUTOCONFIRM_MODE: return if not config.needs_remoting_info(): return descr = buildinfo.BuildInfo() remoteInfo = '' print(''' Machines that automate sandbox operations should be remotely accessible for configuration and troubleshooting purposes. Please provide the following information to facilitate this. ''') config.username_for_remote_access = sadm_prompt.prompt('Username for remote login', config.username_for_remote_access) config.ipaddr = sadm_prompt.prompt('IP address', config.ipaddr) config.ssh_port = sadm_prompt.prompt('Port for ssh', config.ssh_port) config.remote_desktop_port = sadm_prompt.prompt('Port for remote desktop', config.remote_desktop_port) config.remoting_instructions = sadm_prompt.prompt(''' Other instructions for accessing this machine remotely (such as where to get the password etc.)''', config.remoting_instructions) if config.ssh_port: remoteInfo += 'ssh to %s:%s as %s\n' % (config.ipaddr, config.ssh_port, config.username_for_remote_access) if config.remote_desktop_port: remoteInfo += 'remote desktop to %s:%s\n' % (config.ipaddr, config.remote_desktop_port) if config.remoting_instructions: remoteInfo += '%s' % config.remoting_instructions build_machines = tempfile.mkdtemp() wr = vcs.get_working_repository() vcs.checkout(os.path.join(wr.master_reporoot, 'BuildMachines').replace('\\','/'), build_machines) if os.name == 'nt': site = os.environ['COMPUTERNAME'].lower() else: site = os.environ['HOSTNAME'].lower() fldr = os.path.join(build_machines, site) if not os.path.isdir(fldr): os.makedirs(fldr) fp = open(os.path.join(fldr, REMOTE_INFO_FILE), 'w') fp.write(remoteInfo) fp.close() vcs.add(build_machines) try: vcs.checkin(build_machines, 'Update remote info for %s' % site, quiet=True) except: pass
def test_dependencies(self): tmpdir = tempfile.mkdtemp() #print('running test in temporary repo %s' % tmpdir) cwd = os.getcwd() try: template1 = '[%s]' % metadata.DEPENDENCIES_SECTION template2 = template1 + ''' %s: code,%s.trunk.1.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' template3 = template1 + ''' %s: code,%s.trunk.2.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' files = { 'a': template2 % ('b', 'b', 'c', 'c'), 'b': template1, 'c': template3 % ('b', 'b', 'd', 'd'), 'd': template1 } testRepos = ['a', 'b', 'c', 'd'] for t in testRepos: repoPath = os.path.join(tmpdir, 'trunk', t) os.makedirs(os.path.join(tmpdir, 'trunk', t)) branchPath = repoPath + '/code' #print('init %s' % branchPath) vcs.init(branchPath, False) filePath = branchPath + '/' + metadata.METADATA_FILE save(filePath, files[t]) os.chdir(branchPath) #print('adding %s' % filePath) vcs.add(filePath) #print('checking in %s' % filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.1.1 use: reusable' % t) if t == 'b': #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) filePath = branchPath + '/dependencies2.txt' save(filePath, files[t]) vcs.add(filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.2.1 use: reusable' % t) #subprocess.Popen(['bzr', 'tags']) working_repo = vcs.WorkingRepository() working_repo._init(tmpdir, tmpdir, tmpdir) prob = metadata.get_components_inv_dep_order(working_repo, 'win_x64', 'a', tmpdir, 'trunk', '') comp = [ component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable', 'code'), component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable', 'code'), component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable', 'code'), component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable', 'code') ] if False: for c in comp: print("comp = " + str(c)) for c in prob: print("prob = " + str(c)) # prob will have buildscripts; comp doesn't prob = [p for p in prob if p.name != 'buildscripts'] self.assertEquals(len(comp), len(prob)) for i in range(len(comp)): self.assertEquals(comp[i].name, prob[i].name) finally: os.chdir(cwd) shutil.rmtree(tmpdir)
def report(sb, state): rr = sb.get_report_root() root = sb.get_root() need_checkin = vcs.folder_is_tied_to_vcs(rr) try: # Get latest version of reports so we are less likely to cause merge # conflicts. wr = vcs.get_working_repository() use_master = False if not need_checkin: url = os.path.join( wr.master_reporoot, sb.get_branch(), sb.get_top_component(), 'report', ).replace('\\', '/') publish.create_branch(url, False) use_master = True wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=use_master) need_checkin = vcs.folder_is_tied_to_vcs(rr) # Report our results. bi = buildinfo.BuildInfo() machineFolder = os.path.join(rr, bi.host).replace('\\', '/') summary = EvalSummary(sb.get_build_id(), sb.get_sandboxtype().get_style(), bi.host, state.phase, state.reason, state.start_time, state.timestamps, sb.get_targeted_platform_variant(), bi.os, bi.bitness, bi.version) db = Dashboard(rr) db.add_summary(summary) if os.path.exists(os.path.join(root, 'eval-log.txt')): shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder) # Check in our changes. if need_checkin: status = vcs.get_status(rr) if 'unknown' in status: vcs.add(rr) vcs.checkin(rr, msg="update dashboard", quiet_stderr=True) try: vcs.push(rr) except BzrCommandError, e: if 'diverged' in ("%s" % e): print "\nAttemping to resolve diverged report aspect" print "\nNuking report dir %s" % rr if not ioutil.nuke(rr): print "\nAuto resolving diverged report aspect failed!" bi = BranchInfo(branchname=sb.get_branch(), componentname=sb.get_top_component(), aspectname='report') aspectdir = bi.get_branchdir(wr.local_reporoot) print "\nNuking report repo %s" % aspectdir if not ioutil.nuke(aspectdir): print "\nAuto resolving diverged report aspect failed!" # Use the master because we have a problem here. wr.create_local_branch(sb.get_top_component(), 'report', sb.get_branch(), use_master=True) wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=True) db = Dashboard(rr) db.add_summary(summary) if os.path.exists(os.path.join(root, 'eval-log.txt')): shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder) status = vcs.get_status(rr) if 'unknown' in status: vcs.add(rr) vcs.checkin(rr, msg="update dashboard", quiet_stderr=True) vcs.push(rr) print "\nAuto resolve diverged report aspect success!" else: raise e except: traceback.print_exc()
def report(sb, state): rr = sb.get_report_root() root = sb.get_root() need_checkin = vcs.folder_is_tied_to_vcs(rr) try: # Get latest version of reports so we are less likely to cause merge # conflicts. wr = vcs.get_working_repository() use_master = False if not need_checkin: url = os.path.join(wr.master_reporoot, sb.get_branch(), sb.get_top_component(), 'report', ). replace('\\', '/') publish.create_branch(url, False) use_master = True wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=use_master) need_checkin = vcs.folder_is_tied_to_vcs(rr) # Report our results. bi = buildinfo.BuildInfo() machineFolder = os.path.join(rr, bi.host).replace('\\', '/') summary = EvalSummary(sb.get_build_id(), sb.get_sandboxtype().get_style(), bi.host, state.phase, state.reason, state.start_time, state.timestamps, sb.get_targeted_platform_variant(), bi.os, bi.bitness, bi.version) db = Dashboard(rr) db.add_summary(summary) if os.path.exists(os.path.join(root, 'eval-log.txt')): shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder) # Check in our changes. if need_checkin: status = vcs.get_status(rr) if 'unknown' in status: vcs.add(rr) vcs.checkin(rr, msg="update dashboard", quiet_stderr=True) try: vcs.push(rr) except BzrCommandError, e: if 'diverged' in ("%s" % e): print "\nAttemping to resolve diverged report aspect" print "\nNuking report dir %s" % rr if not ioutil.nuke(rr): print "\nAuto resolving diverged report aspect failed!" bi = BranchInfo(branchname=sb.get_branch(), componentname=sb.get_top_component(), aspectname='report') aspectdir = bi.get_branchdir(wr.local_reporoot) print "\nNuking report repo %s" % aspectdir if not ioutil.nuke(aspectdir): print "\nAuto resolving diverged report aspect failed!" # Use the master because we have a problem here. wr.create_local_branch(sb.get_top_component(), 'report', sb.get_branch(), use_master=True) wr.create_or_update_checkout(rr, sb.get_top_component(), 'report', sb.get_branch(), None, use_master=True) db = Dashboard(rr) db.add_summary(summary) if os.path.exists(os.path.join(root, 'eval-log.txt')): shutil.copy2(os.path.join(root, 'eval-log.txt'), machineFolder) status = vcs.get_status(rr) if 'unknown' in status: vcs.add(rr) vcs.checkin(rr, msg="update dashboard", quiet_stderr=True) vcs.push(rr) print "\nAuto resolve diverged report aspect success!" else: raise e except: traceback.print_exc()
def test_dependencies(self): tmpdir = tempfile.mkdtemp() #print('running test in temporary repo %s' % tmpdir) cwd = os.getcwd() try: template1 = '[%s]' % metadata.DEPENDENCIES_SECTION template2 = template1 + ''' %s: code,%s.trunk.1.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' template3 = template1 + ''' %s: code,%s.trunk.2.1 use: reusable %s: code,%s.trunk.1.1 use: reusable ''' files = { 'a': template2 % ('b', 'b', 'c', 'c'), 'b': template1, 'c': template3 % ('b', 'b', 'd', 'd'), 'd': template1 } testRepos = ['a', 'b', 'c', 'd'] for t in testRepos: repoPath = os.path.join(tmpdir, 'trunk', t) os.makedirs(os.path.join(tmpdir, 'trunk', t)) branchPath = repoPath + '/code' #print('init %s' % branchPath) vcs.init(branchPath, False) filePath = branchPath + '/' + metadata.METADATA_FILE save(filePath, files[t]) os.chdir(branchPath) #print('adding %s' % filePath) vcs.add(filePath) #print('checking in %s' % filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.1.1 use: reusable' % t) if t == 'b': #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) filePath = branchPath + '/dependencies2.txt' save(filePath, files[t]) vcs.add(filePath) vcs.checkin(filePath, 'Test', True) vcs.tag('%s.trunk.2.1 use: reusable' % t) #subprocess.Popen(['bzr', 'tags']) working_repo = vcs.WorkingRepository() working_repo._init(tmpdir, tmpdir, tmpdir) prob = metadata.get_components_inv_dep_order( working_repo, 'win_x64', 'a', tmpdir, 'trunk', '') comp = [ component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable', 'code'), component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable', 'code'), component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable', 'code'), component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable', 'code') ] if False: for c in comp: print("comp = " + str(c)) for c in prob: print("prob = " + str(c)) # prob will have buildscripts; comp doesn't prob = [p for p in prob if p.name != 'buildscripts'] self.assertEquals(len(comp), len(prob)) for i in range(len(comp)): self.assertEquals(comp[i].name, prob[i].name) finally: os.chdir(cwd) shutil.rmtree(tmpdir)