forked from lix-project/hydra
* Merge the GC branch.
This commit is contained in:
parent
14f9260a27
commit
738712fca0
|
@ -167,3 +167,8 @@
|
||||||
* Find the builds with the highest number of build steps:
|
* 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;
|
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
|
||||||
|
|
|
@ -21,8 +21,9 @@ void printHelp()
|
||||||
static Path gcRootsDir;
|
static Path gcRootsDir;
|
||||||
|
|
||||||
|
|
||||||
typedef std::map<Symbol, std::pair<unsigned int, Value> > ArgsUsed;
|
typedef std::map<Symbol, std::pair<unsigned int, Value *> > ArgsUsed;
|
||||||
typedef std::map<Symbol, list<Value> > AutoArgs;
|
typedef std::list<Value *, traceable_allocator<Value *> > ValueList;
|
||||||
|
typedef std::map<Symbol, ValueList> AutoArgs;
|
||||||
|
|
||||||
|
|
||||||
static void findJobs(EvalState & state, XMLWriter & doc,
|
static void findJobs(EvalState & state, XMLWriter & doc,
|
||||||
|
@ -38,10 +39,10 @@ static void tryJobAlts(EvalState & state, XMLWriter & doc,
|
||||||
const Bindings & actualArgs)
|
const Bindings & actualArgs)
|
||||||
{
|
{
|
||||||
if (cur == last) {
|
if (cur == last) {
|
||||||
Value v, arg;
|
Value v, * arg = state.allocValue();
|
||||||
state.mkAttrs(arg);
|
state.mkAttrs(*arg, 0);
|
||||||
*arg.attrs = actualArgs;
|
*arg->attrs = actualArgs;
|
||||||
mkApp(v, fun, arg);
|
mkApp(v, fun, *arg);
|
||||||
findJobs(state, doc, argsUsed, argsLeft, v, attrPath);
|
findJobs(state, doc, argsUsed, argsLeft, v, attrPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -55,12 +56,13 @@ static void tryJobAlts(EvalState & state, XMLWriter & doc,
|
||||||
Formals::Formals_::iterator next = cur; ++next;
|
Formals::Formals_::iterator next = cur; ++next;
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
foreach (list<Value>::const_iterator, i, a->second) {
|
foreach (ValueList::const_iterator, i, a->second) {
|
||||||
Bindings actualArgs2(actualArgs); // !!! inefficient
|
Bindings actualArgs2(actualArgs); // !!! inefficient
|
||||||
ArgsUsed argsUsed2(argsUsed);
|
ArgsUsed argsUsed2(argsUsed);
|
||||||
AutoArgs argsLeft2(argsLeft);
|
AutoArgs argsLeft2(argsLeft);
|
||||||
actualArgs2[cur->name].value = *i;
|
actualArgs2.push_back(Attr(cur->name, *i));
|
||||||
argsUsed2[cur->name] = std::pair<unsigned int, Value>(n, *i);
|
actualArgs2.sort(); // !!! inefficient
|
||||||
|
argsUsed2[cur->name] = std::pair<unsigned int, Value *>(n, *i);
|
||||||
argsLeft2.erase(cur->name);
|
argsLeft2.erase(cur->name);
|
||||||
tryJobAlts(state, doc, argsUsed2, argsLeft2, attrPath, fun, next, last, actualArgs2);
|
tryJobAlts(state, doc, argsUsed2, argsLeft2, attrPath, fun, next, last, actualArgs2);
|
||||||
++n;
|
++n;
|
||||||
|
@ -73,7 +75,7 @@ static void showArgsUsed(XMLWriter & doc, const ArgsUsed & argsUsed)
|
||||||
foreach (ArgsUsed::const_iterator, i, argsUsed) {
|
foreach (ArgsUsed::const_iterator, i, argsUsed) {
|
||||||
XMLAttrs xmlAttrs2;
|
XMLAttrs xmlAttrs2;
|
||||||
xmlAttrs2["name"] = i->first;
|
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);
|
xmlAttrs2["altnr"] = int2String(i->second.first);
|
||||||
doc.writeEmptyElement("arg", xmlAttrs2);
|
doc.writeEmptyElement("arg", xmlAttrs2);
|
||||||
}
|
}
|
||||||
|
@ -162,8 +164,8 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc,
|
||||||
|
|
||||||
else {
|
else {
|
||||||
foreach (Bindings::iterator, i, *v.attrs)
|
foreach (Bindings::iterator, i, *v.attrs)
|
||||||
findJobs(state, doc, argsUsed, argsLeft, i->second.value,
|
findJobs(state, doc, argsUsed, argsLeft, *i->value,
|
||||||
(attrPath.empty() ? "" : attrPath + ".") + (string) i->first);
|
(attrPath.empty() ? "" : attrPath + ".") + (string) i->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,11 +214,11 @@ void run(Strings args)
|
||||||
string name = *i++;
|
string name = *i++;
|
||||||
if (i == args.end()) throw UsageError("missing argument");
|
if (i == args.end()) throw UsageError("missing argument");
|
||||||
string value = *i++;
|
string value = *i++;
|
||||||
Value v;
|
Value * v = state.allocValue();
|
||||||
if (arg == "--arg")
|
if (arg == "--arg")
|
||||||
state.eval(parseExprFromString(state, value, absPath(".")), v);
|
state.eval(parseExprFromString(state, value, absPath(".")), *v);
|
||||||
else
|
else
|
||||||
mkString(v, value);
|
mkString(*v, value);
|
||||||
autoArgs[state.symbols.create(name)].push_back(v);
|
autoArgs[state.symbols.create(name)].push_back(v);
|
||||||
}
|
}
|
||||||
else if (arg == "--gc-roots-dir") {
|
else if (arg == "--gc-roots-dir") {
|
||||||
|
@ -239,6 +241,7 @@ void run(Strings args)
|
||||||
Value v;
|
Value v;
|
||||||
state.mkThunk_(v, e);
|
state.mkThunk_(v, e);
|
||||||
|
|
||||||
|
std::cout.setf(std::ios::unitbuf);
|
||||||
XMLWriter doc(true, std::cout);
|
XMLWriter doc(true, std::cout);
|
||||||
XMLOpenElement root(doc, "jobs");
|
XMLOpenElement root(doc, "jobs");
|
||||||
findJobs(state, doc, ArgsUsed(), autoArgs, v, "");
|
findJobs(state, doc, ArgsUsed(), autoArgs, v, "");
|
||||||
|
|
|
@ -36,18 +36,27 @@ sub keepBuild {
|
||||||
|
|
||||||
foreach my $project ($db->resultset('Projects')->all) {
|
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) {
|
# 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 ",
|
print STDERR "*** looking for builds to keep in job ",
|
||||||
$project->name, ":", $job->jobset->name, ":", $job->name, "\n";
|
$project->name, ":", $job->jobset->name, ":", $job->name, "\n";
|
||||||
|
|
||||||
# Keep the N most recent successful builds for each job and
|
# Keep the N most recent successful builds for each job
|
||||||
# platform.
|
# and platform.
|
||||||
# !!! Take time into account? E.g. don't delete builds that
|
# !!! Take time into account? E.g. don't delete builds
|
||||||
# are younger than N days.
|
# that are younger than N days.
|
||||||
my @systems = $job->builds->search({ }, { select => ["system"], distinct => 1 })->all;
|
my @systems = $job->builds->search({ }, { select => ["system"], distinct => 1 })->all;
|
||||||
my $keepnr = $job->jobset->keepnr ;
|
|
||||||
foreach my $system (@systems) {
|
foreach my $system (@systems) {
|
||||||
my @recentBuilds = $job->builds->search(
|
my @recentBuilds = $job->builds->search(
|
||||||
{ finished => 1
|
{ finished => 1
|
||||||
|
@ -61,9 +70,9 @@ foreach my $project ($db->resultset('Projects')->all) {
|
||||||
keepBuild $_ foreach @recentBuilds;
|
keepBuild $_ foreach @recentBuilds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Go over all views in this project.
|
# Go over all views in this project.
|
||||||
|
|
||||||
foreach my $view ($project->views->all) {
|
foreach my $view ($project->views->all) {
|
||||||
print STDERR "*** looking for builds to keep in view ", $project->name, ":", $view->name, "\n";
|
print STDERR "*** looking for builds to keep in view ", $project->name, ":", $view->name, "\n";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue