From 3b504b23707beb381a52c86af6766b83591cfaba Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Tue, 19 Jan 2010 14:15:31 +0000 Subject: [PATCH] * hydra: added variant of build input type, 'build output (same system)' to allow better continous integration in one jobset for multiple system. it makes sure that the system of the build that is passed as input for a job has the same system as the job. --- deps.nix | 2 + src/lib/Hydra/Controller/Jobset.pm | 2 +- src/lib/Hydra/Helper/AddBuilds.pm | 62 +++++++++++++++++++++++++++++- src/root/build.tt | 2 +- src/root/clone-build.tt | 2 +- src/root/common.tt | 1 + src/script/hydra_build.pl | 4 +- src/script/hydra_scheduler.pl | 13 +++++-- 8 files changed, 79 insertions(+), 9 deletions(-) diff --git a/deps.nix b/deps.nix index f9caefb7..567e3e9c 100644 --- a/deps.nix +++ b/deps.nix @@ -19,5 +19,7 @@ with pkgs; perlPackages.EmailSimpleCreator perlPackages.TextTable perlPackages.NetTwitterLite + perlPackages.PadWalker + perlPackages.DataDump ] diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 467cc30a..2be8b01f 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -120,7 +120,7 @@ sub checkInput { error($c, "Invalid input type: $inputType") unless $inputType eq "svn" || $inputType eq "cvs" || $inputType eq "tarball" || $inputType eq "string" || $inputType eq "path" || $inputType eq "boolean" || - $inputType eq "git" || $inputType eq "build"; + $inputType eq "git" || $inputType eq "build" || $inputType eq "sysbuild" ; return ($inputName, $inputType); } diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index 0176fbde..5b2d1039 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -215,6 +215,48 @@ sub fetchInputBuild { }; } +sub fetchInputSystemBuild { + my ($db, $project, $jobset, $name, $type, $value) = @_; + + my ($projectName, $jobsetName, $jobName, $attrs) = parseJobName($value); + $projectName ||= $project->name; + $jobsetName ||= $jobset->name; + + my @latestBuilds = $db->resultset('LatestSucceededForJob') + ->search({}, {bind => [$projectName, $jobsetName, $jobName]}); + + my @validBuilds = (); + foreach my $build (@latestBuilds) { + if(isValidPath($build->outpath)) { + push(@validBuilds,$build); + } + } + + if (scalar(@validBuilds) == 0) { + print STDERR "input `", $name, "': no previous build available\n"; + return undef; + } + + my @inputs = (); + foreach my $prevBuild (@validBuilds) { + my $pkgNameRE = "(?:(?:[A-Za-z0-9]|(?:-[^0-9]))+)"; + my $versionRE = "(?:[A-Za-z0-9\.\-]+)"; + + my $relName = ($prevBuild->resultInfo->releasename or $prevBuild->nixname); + my $version = $2 if $relName =~ /^($pkgNameRE)-($versionRE)$/; + + my $input = + { type => "sysbuild" + , storePath => $prevBuild->outpath + , id => $prevBuild->id + , version => $version + , system => $prevBuild->system + }; + push(@inputs, $input); + } + return @inputs; +} + sub fetchInputGit { my ($db, $project, $jobset, $name, $type, $value) = @_; @@ -318,6 +360,9 @@ sub fetchInput { elsif ($type eq "build") { return fetchInputBuild($db, $project, $jobset, $name, $type, $value); } + elsif ($type eq "sysbuild") { + return fetchInputSystemBuild($db, $project, $jobset, $name, $type, $value); + } elsif ($type eq "git") { return fetchInputGit($db, $project, $jobset, $name, $type, $value); } @@ -351,7 +396,7 @@ sub inputsToArgs { when ("boolean") { push @res, "--arg", $input, $alt->{value}; } - when (["svn", "path", "build", "git", "cvs"]) { + when (["svn", "path", "build", "git", "cvs", "sysbuild"]) { push @res, "--arg", $input, ( "{ outPath = builtins.storePath " . $alt->{storePath} . "" . (defined $alt->{revision} ? "; rev = \"" . $alt->{revision} . "\"" : "") . @@ -397,6 +442,21 @@ sub evalJobs { SuppressEmpty => '') or die "cannot parse XML output"; + my @filteredJobs = (); + foreach my $job (@{$jobs->{job}}) { + my $validJob = 1; + foreach my $arg (@{$job->{arg}}) { + my $input = $inputInfo->{$arg->{name}}->[$arg->{altnr}] ; + if($input->{type} eq "sysbuild" && ! ($input->{system} eq $job->{system}) ) { + $validJob = 0 ; + } + } + if($validJob) { + push(@filteredJobs, $job); + } + } + $jobs->{job} = \@filteredJobs; + return ($jobs, $nixExprInput); } diff --git a/src/root/build.tt b/src/root/build.tt index 9f9366d7..e9de3dd1 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -255,7 +255,7 @@ [% input.name %] [% type = input.type; inputTypes.$type %] - [% IF input.type == "build" %] + [% IF input.type == "build" || input.type == "sysbuild" %] Job [% INCLUDE renderFullJobNameOfBuild build=input.dependency %] build [% input.dependency.id %] [% ELSIF input.type == "string" || input.type == "boolean" %] "[% input.value %]" diff --git a/src/root/clone-build.tt b/src/root/clone-build.tt index ba8151bc..3d6af138 100644 --- a/src/root/clone-build.tt +++ b/src/root/clone-build.tt @@ -34,7 +34,7 @@ build.project.name _ ':' _ build.jobset.name _ ':' _ build.job.name _ '[id="'_ build.id _ '"]' ) %] [% ELSE %] diff --git a/src/root/common.tt b/src/root/common.tt index ea967b5c..ce978905 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -11,6 +11,7 @@ , "boolean" = "Boolean" , "path" = "Local path" , "build" = "Build output" + , "sysbuild" = "Build output (same system)" } %] diff --git a/src/script/hydra_build.pl b/src/script/hydra_build.pl index 7b2aee9b..4b503eae 100755 --- a/src/script/hydra_build.pl +++ b/src/script/hydra_build.pl @@ -14,7 +14,7 @@ use Config::General; use Text::Table; use POSIX qw(strftime); use Net::Twitter::Lite; - +use Data::Dump qw(dump); STDOUT->autoflush(); @@ -138,7 +138,7 @@ sub sendEmailNotification { push @lines, [ $input->name , $input->type - , $input->type eq "build" + , ( $input->type eq "build" || $input->type eq "sysbuild") ? $input->dependency->id : ($input->type eq "string" || $input->type eq "boolean") ? $input->value : ($input->uri . ':' . $input->revision) diff --git a/src/script/hydra_scheduler.pl b/src/script/hydra_scheduler.pl index 48ae543d..77b5cdad 100755 --- a/src/script/hydra_scheduler.pl +++ b/src/script/hydra_scheduler.pl @@ -13,7 +13,7 @@ use Email::Simple; use Email::Simple::Creator; use Sys::Hostname::Long; use Config::General; - +use Data::Dump qw(dump); STDOUT->autoflush(); @@ -24,8 +24,15 @@ sub fetchInputs { my ($project, $jobset, $inputInfo) = @_; foreach my $input ($jobset->jobsetinputs->all) { foreach my $alt ($input->jobsetinputalts->all) { - my $info = fetchInput($db, $project, $jobset, $input->name, $input->type, $alt->value); - push @{$$inputInfo{$input->name}}, $info if defined $info; + if($input->type eq "sysbuild") { + my @info = fetchInput($db, $project, $jobset, $input->name, $input->type, $alt->value); + foreach my $info_el (@info) { + push @{$$inputInfo{$input->name}}, $info_el if defined $info_el; + } + } else { + my $info = fetchInput($db, $project, $jobset, $input->name, $input->type, $alt->value); + push @{$$inputInfo{$input->name}}, $info if defined $info; + } } } }