def create_copy_command(props): rev = props.getProperty("got_revision") builder = props.getProperty("buildername") istry = props.getProperty("isTrySched") branch = props.getProperty("branch") command = ["cp", "-a"] db_file = os.path.join(get_web_base(), builder, builder + ".db") if not os.path.exists(db_file): # This is probably the first commit being tested. Don't do anything. return ["true"] con = sqlite3.connect(db_file) c = con.cursor() c.execute( 'SELECT commitid FROM logs WHERE branch = "%s" AND trysched = 0 ORDER BY timestamp DESC LIMIT 1' % branch ) comm = c.fetchone() con.close() if comm: commit = comm[0] else: return ["true"] from_path = os.path.join(get_web_base(), builder, commit[:2], commit, "gdb.sum.xz") if not os.path.exists(from_path): # Let's just return true here, because we want the build to # continue. return ["true"] if istry and istry == "yes": try_count = props.getProperty("try_count") to_path = os.path.join(get_web_base(), builder, "try", rev[:2], rev, try_count) else: to_path = os.path.join(get_web_base(), builder, rev[:2], rev) if not os.path.exists(to_path): old_umask = os.umask(0o022) os.makedirs(to_path) os.umask(old_umask) to_path = os.path.join(to_path, "previous_gdb.sum.xz") command += [from_path, to_path] return command
def _evaluateCommand_single_repo(self, cmd): rev = self.getProperty("got_revision") builder = self.getProperty("buildername") istrysched = self.getProperty("isTrySched") isrebuild = self.getProperty("isRebuild") branch = self.getProperty("branch") repodir = os.path.join(get_web_base(), builder) full_tag = "%s-%s-%s" % (datetime.now().strftime("%Y%m%d-%H%M%S"), rev, branch) if istrysched and istrysched == "yes": full_tag += "-TRY_BUILD" if branch is None: branch = "master" repo = git.Repo.init(path=repodir) if isrebuild and isrebuild == "yes": # Do nothing if branch in repo.heads: # We have to clean the branch because otherwise this # can confuse other builds repo.git.execute(["git", "checkout", "*"]) return SUCCESS if "master" not in repo.heads: with open(os.path.join(repodir, "README"), "w") as f: f.write("git repo for GDB test results -- %s" % builder) with open(os.path.join(repodir, ".gitignore"), "w") as f: f.write("*xfail*\n") repo.index.add(["README", ".gitignore"]) repo.index.commit("Initial commit") repo.index.write() if branch not in repo.heads: myhead = repo.create_head(branch) else: myhead = repo.heads[branch] myhead.checkout() if full_tag not in repo.tags: repo.index.add(["gdb.sum", "gdb.log", "baseline"]) if os.path.exists("%s/previous_gdb.sum" % repodir): repo.index.add(["previous_gdb.sum"]) if os.path.exists("%s/trybuild_gdb.sum" % repodir): repo.index.add(["trybuild_gdb.sum"]) if repo.is_dirty(): if istrysched and istrysched == "yes": repo.index.commit( "TRY BUILD: Log files for %s -- branch %s" % (full_tag, branch)) else: repo.index.commit("Log files for %s -- branch %s" % (full_tag, branch)) repo.index.write() repo.create_tag(full_tag) # Returning the HEAD to master repo.heads["master"].checkout() return SUCCESS
def _evaluateCommand_single_repo (self, cmd): rev = self.getProperty ('got_revision') builder = self.getProperty ('buildername') istry = self.getProperty ('isTryBuilder') isrebuild = self.getProperty ('isRebuild') branch = self.getProperty ('branch') repodir = os.path.join (get_web_base (), builder) full_tag = "%s-%s-%s" % (datetime.now ().strftime ("%Y%m%d-%H%M%S"), rev, branch) if branch is None: branch = 'master' repo = git.Repo.init (path = repodir) if (istry and istry == 'yes') or (isrebuild and isrebuild == 'yes'): # Do nothing if branch in repo.heads: # We have to clean the branch because otherwise this # can confuse other builds repo.git.execute (['git', 'checkout', '*']) return SUCCESS if 'master' not in repo.heads: with open (os.path.join (repodir, 'README'), 'w') as f: f.write ("git repo for GDB test results -- %s" % builder) with open (os.path.join (repodir, '.gitignore'), 'w') as f: f.write ("*xfail*\n") repo.index.add (['README', '.gitignore']) repo.index.commit ('Initial commit') repo.index.write () if branch not in repo.heads: myhead = repo.create_head (branch) else: myhead = repo.heads[branch] myhead.checkout () if full_tag not in repo.tags: repo.index.add (['gdb.sum', 'gdb.log', 'baseline']) if os.path.exists ("%s/previous_gdb.sum" % repodir): repo.index.add (['previous_gdb.sum']) if repo.is_dirty (): repo.index.commit ('Log files for %s -- branch %s' % (full_tag, branch)) repo.index.write () repo.create_tag (full_tag) # Returning the HEAD to master repo.heads['master'].checkout () return SUCCESS
def get_builder_commit_id (builder, commit, branch): """Get the commit hash in the BUILDER's repository which points to the log files of the COMMIT that was tested.""" repodir = os.path.join (get_web_base (), builder) repo = git.Repo.init (path = repodir) commit_id_re = re.compile ("^\d{8}-\d{6}-%s-%s$" % (commit, branch)) for t in repo.tags: m = commit_id_re.match (t.name) if not m: continue return t.commit.__str__ () return None
def get_builder_commit_id(builder, commit, branch): """Get the commit hash in the BUILDER's repository which points to the log files of the COMMIT that was tested.""" repodir = os.path.join(get_web_base(), builder) repo = git.Repo.init(path=repodir) commit_id_re = re.compile(r"^\d{8}-\d{6}-%s-%s$" % (commit, branch)) for t in repo.tags: m = commit_id_re.match(t.name) if not m: continue return t.commit.__str__() return None
def _evaluateCommand_builder_branch(self, cmd): rev = self.getProperty("got_revision") builder = self.getProperty("buildername") istry = self.getProperty("isTryBuilder") branch = self.getProperty("branch") repodir = get_web_base() builder_dir = os.path.join(repodir, builder) # TODO: Include timestamp in the tag name? full_tag = "%s-%s-%s" % (builder, rev, branch) if branch is None: branch = "master" if istry and istry == "yes": # Do nothing return SUCCESS repo = git.Repo.init(path=repodir) if not os.path.exists(builder_dir): os.mkdir(builder_dir) if "master" not in repo.heads: with open(os.path.join(repodir, "README"), "w") as f: f.write("git repo for GDB test results") with open(os.path.join(repodir, ".gitignore"), "w") as f: f.write("*xfail*\n") repo.index.add(["README", ".gitignore"]) repo.index.commit("Initial commit") repo.index.write() if builder not in repo.heads: myhead = repo.create_head(builder) else: myhead = repo.heads[builder] if full_tag not in repo.tags: myhead.checkout() repo.index.add([ "%s/gdb.sum" % builder, "%s/gdb.log" % builder, "%s/baseline" % builder, ]) if repo.is_dirty(): repo.index.commit("Log files for %s -- branch %s" % (full_tag, branch)) repo.index.write() repo.create_tag(full_tag) return SUCCESS
def __init__(self, **kwargs): steps.MasterShellCommand.__init__(self, command=None, **kwargs) self.command = [ os.path.expanduser("~/scripts/update-logs.sh"), "--commit", util.Property("got_revision"), "--builder", util.Property("buildername"), "--base-directory", get_web_base(), "--branch", util.Property("branch"), "--is-try-sched", util.Property("isTrySched", default="no"), "--try-count", util.Property("try_count", default="0"), ]
def _evaluateCommand_builder_branch (self, cmd): rev = self.getProperty ('got_revision') builder = self.getProperty ('buildername') istry = self.getProperty ('isTryBuilder') branch = self.getProperty ('branch') repodir = get_web_base () builder_dir = os.path.join (repodir, builder) # TODO: Include timestamp in the tag name? full_tag = "%s-%s-%s" % (builder, rev, branch) if branch is None: branch = 'master' if istry and istry == 'yes': # Do nothing return SUCCESS repo = git.Repo.init (path = repodir) if not os.path.exists (builder_dir): os.mkdir (builder_dir) if 'master' not in repo.heads: with open (os.path.join (repodir, 'README'), 'w') as f: f.write ("git repo for GDB test results") with open (os.path.join (repodir, '.gitignore'), 'w') as f: f.write ("*xfail*\n") repo.index.add (['README', '.gitignore']) repo.index.commit ('Initial commit') repo.index.write () if builder not in repo.heads: myhead = repo.create_head (builder) else: myhead = repo.heads[builder] if full_tag not in repo.tags: myhead.checkout () repo.index.add (['%s/gdb.sum' % builder, '%s/gdb.log' % builder, '%s/baseline' % builder]) if repo.is_dirty (): repo.index.commit ('Log files for %s -- branch %s' % (full_tag, branch)) repo.index.write () repo.create_tag (full_tag) return SUCCESS
def switch_to_branch (builder, branch): """Switch (or create) to BRANCH on BUILDER repo.""" repodir = os.path.join (get_web_base (), builder) repo = git.Repo.init (path = repodir) if 'master' not in repo.heads: with open (os.path.join (repodir, 'README'), 'w') as f: f.write ("git repo for GDB test results") with open (os.path.join (repodir, '.gitignore'), 'w') as f: f.write ("*xfails*\n") repo.index.add (['README', '.gitignore']) repo.index.commit ('Initial commit') repo.index.write () if branch not in repo.heads: myhead = repo.create_head (branch) else: myhead = repo.heads[branch] myhead.checkout (force = True)
def switch_to_branch(builder, branch, force_switch=False): """Switch (or create) to BRANCH on BUILDER repo.""" repodir = os.path.join(get_web_base(), builder) repo = git.Repo.init(path=repodir) if "master" not in repo.heads: with open(os.path.join(repodir, "README"), "w") as f: f.write("git repo for GDB test results") with open(os.path.join(repodir, ".gitignore"), "w") as f: f.write("*xfails*\n") repo.index.add(["README", ".gitignore"]) repo.index.commit("Initial commit") repo.index.write() if branch not in repo.heads: myhead = repo.create_head(branch) else: myhead = repo.heads[branch] myhead.checkout(force=force_switch)
def evaluateCommand (self, cmd): rev = self.getProperty('got_revision') builder = self.getProperty('buildername') isrebuild = self.getProperty ('isRebuild') branch = self.getProperty('branch') wb = get_web_base () if branch is None: branch = 'master' if isrebuild and isrebuild == 'yes': return SUCCESS # Switch to the right branch inside the BUILDER repo switch_to_branch (builder, branch, force_switch = True) try: copyfile ("%s/%s/gcc.sum" % (wb, builder), "%s/%s/previous_gcc.sum" % (wb, builder)) except IOError: # If the dest file does not exist, ignore pass return SUCCESS
def evaluateCommand (self, cmd): rev = self.getProperty('got_revision') builder = self.getProperty('buildername') istrybuilder = self.getProperty('isTryBuilder') isrebuild = self.getProperty ('isRebuild') branch = self.getProperty('branch') wb = get_web_base () if branch is None: branch = 'master' if (istrybuilder and istrybuilder == 'yes') or (isrebuild and isrebuild == 'yes'): return SUCCESS # Switch to the right branch inside the BUILDER repo switch_to_branch (builder, branch) try: copyfile ("%s/%s/gdb.sum" % (wb, builder), "%s/%s/previous_gdb.sum" % (wb, builder)) except IOError: # If the dest file does not exist, ignore pass return SUCCESS
def evaluateCommand(self, cmd): rev = self.getProperty("got_revision") builder = self.getProperty("buildername") istrysched = self.getProperty("isTrySched") istry = istrysched and istrysched == "yes" branch = self.getProperty("branch") db_file = os.path.join(get_web_base(), builder, builder + ".db") parser = DejaResults() cur_results = parser.read_sum_text(self.getLog("stdio").getText()) baseline = None if branch is None: branch = "master" if not os.path.exists(db_file): # This takes care of our very first build. if istry: parser.write_try_build_sum_file(cur_results, builder, branch, rev, "0") else: parser.write_sum_file(cur_results, builder, branch, rev, istry) # If there was no previous baseline, then this run # gets the honor. if baseline is None: baseline = cur_results parser.write_baseline(baseline, builder, branch, rev, istry) return SUCCESS con = sqlite3.connect(db_file) c = con.cursor() c.execute( 'SELECT commitid FROM logs WHERE branch = "%s" AND trysched = 0 ORDER BY timestamp DESC LIMIT 1' % branch ) prev = c.fetchone() con.close() if prev: prevcommit = prev[0] else: # This takes care of our very first build. if istry: parser.write_try_build_sum_file(cur_results, builder, branch, rev, "0") else: parser.write_sum_file(cur_results, builder, branch, rev, istry) # If there was no previous baseline, then this run # gets the honor. if baseline is None: baseline = cur_results parser.write_baseline(baseline, builder, branch, rev, istry) return SUCCESS baseline = parser.read_baseline(builder, branch, prevcommit) old_sum = parser.read_sum_file(builder, branch, prevcommit) result = SUCCESS if baseline is not None: report = parser.compute_regressions(builder, branch, cur_results, baseline) if report != "": self.addCompleteLog("baseline_diff", report) result = WARNINGS if old_sum is not None: report = parser.compute_regressions(builder, branch, cur_results, old_sum) if report != "": self.addCompleteLog("regressions", report) result = FAILURE if istry: try_count = self.getProperty("try_count") parser.write_try_build_sum_file( cur_results, builder, branch, rev, try_count ) else: parser.write_sum_file(cur_results, builder, branch, rev, istry) # If there was no previous baseline, then this run # gets the honor. if baseline is None: baseline = cur_results parser.write_baseline(baseline, builder, branch, rev, istry) return result