From aa28ffe3a829dc648161f0ff7e5dcf3c2a92ec48 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 22 Jan 2013 14:09:37 +0100 Subject: [PATCH] Die tabs die --- src/lib/Hydra/Base/Controller/ListBuilds.pm | 4 +- src/lib/Hydra/Controller/API.pm | 12 ++-- src/lib/Hydra/Controller/Admin.pm | 22 +++---- src/lib/Hydra/Controller/Build.pm | 24 +++---- src/lib/Hydra/Controller/Job.pm | 18 +++--- src/lib/Hydra/Controller/Jobset.pm | 12 ++-- src/lib/Hydra/Controller/JobsetEval.pm | 2 +- src/lib/Hydra/Controller/Project.pm | 2 +- src/lib/Hydra/Controller/Root.pm | 8 +-- src/lib/Hydra/Helper/AddBuilds.pm | 72 ++++++++++----------- src/lib/Hydra/Helper/Nix.pm | 2 +- src/lib/Hydra/View/NixPkg.pm | 2 +- 12 files changed, 90 insertions(+), 90 deletions(-) diff --git a/src/lib/Hydra/Base/Controller/ListBuilds.pm b/src/lib/Hydra/Base/Controller/ListBuilds.pm index 2cf70d75..151fe8e3 100644 --- a/src/lib/Hydra/Base/Controller/ListBuilds.pm +++ b/src/lib/Hydra/Base/Controller/ListBuilds.pm @@ -93,7 +93,7 @@ sub latest : Chained('get_builds') PathPart('latest') { my ($self, $c, @rest) = @_; 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; @@ -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; 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; diff --git a/src/lib/Hydra/Controller/API.pm b/src/lib/Hydra/Controller/API.pm index 3d412310..283ea0c3 100644 --- a/src/lib/Hydra/Controller/API.pm +++ b/src/lib/Hydra/Controller/API.pm @@ -103,8 +103,8 @@ sub latestbuilds : Chained('api') PathPart('latestbuilds') Args(0) { sub jobsetToHash { my ($jobset) = @_; return { - project => $jobset->project->name, - name => $jobset->name, + project => $jobset->project->name, + name => $jobset->name, nrscheduled => $jobset->get_column("nrscheduled"), nrsucceeded => $jobset->get_column("nrsucceeded"), nrfailed => $jobset->get_column("nrfailed"), @@ -222,13 +222,13 @@ sub scmdiff : Chained('api') PathPart('scmdiff') Args(0) { my $clonePath = scmPath . "/" . sha256_hex($uri); die if ! -d $clonePath; $branch = `(cd $clonePath; hg log --template '{branch}' -r $rev2)`; - $diff .= `(cd $clonePath; hg log -r $rev1 -r $rev2 -b $branch)`; - $diff .= `(cd $clonePath; hg diff -r $rev1:$rev2)`; + $diff .= `(cd $clonePath; hg log -r $rev1 -r $rev2 -b $branch)`; + $diff .= `(cd $clonePath; hg diff -r $rev1:$rev2)`; } elsif ($type eq "git") { my $clonePath = scmPath . "/" . sha256_hex($uri); die if ! -d $clonePath; - $diff .= `(cd $clonePath; git log $rev1..$rev2)`; - $diff .= `(cd $clonePath; git diff $rev1..$rev2)`; + $diff .= `(cd $clonePath; git log $rev1..$rev2)`; + $diff .= `(cd $clonePath; git diff $rev1..$rev2)`; } $c->stash->{'plain'} = { data => (scalar $diff) || " " }; diff --git a/src/lib/Hydra/Controller/Admin.pm b/src/lib/Hydra/Controller/Admin.pm index ef3fa6f8..f71ffcc4 100644 --- a/src/lib/Hydra/Controller/Admin.pm +++ b/src/lib/Hydra/Controller/Admin.pm @@ -21,14 +21,14 @@ sub nixMachines { my $result = "# GENERATED BY HYDRA\n"; foreach my $machine ($c->model("DB::BuildMachines")->all) { - if($machine->enabled) { - $result = $result . $machine->username . '@'. $machine->hostname . ' '; - foreach my $system ($machine->buildmachinesystemtypes) { - $result = $result . $system->system .','; - } - chop $result; - $result = $result . ' '. $machine->ssh_key . ' ' . $machine->maxconcurrent . ' '. $machine->speedfactor . ' ' . $machine->options . "\n"; - } + if($machine->enabled) { + $result = $result . $machine->username . '@'. $machine->hostname . ' '; + foreach my $system ($machine->buildmachinesystemtypes) { + $result = $result . $system->system .','; + } + chop $result; + $result = $result . ' '. $machine->ssh_key . ' ' . $machine->maxconcurrent . ' '. $machine->speedfactor . ' ' . $machine->options . "\n"; + } } return $result; } @@ -284,9 +284,9 @@ sub updateMachine { }); $machine->buildmachinesystemtypes->delete_all; if(ref($systems) eq 'ARRAY') { - for my $s (@$systems) { - $machine->buildmachinesystemtypes->create({ system => $s}) ; - } + for my $s (@$systems) { + $machine->buildmachinesystemtypes->create({ system => $s}) ; + } } else { $machine->buildmachinesystemtypes->create({ system => $systems}) ; } diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 59a1c663..ab623c9d 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -60,7 +60,7 @@ sub view_build : Chained('build') PathPart('') Args(0) { (my $lastBuildStep) = $build->buildsteps->search({},{order_by => "stepnr DESC", rows => 1}); my $path = defined $lastBuildStep ? $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); } @@ -140,8 +140,8 @@ sub showLog { } elsif ($mode eq "tail-reload") { - my $url = $c->request->uri->as_string; - $url =~ s/tail-reload/tail/g; + my $url = $c->request->uri->as_string; + $url =~ s/tail-reload/tail/g; $c->stash->{url} = $url; $c->stash->{reload} = !$c->stash->{build}->finished && $c->stash->{build}->busy; $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); foreach my $p (@buildtimepaths) { - my $buildStep; - ($buildStep) = $c->model('DB::BuildSteps')->search({ outpath => $p }, {}) ; - my %dep = ( buildstep => $buildStep, path => $p ) ; - push(@buildtimedeps, \%dep); + my $buildStep; + ($buildStep) = $c->model('DB::BuildSteps')->search({ outpath => $p }, {}) ; + my %dep = ( buildstep => $buildStep, path => $p ) ; + push(@buildtimedeps, \%dep); } foreach my $p (@runtimepaths) { - my $buildStep; - ($buildStep) = $c->model('DB::BuildSteps')->search({ outpath => $p }, {}) ; - my %dep = ( buildstep => $buildStep, path => $p ) ; - push(@runtimedeps, \%dep); + my $buildStep; + ($buildStep) = $c->model('DB::BuildSteps')->search({ outpath => $p }, {}) ; + my %dep = ( buildstep => $buildStep, path => $p ) ; + 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 # build expression. my $exprType = - $c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix"; + $c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix"; my $jobName = trim $c->request->params->{"jobname"}; error($c, "Invalid job name: $jobName") if $jobName !~ /^$jobNameRE$/; diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm index 2f442629..eedadc23 100644 --- a/src/lib/Hydra/Controller/Job.pm +++ b/src/lib/Hydra/Controller/Job.pm @@ -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->{lastBuilds} = - [ $c->stash->{job}->builds->search({ finished => 1 }, - { order_by => 'timestamp DESC', rows => 10, columns => [@buildListColumns] }) ]; + [ $c->stash->{job}->builds->search({ finished => 1 }, + { order_by => 'timestamp DESC', rows => 10, columns => [@buildListColumns] }) ]; $c->stash->{runningBuilds} = [ - $c->stash->{job}->builds->search( - { busy => 1 }, - { join => ['project'] - , order_by => ["priority DESC", "timestamp"] + $c->stash->{job}->builds->search( + { busy => 1 }, + { join => ['project'] + , order_by => ["priority DESC", "timestamp"] , '+select' => ['project.enabled'] - , '+as' => ['enabled'] - } - ) ]; + , '+as' => ['enabled'] + } + ) ]; $c->stash->{systems} = [$c->stash->{job}->builds->search({iscurrent => 1}, {select => ["system"], distinct => 1})]; } diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 2651fd11..e8e09efe 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -57,7 +57,7 @@ sub jobsetIndex { # status per system my @systems = (); foreach my $system (@{$c->stash->{systems}}) { - push(@systems, $system->system); + push(@systems, $system->system); } if($forceStatus || scalar(@{$c->stash->{activeJobs}}) <= 100) { @@ -74,10 +74,10 @@ sub jobsetIndex { [ $c->model('DB')->resultset('ActiveJobsForJobset')->search( {}, { bind => [$c->stash->{project}->name, $c->stash->{jobset}->name] - , select => \@select - , as => \@as - , order_by => ["job"] - })]; + , select => \@select + , as => \@as + , order_by => ["job"] + })]; } } @@ -226,7 +226,7 @@ sub updateJobset { # When the expression is in a .scm file, assume it's a Guile + Guix # build expression. my $exprType = - $c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix"; + $c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix"; my ($nixExprPath, $nixExprInput) = nixExprPathFromParams $c; diff --git a/src/lib/Hydra/Controller/JobsetEval.pm b/src/lib/Hydra/Controller/JobsetEval.pm index 849d4209..17705b59 100644 --- a/src/lib/Hydra/Controller/JobsetEval.pm +++ b/src/lib/Hydra/Controller/JobsetEval.pm @@ -11,7 +11,7 @@ sub eval : Chained('/') PathPart('eval') CaptureArgs(1) { my ($self, $c, $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->{project} = $eval->project; diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index c2474e9a..6eaca818 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -147,7 +147,7 @@ sub create_jobset_submit : Chained('project') PathPart('create-jobset/submit') A my $jobsetName = trim $c->request->params->{name}; 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$/; diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 9a2b0c39..d21d7ad9 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -23,8 +23,8 @@ sub begin :Private { $c->stash->{tracker} = $ENV{"HYDRA_TRACKER"} ; if (scalar(@args) == 0 || $args[0] ne "static") { - $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->{nrRunningBuilds} = $c->model('DB::Builds')->search({ finished => 0, busy => 1 }, {})->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 => #"StoreDir: $Nix::Config::storeDir\n" . # FIXME "StoreDir: /nix/store\n" . - "WantMassQuery: 0\n" . + "WantMassQuery: 0\n" . # Give Hydra binary caches a very low priority (lower than the # static binary cache http://nixos.org/binary-cache). - "Priority: 100\n" + "Priority: 100\n" }; $c->forward('Hydra::View::Plain'); } diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index c51757cc..1253b74a 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -637,7 +637,7 @@ sub fetchInput { } foreach my $input (@inputs) { - $input->{type} = $type if defined $input; + $input->{type} = $type if defined $input; } return @inputs; @@ -648,14 +648,14 @@ sub booleanToString { my ($exprType, $value) = @_; my $result; if ($exprType eq "guile") { - if ($value eq "true") { - $result = "#t"; - } else { - $result = "#f"; - } - $result = $value; + if ($value eq "true") { + $result = "#t"; + } else { + $result = "#f"; + } + $result = $value; } else { - $result = $value; + $result = $value; } return $result; } @@ -664,21 +664,21 @@ sub buildInputToString { my ($exprType, $input) = @_; my $result; if ($exprType eq "guile") { - $result = "'((file-name . \"" . ${input}->{storePath} . "\")" . - (defined $input->{revision} ? "(revision . \"" . $input->{revision} . "\")" : "") . - (defined $input->{revCount} ? "(revision-count . " . $input->{revCount} . ")" : "") . - (defined $input->{gitTag} ? "(git-tag . \"" . $input->{gitTag} . "\")" : "") . - (defined $input->{shortRev} ? "(short-revision . \"" . $input->{shortRev} . "\")" : "") . - (defined $input->{version} ? "(version . \"" . $input->{version} . "\")" : "") . - ")"; + $result = "'((file-name . \"" . ${input}->{storePath} . "\")" . + (defined $input->{revision} ? "(revision . \"" . $input->{revision} . "\")" : "") . + (defined $input->{revCount} ? "(revision-count . " . $input->{revCount} . ")" : "") . + (defined $input->{gitTag} ? "(git-tag . \"" . $input->{gitTag} . "\")" : "") . + (defined $input->{shortRev} ? "(short-revision . \"" . $input->{shortRev} . "\")" : "") . + (defined $input->{version} ? "(version . \"" . $input->{version} . "\")" : "") . + ")"; } else { - $result = "{ outPath = builtins.storePath " . $input->{storePath} . "" . - (defined $input->{revision} ? "; rev = \"" . $input->{revision} . "\"" : "") . - (defined $input->{revCount} ? "; revCount = " . $input->{revCount} . "" : "") . - (defined $input->{gitTag} ? "; gitTag = \"" . $input->{gitTag} . "\"" : "") . - (defined $input->{shortRev} ? "; shortRev = \"" . $input->{shortRev} . "\"" : "") . - (defined $input->{version} ? "; version = \"" . $input->{version} . "\"" : "") . - ";}"; + $result = "{ outPath = builtins.storePath " . $input->{storePath} . "" . + (defined $input->{revision} ? "; rev = \"" . $input->{revision} . "\"" : "") . + (defined $input->{revCount} ? "; revCount = " . $input->{revCount} . "" : "") . + (defined $input->{gitTag} ? "; gitTag = \"" . $input->{gitTag} . "\"" : "") . + (defined $input->{shortRev} ? "; shortRev = \"" . $input->{shortRev} . "\"" : "") . + (defined $input->{version} ? "; version = \"" . $input->{version} . "\"" : "") . + ";}"; } return $result; } @@ -898,12 +898,12 @@ sub checkBuild { # scheduled if the meta.maintainers field is changed? if (defined $prevEval) { my ($prevBuild) = $prevEval->builds->search( - # The "project" and "jobset" constraints are - # semantically unnecessary (because they're implied by - # the eval), but they give a factor 1000 speedup on - # the Nixpkgs jobset with PostgreSQL. - { project => $project->name, jobset => $jobset->name, job => $job->name, outPath => $outPath }, - { rows => 1, columns => ['id'] }); + # The "project" and "jobset" constraints are + # semantically unnecessary (because they're implied by + # the eval), but they give a factor 1000 speedup on + # the Nixpkgs jobset with PostgreSQL. + { project => $project->name, jobset => $jobset->name, job => $job->name, outPath => $outPath }, + { rows => 1, columns => ['id'] }); if (defined $prevBuild) { print STDERR " already scheduled/built as build ", $prevBuild->id, "\n"; $buildIds->{$prevBuild->id} = 0; @@ -953,10 +953,10 @@ sub checkBuild { , system => $buildInfo->{system} , nixexprinput => $jobset->nixexprinput , nixexprpath => $jobset->nixexprpath - , priority => $priority - , busy => 0 - , locker => "" - , %extraFlags + , priority => $priority + , busy => 0 + , locker => "" + , %extraFlags }); $buildIds->{$build->id} = 1; @@ -1013,17 +1013,17 @@ sub restartBuild { my $paths = ""; foreach my $bs ($build->buildsteps) { - $paths = $paths . " " . $bs->outpath; + $paths = $paths . " " . $bs->outpath; } my $r = `nix-store --clear-failed-paths $paths $outpath`; $build->update( - { finished => 0 - , timestamp => time + { finished => 0 + , timestamp => time , busy => 0 , locker => "" - }); + }); # Reset the stats for the evals to which this build belongs. # !!! Should do this in a trigger. diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 136131dc..b3d91948 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -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 me.project = a.project and me.name = a.jobset and a.isCurrent = 1)" ] - , "+as" => ["nrscheduled", "nrfailed", "nrsucceeded", "nrtotal"] + , "+as" => ["nrscheduled", "nrfailed", "nrsucceeded", "nrtotal"] }); } diff --git a/src/lib/Hydra/View/NixPkg.pm b/src/lib/Hydra/View/NixPkg.pm index 71527e1d..945a0b82 100644 --- a/src/lib/Hydra/View/NixPkg.pm +++ b/src/lib/Hydra/View/NixPkg.pm @@ -13,7 +13,7 @@ sub process { my $s = "NIXPKG1 " . $c->stash->{manifestUri} . " " . $build->nixname . " " . $build->system . " " . $build->drvpath . " " . $build->outpath - . " " . $c->uri_for('/'); + . " " . $c->uri_for('/'); $c->response->body($s);