diff --git a/doc/dev-notes.txt b/doc/dev-notes.txt index 47274125..54fb7c3a 100644 --- a/doc/dev-notes.txt +++ b/doc/dev-notes.txt @@ -167,3 +167,8 @@ * Find the builds with the highest number of build steps: select id, (select count(*) from buildsteps where build = x.id) as n from builds x order by n desc; + + +* Evaluating the NixOS Hydra jobs: + + $ ./hydra_eval_jobs ~/Dev/nixos-wc/release.nix --arg nixpkgs '{outPath = /home/eelco/Dev/nixpkgs-wc;}' --arg nixosSrc '{outPath = /home/eelco/Dev/nixos-wc; rev = 1234;}' --arg services '{outhPath = /home/eelco/services-wc;}' --argstr system i686-linux --argstr system x86_64-linux --arg officialRelease false diff --git a/src/c/hydra_eval_jobs.cc b/src/c/hydra_eval_jobs.cc index 2b09b5be..79b2ce95 100644 --- a/src/c/hydra_eval_jobs.cc +++ b/src/c/hydra_eval_jobs.cc @@ -21,8 +21,9 @@ void printHelp() static Path gcRootsDir; -typedef std::map > ArgsUsed; -typedef std::map > AutoArgs; +typedef std::map > ArgsUsed; +typedef std::list > ValueList; +typedef std::map AutoArgs; static void findJobs(EvalState & state, XMLWriter & doc, @@ -38,10 +39,10 @@ static void tryJobAlts(EvalState & state, XMLWriter & doc, const Bindings & actualArgs) { if (cur == last) { - Value v, arg; - state.mkAttrs(arg); - *arg.attrs = actualArgs; - mkApp(v, fun, arg); + Value v, * arg = state.allocValue(); + state.mkAttrs(*arg, 0); + *arg->attrs = actualArgs; + mkApp(v, fun, *arg); findJobs(state, doc, argsUsed, argsLeft, v, attrPath); return; } @@ -55,12 +56,13 @@ static void tryJobAlts(EvalState & state, XMLWriter & doc, Formals::Formals_::iterator next = cur; ++next; int n = 0; - foreach (list::const_iterator, i, a->second) { + foreach (ValueList::const_iterator, i, a->second) { Bindings actualArgs2(actualArgs); // !!! inefficient ArgsUsed argsUsed2(argsUsed); AutoArgs argsLeft2(argsLeft); - actualArgs2[cur->name].value = *i; - argsUsed2[cur->name] = std::pair(n, *i); + actualArgs2.push_back(Attr(cur->name, *i)); + actualArgs2.sort(); // !!! inefficient + argsUsed2[cur->name] = std::pair(n, *i); argsLeft2.erase(cur->name); tryJobAlts(state, doc, argsUsed2, argsLeft2, attrPath, fun, next, last, actualArgs2); ++n; @@ -73,7 +75,7 @@ static void showArgsUsed(XMLWriter & doc, const ArgsUsed & argsUsed) foreach (ArgsUsed::const_iterator, i, argsUsed) { XMLAttrs xmlAttrs2; xmlAttrs2["name"] = i->first; - xmlAttrs2["value"] = (format("%1%") % i->second.second).str(); + xmlAttrs2["value"] = (format("%1%") % *i->second.second).str(); xmlAttrs2["altnr"] = int2String(i->second.first); doc.writeEmptyElement("arg", xmlAttrs2); } @@ -105,7 +107,7 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc, Value & v, const string & attrPath) { debug(format("at path `%1%'") % attrPath); - + state.forceValue(v); if (v.type == tAttrs) { @@ -162,8 +164,8 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc, else { foreach (Bindings::iterator, i, *v.attrs) - findJobs(state, doc, argsUsed, argsLeft, i->second.value, - (attrPath.empty() ? "" : attrPath + ".") + (string) i->first); + findJobs(state, doc, argsUsed, argsLeft, *i->value, + (attrPath.empty() ? "" : attrPath + ".") + (string) i->name); } } @@ -212,11 +214,11 @@ void run(Strings args) string name = *i++; if (i == args.end()) throw UsageError("missing argument"); string value = *i++; - Value v; + Value * v = state.allocValue(); if (arg == "--arg") - state.eval(parseExprFromString(state, value, absPath(".")), v); + state.eval(parseExprFromString(state, value, absPath(".")), *v); else - mkString(v, value); + mkString(*v, value); autoArgs[state.symbols.create(name)].push_back(v); } else if (arg == "--gc-roots-dir") { @@ -239,6 +241,7 @@ void run(Strings args) Value v; state.mkThunk_(v, e); + std::cout.setf(std::ios::unitbuf); XMLWriter doc(true, std::cout); XMLOpenElement root(doc, "jobs"); findJobs(state, doc, ArgsUsed(), autoArgs, v, ""); diff --git a/src/script/hydra_update_gc_roots.pl.in b/src/script/hydra_update_gc_roots.pl.in index a07d4690..890f6138 100755 --- a/src/script/hydra_update_gc_roots.pl.in +++ b/src/script/hydra_update_gc_roots.pl.in @@ -36,34 +36,43 @@ sub keepBuild { foreach my $project ($db->resultset('Projects')->all) { - # Go over all jobs in this project. + # Go over all jobsets in this project. + foreach my $jobset ($project->jobsets->all) { + my $keepnr = $jobset->keepnr; - foreach my $job ($project->jobs->all) { - print STDERR "*** looking for builds to keep in job ", - $project->name, ":", $job->jobset->name, ":", $job->name, "\n"; + # If the jobset has been disabled for more than one week, than + # don't keep its builds anymore. + if ($jobset->enabled == 0 && (time() - $jobset->lastcheckedtime > (7 * 24 * 3600))) { + print STDERR "*** skipping disabled jobset ", $project->name, ":", $jobset->name, "\n"; + next; + } + + # Go over all jobs in this jobset. + foreach my $job ($jobset->jobs->all) { + print STDERR "*** looking for builds to keep in job ", + $project->name, ":", $job->jobset->name, ":", $job->name, "\n"; - # Keep the N most recent successful builds for each job and - # platform. - # !!! Take time into account? E.g. don't delete builds that - # are younger than N days. - my @systems = $job->builds->search({ }, { select => ["system"], distinct => 1 })->all; - my $keepnr = $job->jobset->keepnr ; - foreach my $system (@systems) { - my @recentBuilds = $job->builds->search( - { finished => 1 - , buildStatus => 0 # == success - , system => $system->system - }, - { join => 'resultInfo' - , order_by => 'id DESC' - , rows => $keepnr - }); - keepBuild $_ foreach @recentBuilds; + # Keep the N most recent successful builds for each job + # and platform. + # !!! Take time into account? E.g. don't delete builds + # that are younger than N days. + my @systems = $job->builds->search({ }, { select => ["system"], distinct => 1 })->all; + foreach my $system (@systems) { + my @recentBuilds = $job->builds->search( + { finished => 1 + , buildStatus => 0 # == success + , system => $system->system + }, + { join => 'resultInfo' + , order_by => 'id DESC' + , rows => $keepnr + }); + keepBuild $_ foreach @recentBuilds; + } } } # Go over all views in this project. - foreach my $view ($project->views->all) { print STDERR "*** looking for builds to keep in view ", $project->name, ":", $view->name, "\n";