Die tabs die

This commit is contained in:
Eelco Dolstra 2013-01-22 14:09:37 +01:00
parent 486b6037a9
commit aa28ffe3a8
12 changed files with 90 additions and 90 deletions

View file

@ -93,7 +93,7 @@ sub latest : Chained('get_builds') PathPart('latest') {
my ($self, $c, @rest) = @_; my ($self, $c, @rest) = @_;
my ($latest) = $c->stash->{allBuilds}->search( my ($latest) = $c->stash->{allBuilds}->search(
{finished => 1, buildstatus => 0}, {order_by => ["isCurrent DESC", "timestamp DESC"]}); {finished => 1, buildstatus => 0}, {order_by => ["isCurrent DESC", "timestamp DESC"]});
notFound($c, "There is no successful build to redirect to.") unless defined $latest; notFound($c, "There is no successful build to redirect to.") unless defined $latest;
@ -108,7 +108,7 @@ sub latest_for : Chained('get_builds') PathPart('latest-for') {
notFound($c, "You need to specify a platform type in the URL.") unless defined $system; notFound($c, "You need to specify a platform type in the URL.") unless defined $system;
my ($latest) = $c->stash->{allBuilds}->search( my ($latest) = $c->stash->{allBuilds}->search(
{finished => 1, buildstatus => 0, system => $system}, {order_by => ["isCurrent DESC", "timestamp DESC"]}); {finished => 1, buildstatus => 0, system => $system}, {order_by => ["isCurrent DESC", "timestamp DESC"]});
notFound($c, "There is no successful build for platform `$system' to redirect to.") unless defined $latest; notFound($c, "There is no successful build for platform `$system' to redirect to.") unless defined $latest;

View file

@ -103,8 +103,8 @@ sub latestbuilds : Chained('api') PathPart('latestbuilds') Args(0) {
sub jobsetToHash { sub jobsetToHash {
my ($jobset) = @_; my ($jobset) = @_;
return { return {
project => $jobset->project->name, project => $jobset->project->name,
name => $jobset->name, name => $jobset->name,
nrscheduled => $jobset->get_column("nrscheduled"), nrscheduled => $jobset->get_column("nrscheduled"),
nrsucceeded => $jobset->get_column("nrsucceeded"), nrsucceeded => $jobset->get_column("nrsucceeded"),
nrfailed => $jobset->get_column("nrfailed"), nrfailed => $jobset->get_column("nrfailed"),
@ -222,13 +222,13 @@ sub scmdiff : Chained('api') PathPart('scmdiff') Args(0) {
my $clonePath = scmPath . "/" . sha256_hex($uri); my $clonePath = scmPath . "/" . sha256_hex($uri);
die if ! -d $clonePath; die if ! -d $clonePath;
$branch = `(cd $clonePath; hg log --template '{branch}' -r $rev2)`; $branch = `(cd $clonePath; hg log --template '{branch}' -r $rev2)`;
$diff .= `(cd $clonePath; hg log -r $rev1 -r $rev2 -b $branch)`; $diff .= `(cd $clonePath; hg log -r $rev1 -r $rev2 -b $branch)`;
$diff .= `(cd $clonePath; hg diff -r $rev1:$rev2)`; $diff .= `(cd $clonePath; hg diff -r $rev1:$rev2)`;
} elsif ($type eq "git") { } elsif ($type eq "git") {
my $clonePath = scmPath . "/" . sha256_hex($uri); my $clonePath = scmPath . "/" . sha256_hex($uri);
die if ! -d $clonePath; die if ! -d $clonePath;
$diff .= `(cd $clonePath; git log $rev1..$rev2)`; $diff .= `(cd $clonePath; git log $rev1..$rev2)`;
$diff .= `(cd $clonePath; git diff $rev1..$rev2)`; $diff .= `(cd $clonePath; git diff $rev1..$rev2)`;
} }
$c->stash->{'plain'} = { data => (scalar $diff) || " " }; $c->stash->{'plain'} = { data => (scalar $diff) || " " };

View file

@ -21,14 +21,14 @@ sub nixMachines {
my $result = "# GENERATED BY HYDRA\n"; my $result = "# GENERATED BY HYDRA\n";
foreach my $machine ($c->model("DB::BuildMachines")->all) { foreach my $machine ($c->model("DB::BuildMachines")->all) {
if($machine->enabled) { if($machine->enabled) {
$result = $result . $machine->username . '@'. $machine->hostname . ' '; $result = $result . $machine->username . '@'. $machine->hostname . ' ';
foreach my $system ($machine->buildmachinesystemtypes) { foreach my $system ($machine->buildmachinesystemtypes) {
$result = $result . $system->system .','; $result = $result . $system->system .',';
} }
chop $result; chop $result;
$result = $result . ' '. $machine->ssh_key . ' ' . $machine->maxconcurrent . ' '. $machine->speedfactor . ' ' . $machine->options . "\n"; $result = $result . ' '. $machine->ssh_key . ' ' . $machine->maxconcurrent . ' '. $machine->speedfactor . ' ' . $machine->options . "\n";
} }
} }
return $result; return $result;
} }
@ -284,9 +284,9 @@ sub updateMachine {
}); });
$machine->buildmachinesystemtypes->delete_all; $machine->buildmachinesystemtypes->delete_all;
if(ref($systems) eq 'ARRAY') { if(ref($systems) eq 'ARRAY') {
for my $s (@$systems) { for my $s (@$systems) {
$machine->buildmachinesystemtypes->create({ system => $s}) ; $machine->buildmachinesystemtypes->create({ system => $s}) ;
} }
} else { } else {
$machine->buildmachinesystemtypes->create({ system => $systems}) ; $machine->buildmachinesystemtypes->create({ system => $systems}) ;
} }

View file

@ -60,7 +60,7 @@ sub view_build : Chained('build') PathPart('') Args(0) {
(my $lastBuildStep) = $build->buildsteps->search({},{order_by => "stepnr DESC", rows => 1}); (my $lastBuildStep) = $build->buildsteps->search({},{order_by => "stepnr DESC", rows => 1});
my $path = defined $lastBuildStep ? $lastBuildStep->logfile : "" ; my $path = defined $lastBuildStep ? $lastBuildStep->logfile : "" ;
if ($build->finished && ($build->buildstatus == 1 || $build->buildstatus == 6) && !($path eq "") && -f $lastBuildStep->logfile) { if ($build->finished && ($build->buildstatus == 1 || $build->buildstatus == 6) && !($path eq "") && -f $lastBuildStep->logfile) {
my $logtext = logContents($path, 50); my $logtext = logContents($path, 50);
$c->stash->{logtext} = removeAsciiEscapes($logtext); $c->stash->{logtext} = removeAsciiEscapes($logtext);
} }
@ -140,8 +140,8 @@ sub showLog {
} }
elsif ($mode eq "tail-reload") { elsif ($mode eq "tail-reload") {
my $url = $c->request->uri->as_string; my $url = $c->request->uri->as_string;
$url =~ s/tail-reload/tail/g; $url =~ s/tail-reload/tail/g;
$c->stash->{url} = $url; $c->stash->{url} = $url;
$c->stash->{reload} = !$c->stash->{build}->finished && $c->stash->{build}->busy; $c->stash->{reload} = !$c->stash->{build}->finished && $c->stash->{build}->busy;
$c->stash->{title} = ""; $c->stash->{title} = "";
@ -311,17 +311,17 @@ sub deps : Chained('build') PathPart('deps') {
@runtimepaths = split '\n', `nix-store --query --requisites --include-outputs $outpath` if isValidPath($build->outpath); @runtimepaths = split '\n', `nix-store --query --requisites --include-outputs $outpath` if isValidPath($build->outpath);
foreach my $p (@buildtimepaths) { foreach my $p (@buildtimepaths) {
my $buildStep; my $buildStep;
($buildStep) = $c->model('DB::BuildSteps')->search({ outpath => $p }, {}) ; ($buildStep) = $c->model('DB::BuildSteps')->search({ outpath => $p }, {}) ;
my %dep = ( buildstep => $buildStep, path => $p ) ; my %dep = ( buildstep => $buildStep, path => $p ) ;
push(@buildtimedeps, \%dep); push(@buildtimedeps, \%dep);
} }
foreach my $p (@runtimepaths) { foreach my $p (@runtimepaths) {
my $buildStep; my $buildStep;
($buildStep) = $c->model('DB::BuildSteps')->search({ outpath => $p }, {}) ; ($buildStep) = $c->model('DB::BuildSteps')->search({ outpath => $p }, {}) ;
my %dep = ( buildstep => $buildStep, path => $p ) ; my %dep = ( buildstep => $buildStep, path => $p ) ;
push(@runtimedeps, \%dep); push(@runtimedeps, \%dep);
} }
@ -466,7 +466,7 @@ sub clone_submit : Chained('build') PathPart('clone/submit') Args(0) {
# When the expression is in a .scm file, assume it's a Guile + Guix # When the expression is in a .scm file, assume it's a Guile + Guix
# build expression. # build expression.
my $exprType = my $exprType =
$c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix"; $c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
my $jobName = trim $c->request->params->{"jobname"}; my $jobName = trim $c->request->params->{"jobname"};
error($c, "Invalid job name: $jobName") if $jobName !~ /^$jobNameRE$/; error($c, "Invalid job name: $jobName") if $jobName !~ /^$jobNameRE$/;

View file

@ -28,18 +28,18 @@ sub overview : Chained('job') PathPart('') Args(0) {
$c->stash->{currentBuilds} = [$c->stash->{job}->builds->search({finished => 1, iscurrent => 1}, { order_by => 'system' })]; $c->stash->{currentBuilds} = [$c->stash->{job}->builds->search({finished => 1, iscurrent => 1}, { order_by => 'system' })];
$c->stash->{lastBuilds} = $c->stash->{lastBuilds} =
[ $c->stash->{job}->builds->search({ finished => 1 }, [ $c->stash->{job}->builds->search({ finished => 1 },
{ order_by => 'timestamp DESC', rows => 10, columns => [@buildListColumns] }) ]; { order_by => 'timestamp DESC', rows => 10, columns => [@buildListColumns] }) ];
$c->stash->{runningBuilds} = [ $c->stash->{runningBuilds} = [
$c->stash->{job}->builds->search( $c->stash->{job}->builds->search(
{ busy => 1 }, { busy => 1 },
{ join => ['project'] { join => ['project']
, order_by => ["priority DESC", "timestamp"] , order_by => ["priority DESC", "timestamp"]
, '+select' => ['project.enabled'] , '+select' => ['project.enabled']
, '+as' => ['enabled'] , '+as' => ['enabled']
} }
) ]; ) ];
$c->stash->{systems} = [$c->stash->{job}->builds->search({iscurrent => 1}, {select => ["system"], distinct => 1})]; $c->stash->{systems} = [$c->stash->{job}->builds->search({iscurrent => 1}, {select => ["system"], distinct => 1})];
} }

View file

@ -57,7 +57,7 @@ sub jobsetIndex {
# status per system # status per system
my @systems = (); my @systems = ();
foreach my $system (@{$c->stash->{systems}}) { foreach my $system (@{$c->stash->{systems}}) {
push(@systems, $system->system); push(@systems, $system->system);
} }
if($forceStatus || scalar(@{$c->stash->{activeJobs}}) <= 100) { if($forceStatus || scalar(@{$c->stash->{activeJobs}}) <= 100) {
@ -74,10 +74,10 @@ sub jobsetIndex {
[ $c->model('DB')->resultset('ActiveJobsForJobset')->search( [ $c->model('DB')->resultset('ActiveJobsForJobset')->search(
{}, {},
{ bind => [$c->stash->{project}->name, $c->stash->{jobset}->name] { bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]
, select => \@select , select => \@select
, as => \@as , as => \@as
, order_by => ["job"] , order_by => ["job"]
})]; })];
} }
} }
@ -226,7 +226,7 @@ sub updateJobset {
# When the expression is in a .scm file, assume it's a Guile + Guix # When the expression is in a .scm file, assume it's a Guile + Guix
# build expression. # build expression.
my $exprType = my $exprType =
$c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix"; $c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
my ($nixExprPath, $nixExprInput) = nixExprPathFromParams $c; my ($nixExprPath, $nixExprInput) = nixExprPathFromParams $c;

View file

@ -11,7 +11,7 @@ sub eval : Chained('/') PathPart('eval') CaptureArgs(1) {
my ($self, $c, $evalId) = @_; my ($self, $c, $evalId) = @_;
my $eval = $c->model('DB::JobsetEvals')->find($evalId) my $eval = $c->model('DB::JobsetEvals')->find($evalId)
or notFound($c, "Evaluation $evalId doesn't exist."); or notFound($c, "Evaluation $evalId doesn't exist.");
$c->stash->{eval} = $eval; $c->stash->{eval} = $eval;
$c->stash->{project} = $eval->project; $c->stash->{project} = $eval->project;

View file

@ -147,7 +147,7 @@ sub create_jobset_submit : Chained('project') PathPart('create-jobset/submit') A
my $jobsetName = trim $c->request->params->{name}; my $jobsetName = trim $c->request->params->{name};
my $exprType = my $exprType =
$c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix"; $c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
error($c, "Invalid jobset name: $jobsetName") if $jobsetName !~ /^$jobsetNameRE$/; error($c, "Invalid jobset name: $jobsetName") if $jobsetName !~ /^$jobsetNameRE$/;

View file

@ -23,8 +23,8 @@ sub begin :Private {
$c->stash->{tracker} = $ENV{"HYDRA_TRACKER"} ; $c->stash->{tracker} = $ENV{"HYDRA_TRACKER"} ;
if (scalar(@args) == 0 || $args[0] ne "static") { if (scalar(@args) == 0 || $args[0] ne "static") {
$c->stash->{nrRunningBuilds} = $c->model('DB::Builds')->search({ finished => 0, busy => 1 }, {})->count(); $c->stash->{nrRunningBuilds} = $c->model('DB::Builds')->search({ finished => 0, busy => 1 }, {})->count();
$c->stash->{nrQueuedBuilds} = $c->model('DB::Builds')->search({ finished => 0 })->count(); $c->stash->{nrQueuedBuilds} = $c->model('DB::Builds')->search({ finished => 0 })->count();
} }
} }
@ -202,10 +202,10 @@ sub nix_cache_info :Path('nix-cache-info') :Args(0) {
$c->stash->{'plain'} = { data => $c->stash->{'plain'} = { data =>
#"StoreDir: $Nix::Config::storeDir\n" . # FIXME #"StoreDir: $Nix::Config::storeDir\n" . # FIXME
"StoreDir: /nix/store\n" . "StoreDir: /nix/store\n" .
"WantMassQuery: 0\n" . "WantMassQuery: 0\n" .
# Give Hydra binary caches a very low priority (lower than the # Give Hydra binary caches a very low priority (lower than the
# static binary cache http://nixos.org/binary-cache). # static binary cache http://nixos.org/binary-cache).
"Priority: 100\n" "Priority: 100\n"
}; };
$c->forward('Hydra::View::Plain'); $c->forward('Hydra::View::Plain');
} }

View file

@ -637,7 +637,7 @@ sub fetchInput {
} }
foreach my $input (@inputs) { foreach my $input (@inputs) {
$input->{type} = $type if defined $input; $input->{type} = $type if defined $input;
} }
return @inputs; return @inputs;
@ -648,14 +648,14 @@ sub booleanToString {
my ($exprType, $value) = @_; my ($exprType, $value) = @_;
my $result; my $result;
if ($exprType eq "guile") { if ($exprType eq "guile") {
if ($value eq "true") { if ($value eq "true") {
$result = "#t"; $result = "#t";
} else { } else {
$result = "#f"; $result = "#f";
} }
$result = $value; $result = $value;
} else { } else {
$result = $value; $result = $value;
} }
return $result; return $result;
} }
@ -664,21 +664,21 @@ sub buildInputToString {
my ($exprType, $input) = @_; my ($exprType, $input) = @_;
my $result; my $result;
if ($exprType eq "guile") { if ($exprType eq "guile") {
$result = "'((file-name . \"" . ${input}->{storePath} . "\")" . $result = "'((file-name . \"" . ${input}->{storePath} . "\")" .
(defined $input->{revision} ? "(revision . \"" . $input->{revision} . "\")" : "") . (defined $input->{revision} ? "(revision . \"" . $input->{revision} . "\")" : "") .
(defined $input->{revCount} ? "(revision-count . " . $input->{revCount} . ")" : "") . (defined $input->{revCount} ? "(revision-count . " . $input->{revCount} . ")" : "") .
(defined $input->{gitTag} ? "(git-tag . \"" . $input->{gitTag} . "\")" : "") . (defined $input->{gitTag} ? "(git-tag . \"" . $input->{gitTag} . "\")" : "") .
(defined $input->{shortRev} ? "(short-revision . \"" . $input->{shortRev} . "\")" : "") . (defined $input->{shortRev} ? "(short-revision . \"" . $input->{shortRev} . "\")" : "") .
(defined $input->{version} ? "(version . \"" . $input->{version} . "\")" : "") . (defined $input->{version} ? "(version . \"" . $input->{version} . "\")" : "") .
")"; ")";
} else { } else {
$result = "{ outPath = builtins.storePath " . $input->{storePath} . "" . $result = "{ outPath = builtins.storePath " . $input->{storePath} . "" .
(defined $input->{revision} ? "; rev = \"" . $input->{revision} . "\"" : "") . (defined $input->{revision} ? "; rev = \"" . $input->{revision} . "\"" : "") .
(defined $input->{revCount} ? "; revCount = " . $input->{revCount} . "" : "") . (defined $input->{revCount} ? "; revCount = " . $input->{revCount} . "" : "") .
(defined $input->{gitTag} ? "; gitTag = \"" . $input->{gitTag} . "\"" : "") . (defined $input->{gitTag} ? "; gitTag = \"" . $input->{gitTag} . "\"" : "") .
(defined $input->{shortRev} ? "; shortRev = \"" . $input->{shortRev} . "\"" : "") . (defined $input->{shortRev} ? "; shortRev = \"" . $input->{shortRev} . "\"" : "") .
(defined $input->{version} ? "; version = \"" . $input->{version} . "\"" : "") . (defined $input->{version} ? "; version = \"" . $input->{version} . "\"" : "") .
";}"; ";}";
} }
return $result; return $result;
} }
@ -898,12 +898,12 @@ sub checkBuild {
# scheduled if the meta.maintainers field is changed? # scheduled if the meta.maintainers field is changed?
if (defined $prevEval) { if (defined $prevEval) {
my ($prevBuild) = $prevEval->builds->search( my ($prevBuild) = $prevEval->builds->search(
# The "project" and "jobset" constraints are # The "project" and "jobset" constraints are
# semantically unnecessary (because they're implied by # semantically unnecessary (because they're implied by
# the eval), but they give a factor 1000 speedup on # the eval), but they give a factor 1000 speedup on
# the Nixpkgs jobset with PostgreSQL. # the Nixpkgs jobset with PostgreSQL.
{ project => $project->name, jobset => $jobset->name, job => $job->name, outPath => $outPath }, { project => $project->name, jobset => $jobset->name, job => $job->name, outPath => $outPath },
{ rows => 1, columns => ['id'] }); { rows => 1, columns => ['id'] });
if (defined $prevBuild) { if (defined $prevBuild) {
print STDERR " already scheduled/built as build ", $prevBuild->id, "\n"; print STDERR " already scheduled/built as build ", $prevBuild->id, "\n";
$buildIds->{$prevBuild->id} = 0; $buildIds->{$prevBuild->id} = 0;
@ -953,10 +953,10 @@ sub checkBuild {
, system => $buildInfo->{system} , system => $buildInfo->{system}
, nixexprinput => $jobset->nixexprinput , nixexprinput => $jobset->nixexprinput
, nixexprpath => $jobset->nixexprpath , nixexprpath => $jobset->nixexprpath
, priority => $priority , priority => $priority
, busy => 0 , busy => 0
, locker => "" , locker => ""
, %extraFlags , %extraFlags
}); });
$buildIds->{$build->id} = 1; $buildIds->{$build->id} = 1;
@ -1013,17 +1013,17 @@ sub restartBuild {
my $paths = ""; my $paths = "";
foreach my $bs ($build->buildsteps) { foreach my $bs ($build->buildsteps) {
$paths = $paths . " " . $bs->outpath; $paths = $paths . " " . $bs->outpath;
} }
my $r = `nix-store --clear-failed-paths $paths $outpath`; my $r = `nix-store --clear-failed-paths $paths $outpath`;
$build->update( $build->update(
{ finished => 0 { finished => 0
, timestamp => time , timestamp => time
, busy => 0 , busy => 0
, locker => "" , locker => ""
}); });
# Reset the stats for the evals to which this build belongs. # Reset the stats for the evals to which this build belongs.
# !!! Should do this in a trigger. # !!! Should do this in a trigger.

View file

@ -172,7 +172,7 @@ sub jobsetOverview {
, "(select count(*) from Builds as a where a.finished = 1 and me.project = a.project and me.name = a.jobset and buildstatus = 0 and a.isCurrent = 1)" , "(select count(*) from Builds as a where a.finished = 1 and me.project = a.project and me.name = a.jobset and buildstatus = 0 and a.isCurrent = 1)"
, "(select count(*) from Builds as a where me.project = a.project and me.name = a.jobset and a.isCurrent = 1)" , "(select count(*) from Builds as a where me.project = a.project and me.name = a.jobset and a.isCurrent = 1)"
] ]
, "+as" => ["nrscheduled", "nrfailed", "nrsucceeded", "nrtotal"] , "+as" => ["nrscheduled", "nrfailed", "nrsucceeded", "nrtotal"]
}); });
} }

View file

@ -13,7 +13,7 @@ sub process {
my $s = "NIXPKG1 " . $c->stash->{manifestUri} my $s = "NIXPKG1 " . $c->stash->{manifestUri}
. " " . $build->nixname . " " . $build->system . " " . $build->nixname . " " . $build->system
. " " . $build->drvpath . " " . $build->outpath . " " . $build->drvpath . " " . $build->outpath
. " " . $c->uri_for('/'); . " " . $c->uri_for('/');
$c->response->body($s); $c->response->body($s);