From cec32017202edc9fcc9fcdce896e51837c179a1c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 15 Oct 2009 21:35:19 +0000 Subject: [PATCH] * Renaming "release sets" to "views" (not finished yet). Having releases as a dynamic view on the database was misguided, since doing thing like adding a new job to a release set will invalidate all old releases. So we rename release sets to views, and we'll reintroduce releases as separate, static entities in the database. --- doc/dev-notes.txt | 9 + src/lib/Hydra/Controller/Project.pm | 2 +- src/lib/Hydra/Controller/Root.pm | 186 ------------------ src/lib/Hydra/Controller/View.pm | 161 +++++++++++++++ src/lib/Hydra/Helper/Nix.pm | 10 +- src/lib/Hydra/Schema.pm | 4 +- src/lib/Hydra/Schema/BuildInputs.pm | 4 +- src/lib/Hydra/Schema/BuildProducts.pm | 4 +- src/lib/Hydra/Schema/BuildResultInfo.pm | 4 +- src/lib/Hydra/Schema/BuildSchedulingInfo.pm | 4 +- src/lib/Hydra/Schema/BuildSteps.pm | 4 +- src/lib/Hydra/Schema/Builds.pm | 4 +- src/lib/Hydra/Schema/CachedPathInputs.pm | 4 +- .../Hydra/Schema/CachedSubversionInputs.pm | 4 +- src/lib/Hydra/Schema/Jobs.pm | 4 +- src/lib/Hydra/Schema/JobsetInputAlts.pm | 4 +- src/lib/Hydra/Schema/JobsetInputs.pm | 4 +- src/lib/Hydra/Schema/Jobsets.pm | 4 +- src/lib/Hydra/Schema/Projects.pm | 12 +- src/lib/Hydra/Schema/SystemTypes.pm | 4 +- src/lib/Hydra/Schema/UserRoles.pm | 4 +- src/lib/Hydra/Schema/Users.pm | 4 +- .../Schema/{ReleaseSetJobs.pm => ViewJobs.pm} | 22 +-- .../Hydra/Schema/{ReleaseSets.pm => Views.pm} | 17 +- src/root/{edit-releaseset.tt => edit-view.tt} | 16 +- src/root/project.tt | 16 +- src/root/releases.tt | 75 ------- src/root/view.tt | 76 +++++++ src/sql/hydra.sql | 64 +++--- 29 files changed, 351 insertions(+), 379 deletions(-) create mode 100644 src/lib/Hydra/Controller/View.pm rename src/lib/Hydra/Schema/{ReleaseSetJobs.pm => ViewJobs.pm} (75%) rename src/lib/Hydra/Schema/{ReleaseSets.pm => Views.pm} (70%) rename src/root/{edit-releaseset.tt => edit-view.tt} (78%) delete mode 100644 src/root/releases.tt create mode 100644 src/root/view.tt diff --git a/doc/dev-notes.txt b/doc/dev-notes.txt index 56c25649..6dd51cbe 100644 --- a/doc/dev-notes.txt +++ b/doc/dev-notes.txt @@ -96,6 +96,15 @@ alter table Jobsets add column enabled integer not null default 1; + # Releases -> Views. + alter table ReleaseSets rename to Views; + alter table Views rename column name to view_; + alter table ReleaseSetJobs rename to ViewJobs; + alter table ViewJobs rename column release_ to view_; + alter table ViewJobs drop column mayFail; + alter table ViewJobs add column autorelease integer not null default 0; + + * Job selection: diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index e815280f..c6c43c1b 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -24,7 +24,7 @@ sub view : Chained('project') PathPart('') Args(0) { getBuildStats($c, scalar $c->stash->{project}->builds); - $c->stash->{releaseSets} = [$c->stash->{project}->releasesets->all]; + $c->stash->{views} = [$c->stash->{project}->views->all]; } diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 9c78a29e..e1e1cc86 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -63,192 +63,6 @@ sub queue :Local { } -sub getReleaseSet { - my ($c, $projectName, $releaseSetName) = @_; - - my $project = $c->model('DB::Projects')->find($projectName); - notFound($c, "Project $projectName doesn't exist.") if !defined $project; - $c->stash->{project} = $project; - - (my $releaseSet) = $c->model('DB::ReleaseSets')->find($projectName, $releaseSetName); - notFound($c, "Release set $releaseSetName doesn't exist.") if !defined $releaseSet; - $c->stash->{releaseSet} = $releaseSet; - - (my $primaryJob) = $releaseSet->releasesetjobs->search({isprimary => 1}); - #die "Release set $releaseSetName doesn't have a primary job." if !defined $primaryJob; - - my $jobs = [$releaseSet->releasesetjobs->search({}, - {order_by => ["isprimary DESC", "job", "attrs"]})]; - - $c->stash->{jobs} = $jobs; - - return ($project, $releaseSet, $primaryJob, $jobs); -} - - -sub updateReleaseSet { - my ($c, $releaseSet) = @_; - - my $releaseSetName = trim $c->request->params->{name}; - error($c, "Invalid release set name: $releaseSetName") - unless $releaseSetName =~ /^[[:alpha:]][\w\-]*$/; - - $releaseSet->update( - { name => $releaseSetName - , description => trim $c->request->params->{description} }); - - $releaseSet->releasesetjobs->delete_all; - - foreach my $param (keys %{$c->request->params}) { - next unless $param =~ /^job-(\d+)-name$/; - my $baseName = $1; - - my $name = trim $c->request->params->{"job-$baseName-name"}; - my $description = trim $c->request->params->{"job-$baseName-description"}; - my $attrs = trim $c->request->params->{"job-$baseName-attrs"}; - - $name =~ /^([\w\-]+):([\w\-]+)$/ or error($c, "Invalid job name: $name"); - my $jobsetName = $1; - my $jobName = $2; - - error($c, "Jobset `$jobsetName' doesn't exist.") - unless $releaseSet->project->jobsets->find({name => $jobsetName}); - - # !!! We could check whether the job exists, but that would - # require the scheduler to have seen the job, which may not be - # the case. - - $releaseSet->releasesetjobs->create( - { jobset => $jobsetName - , job => $jobName - , description => $description - , attrs => $attrs - , isprimary => $c->request->params->{"primary"} eq $baseName ? 1 : 0 - }); - } - - error($c, "There must be one primary job.") - if $releaseSet->releasesetjobs->search({isprimary => 1})->count != 1; -} - - -sub releases :Local { - my ($self, $c, $projectName, $releaseSetName, $subcommand) = @_; - - my ($project, $releaseSet, $primaryJob, $jobs) = getReleaseSet($c, $projectName, $releaseSetName); - - my $resultsPerPage = 10; - my $page = 1; - - if (defined $subcommand && $subcommand =~ /^\d+$/ ) { - $page = int($subcommand) - } - elsif (defined $subcommand && $subcommand ne "") { - - requireProjectOwner($c, $project); - - if ($subcommand eq "edit") { - $c->stash->{template} = 'edit-releaseset.tt'; - return; - } - - elsif ($subcommand eq "submit") { - txn_do($c->model('DB')->schema, sub { - updateReleaseSet($c, $releaseSet); - }); - return $c->res->redirect($c->uri_for("/releases", $projectName, $releaseSet->name)); - } - - elsif ($subcommand eq "delete") { - txn_do($c->model('DB')->schema, sub { - $releaseSet->delete; - }); - return $c->res->redirect($c->uri_for($c->controller('Project')->action_for('view'), [$project->name])); - } - - else { error($c, "Unknown subcommand."); } - } - - $c->stash->{template} = 'releases.tt'; - - my @releases = (); - push @releases, getRelease($_, $jobs) foreach getPrimaryBuildsForReleaseSet($project, $primaryJob, $page, $resultsPerPage); - - $c->stash->{baseUri} = $c->uri_for($self->action_for("releases"), $projectName, $releaseSetName); - $c->stash->{releases} = [@releases]; - $c->stash->{page} = $page; - $c->stash->{totalReleases} = getPrimaryBuildTotal($project, $primaryJob); - $c->stash->{resultsPerPage} = $resultsPerPage; -} - - -sub create_releaseset :Local { - my ($self, $c, $projectName, $subcommand) = @_; - - my $project = $c->model('DB::Projects')->find($projectName); - error($c, "Project $projectName doesn't exist.") if !defined $project; - $c->stash->{project} = $project; - - requireProjectOwner($c, $project); - - if (defined $subcommand && $subcommand eq "submit") { - my $releaseSetName = $c->request->params->{name}; - txn_do($c->model('DB')->schema, sub { - # Note: $releaseSetName is validated in updateProject, - # which will abort the transaction if the name isn't - # valid. - my $releaseSet = $project->releasesets->create({name => $releaseSetName}); - updateReleaseSet($c, $releaseSet); - return $c->res->redirect($c->uri_for("/releases", $projectName, $releaseSet->name)); - }); - } - - $c->stash->{template} = 'edit-releaseset.tt'; - $c->stash->{create} = 1; -} - - -sub release :Local { - my ($self, $c, $projectName, $releaseSetName, $releaseId, @args) = @_; - $c->stash->{template} = 'release.tt'; - - my ($project, $releaseSet, $primaryJob, $jobs) = getReleaseSet($c, $projectName, $releaseSetName); - - if ($releaseId eq "latest") { - # Redirect to the latest successful release. - my $latest = getLatestSuccessfulRelease($project, $primaryJob, $jobs); - error($c, "This release set has no successful releases yet.") if !defined $latest; - return $c->res->redirect($c->uri_for("/release", $projectName, $releaseSetName, $latest->id, @args)); - } - - # Note: we don't actually check whether $releaseId is a primary - # build, but who cares? - my $primaryBuild = $project->builds->find($releaseId, - { join => 'resultInfo', - , '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"] - , '+as' => ["releasename", "buildstatus"] }) - or error($c, "Release $releaseId doesn't exist."); - - $c->stash->{release} = getRelease($primaryBuild, $jobs); - - # Provide a redirect to the specified job of this release. !!! - # This isn't uniquely defined if there are multiple jobs with the - # same name (e.g. builds for different platforms). However, this - # mechanism is primarily to allow linking to resources of which - # there is only one build, such as the manual of the latest - # release. - if (scalar @args != 0) { - my $jobName = shift @args; - (my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$c->stash->{release}->{jobs}}; - notFound($c, "Release doesn't have a job named `$jobName'") - unless defined $build; - error($c, "Job `$jobName' isn't unique.") if @others; - return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('view_build'), - [$build->{build}->id], @args)); - } -} - - # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('/') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; diff --git a/src/lib/Hydra/Controller/View.pm b/src/lib/Hydra/Controller/View.pm new file mode 100644 index 00000000..11cf976d --- /dev/null +++ b/src/lib/Hydra/Controller/View.pm @@ -0,0 +1,161 @@ +package Hydra::Controller::View; + +use strict; +use warnings; +use base 'Catalyst::Controller'; +use Hydra::Helper::Nix; +use Hydra::Helper::CatalystUtils; + + +sub getView { + my ($c, $projectName, $viewName) = @_; + + my $project = $c->model('DB::Projects')->find($projectName); + notFound($c, "Project $projectName doesn't exist.") if !defined $project; + $c->stash->{project} = $project; + + (my $view) = $c->model('DB::Views')->find($projectName, $viewName); + notFound($c, "View $viewName doesn't exist.") if !defined $view; + $c->stash->{view} = $view; + + (my $primaryJob) = $view->viewjobs->search({isprimary => 1}); + #die "View $viewName doesn't have a primary job." if !defined $primaryJob; + + my $jobs = [$view->viewjobs->search({}, + {order_by => ["isprimary DESC", "job", "attrs"]})]; + + $c->stash->{jobs} = $jobs; + + return ($project, $view, $primaryJob, $jobs); +} + + +sub updateReleaseSet { + my ($c, $releaseSet) = @_; + + my $releaseSetName = trim $c->request->params->{name}; + error($c, "Invalid release set name: $releaseSetName") + unless $releaseSetName =~ /^[[:alpha:]][\w\-]*$/; + + $releaseSet->update( + { name => $releaseSetName + , description => trim $c->request->params->{description} }); + + $releaseSet->releasesetjobs->delete_all; + + foreach my $param (keys %{$c->request->params}) { + next unless $param =~ /^job-(\d+)-name$/; + my $baseName = $1; + + my $name = trim $c->request->params->{"job-$baseName-name"}; + my $description = trim $c->request->params->{"job-$baseName-description"}; + my $attrs = trim $c->request->params->{"job-$baseName-attrs"}; + + $name =~ /^([\w\-]+):([\w\-]+)$/ or error($c, "Invalid job name: $name"); + my $jobsetName = $1; + my $jobName = $2; + + error($c, "Jobset `$jobsetName' doesn't exist.") + unless $releaseSet->project->jobsets->find({name => $jobsetName}); + + # !!! We could check whether the job exists, but that would + # require the scheduler to have seen the job, which may not be + # the case. + + $releaseSet->releasesetjobs->create( + { jobset => $jobsetName + , job => $jobName + , description => $description + , attrs => $attrs + , isprimary => $c->request->params->{"primary"} eq $baseName ? 1 : 0 + }); + } + + error($c, "There must be one primary job.") + if $releaseSet->releasesetjobs->search({isprimary => 1})->count != 1; +} + + +sub view : Chained('/') PathPart('view') CaptureArgs(2) { + my ($self, $c, $projectName, $viewName) = @_; + my ($project, $view, $primaryJob, $jobs) = getView($c, $projectName, $viewName); + $c->stash->{project} = $project; + $c->stash->{view} = $view; + $c->stash->{primaryJob} = $primaryJob; + $c->stash->{jobs} = $jobs; +} + + +sub view_view : Chained('view') PathPart('') Args(0) { + my ($self, $c) = @_; + + $c->stash->{template} = 'view.tt'; + + my $resultsPerPage = 10; + my $page = int($c->req->param('page')) || 1; + + my @results = (); + push @results, getRelease($_, $c->stash->{jobs}) foreach + getPrimaryBuildsForReleaseSet($c->stash->{project}, $c->stash->{primaryJob}, $page, $resultsPerPage); + + $c->stash->{baseUri} = $c->uri_for($self->action_for("view"), $c->stash->{project}->name, $c->stash->{view}->name); + $c->stash->{results} = [@results]; + $c->stash->{page} = $page; + $c->stash->{totalResults} = getPrimaryBuildTotal($c->stash->{project}, $c->stash->{primaryJob}); + $c->stash->{resultsPerPage} = $resultsPerPage; +} + + +sub edit : Chained('view') PathPart('edit') Args(0) { + my ($self, $c) = @_; + requireProjectOwner($c, $c->stash->{project}); + $c->stash->{template} = 'edit-view.tt'; +} + + +sub latest : Chained('view') PathPart('latest') { + my ($self, $c, @args) = @_; + + # Redirect to the latest result in the view in which every build + # is successful. + my $latest = getLatestSuccessfulRelease( + $c->stash->{project}, $c->stash->{primaryJob}, $c->stash->{jobs}); + error($c, "This view set has no successful results yet.") if !defined $latest; + return $c->res->redirect($c->uri_for("/view", $c->stash->{project}->name, $c->stash->{view}->name, $latest->id, @args)); +} + + +sub result : Chained('view') PathPart('') { + my ($self, $c, $id, @args) = @_; + + $c->stash->{template} = 'release.tt'; + + # Note: we don't actually check whether $id is a primary build, + # but who cares? + my $primaryBuild = $c->stash->{project}->builds->find($id, + { join => 'resultInfo', + , '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"] + , '+as' => ["releasename", "buildstatus"] }) + or error($c, "Build $id doesn't exist."); + + $c->stash->{release} = getRelease($primaryBuild, $c->stash->{jobs}); + + # Provide a redirect to the specified job of this release. !!! + # This isn't uniquely defined if there are multiple jobs with the + # same name (e.g. builds for different platforms). However, this + # mechanism is primarily to allow linking to resources of which + # there is only one build, such as the manual of the latest + # release. + if (scalar @args != 0) { + my $jobName = shift @args; + (my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$c->stash->{release}->{jobs}}; + notFound($c, "Release doesn't have a job named `$jobName'") + unless defined $build; + error($c, "Job `$jobName' isn't unique.") if @others; + return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('view_build'), + [$build->{build}->id], @args)); + } +} + + +1; diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 5872bb0c..74cadbf8 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -239,12 +239,10 @@ sub getRelease { $thisBuild = findLastJobForPrimaryBuild($primaryBuild, $job) ; } - if ($job->mayfail != 1) { - if (!defined $thisBuild) { - $status = 2 if $status == 0; # = unfinished - } elsif ($thisBuild->get_column('buildstatus') != 0) { - $status = 1; # = failed - } + if (!defined $thisBuild) { + $status = 2 if $status == 0; # = unfinished + } elsif ($thisBuild->get_column('buildstatus') != 0) { + $status = 1; # = failed } $timestamp = $thisBuild->timestamp diff --git a/src/lib/Hydra/Schema.pm b/src/lib/Hydra/Schema.pm index 18602efc..f3e50c22 100644 --- a/src/lib/Hydra/Schema.pm +++ b/src/lib/Hydra/Schema.pm @@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema'; __PACKAGE__->load_classes; -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vdr83mcEie4i5Fn/Uj17Vg +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ODLRc6VfDQpb8MyXPKmqtg # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildInputs.pm b/src/lib/Hydra/Schema/BuildInputs.pm index 5fdb0d4a..f0767f74 100644 --- a/src/lib/Hydra/Schema/BuildInputs.pm +++ b/src/lib/Hydra/Schema/BuildInputs.pm @@ -103,8 +103,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yodYRloko+NdaEVy+IL5JA +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gtA3wQA2CLsXs4X95PfX9A use Hydra::Helper::Nix; diff --git a/src/lib/Hydra/Schema/BuildProducts.pm b/src/lib/Hydra/Schema/BuildProducts.pm index ab0ecd3f..d9579ef9 100644 --- a/src/lib/Hydra/Schema/BuildProducts.pm +++ b/src/lib/Hydra/Schema/BuildProducts.pm @@ -91,8 +91,8 @@ __PACKAGE__->set_primary_key("build", "productnr"); __PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GdjLBqXz+LK4ewxnpIs9eQ +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ii6N3v4M1fX1tQ3YmJNFWw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildResultInfo.pm b/src/lib/Hydra/Schema/BuildResultInfo.pm index 4554c2e0..84357722 100644 --- a/src/lib/Hydra/Schema/BuildResultInfo.pm +++ b/src/lib/Hydra/Schema/BuildResultInfo.pm @@ -86,8 +86,8 @@ __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" }); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KTPvLaqbXGpynWt107ISew +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EMvF2g+MDIE84yjnJOs7og __PACKAGE__->belongs_to( "failedDep", diff --git a/src/lib/Hydra/Schema/BuildSchedulingInfo.pm b/src/lib/Hydra/Schema/BuildSchedulingInfo.pm index 87bc2d1d..8ec329c4 100644 --- a/src/lib/Hydra/Schema/BuildSchedulingInfo.pm +++ b/src/lib/Hydra/Schema/BuildSchedulingInfo.pm @@ -43,8 +43,8 @@ __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" }); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:thMie1PGP25FGbo5qypE/w +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RcdX5dHefBQnxQYbMxNF/w # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildSteps.pm b/src/lib/Hydra/Schema/BuildSteps.pm index 60bd120c..e3bcf63e 100644 --- a/src/lib/Hydra/Schema/BuildSteps.pm +++ b/src/lib/Hydra/Schema/BuildSteps.pm @@ -91,7 +91,7 @@ __PACKAGE__->set_primary_key("build", "stepnr"); __PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Ua+P31BMRmMKP6QFOdA89A +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1AQCHpuv8Lqk/FYdU8JYFA 1; diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm index 60fca2f1..dd1c0299 100644 --- a/src/lib/Hydra/Schema/Builds.pm +++ b/src/lib/Hydra/Schema/Builds.pm @@ -163,8 +163,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:luxYxoOAtLoCgl5iFTYdJA +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CcYlMej7OPRUJn6375Qlqw use Hydra::Helper::Nix; diff --git a/src/lib/Hydra/Schema/CachedPathInputs.pm b/src/lib/Hydra/Schema/CachedPathInputs.pm index 9c5f4a51..d3b71bcd 100644 --- a/src/lib/Hydra/Schema/CachedPathInputs.pm +++ b/src/lib/Hydra/Schema/CachedPathInputs.pm @@ -47,8 +47,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("srcpath", "sha256hash"); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DeoyeS42ddQ2FXa+8n31OQ +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mYBdemei1tFuK8Ll6eMLfQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/CachedSubversionInputs.pm b/src/lib/Hydra/Schema/CachedSubversionInputs.pm index aa5a758e..85e0f3a6 100644 --- a/src/lib/Hydra/Schema/CachedSubversionInputs.pm +++ b/src/lib/Hydra/Schema/CachedSubversionInputs.pm @@ -40,8 +40,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("uri", "revision"); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CaFTGQtLjPwCISqk5W4fag +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bE+w54cACUS2L0PJ9gPjtw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Jobs.pm b/src/lib/Hydra/Schema/Jobs.pm index 4f27c1bc..fe899dba 100644 --- a/src/lib/Hydra/Schema/Jobs.pm +++ b/src/lib/Hydra/Schema/Jobs.pm @@ -75,8 +75,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+Cb0mIbX8ddDbZY39u9feA +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:c0OEe2zPd/E4vh0PRXm4Ag # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/JobsetInputAlts.pm b/src/lib/Hydra/Schema/JobsetInputAlts.pm index 76f1d258..8ad27cfc 100644 --- a/src/lib/Hydra/Schema/JobsetInputAlts.pm +++ b/src/lib/Hydra/Schema/JobsetInputAlts.pm @@ -69,8 +69,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:m3a1Q6c2FePidqbqYhz5dg +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jS8pitmHFnplE8WcK0OyMQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/JobsetInputs.pm b/src/lib/Hydra/Schema/JobsetInputs.pm index 14188fec..e6b5f58d 100644 --- a/src/lib/Hydra/Schema/JobsetInputs.pm +++ b/src/lib/Hydra/Schema/JobsetInputs.pm @@ -65,8 +65,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QSYSg5xsN292LnfvbAG0Vw +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:W0rhMTOzLBZNsVShQHg5+A # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index 892450f2..5d9bad3c 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -103,8 +103,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:85FwtlvNxjGix7PUCJTMqA +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CB5lPsrozpvO8gLXHTyMrQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Projects.pm b/src/lib/Hydra/Schema/Projects.pm index cebd29e4..c85ab2b2 100644 --- a/src/lib/Hydra/Schema/Projects.pm +++ b/src/lib/Hydra/Schema/Projects.pm @@ -65,19 +65,19 @@ __PACKAGE__->has_many( { "foreign.project" => "self.name" }, ); __PACKAGE__->has_many( - "releasesets", - "Hydra::Schema::ReleaseSets", + "views", + "Hydra::Schema::Views", { "foreign.project" => "self.name" }, ); __PACKAGE__->has_many( - "releasesetjobs", - "Hydra::Schema::ReleaseSetJobs", + "viewjobs", + "Hydra::Schema::ViewJobs", { "foreign.project" => "self.name" }, ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Dru36PNUe9iYHEwhhHKJ3A +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:N6NPLJfc1gKM4zz6dS5PJw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/SystemTypes.pm b/src/lib/Hydra/Schema/SystemTypes.pm index 99c87e8d..93312a75 100644 --- a/src/lib/Hydra/Schema/SystemTypes.pm +++ b/src/lib/Hydra/Schema/SystemTypes.pm @@ -21,8 +21,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("system"); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mfZTzyri5eSRhfmBmwyuFQ +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EkpopxgwlZf8Du3EmWzTKQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/UserRoles.pm b/src/lib/Hydra/Schema/UserRoles.pm index 39752056..c01878dc 100644 --- a/src/lib/Hydra/Schema/UserRoles.pm +++ b/src/lib/Hydra/Schema/UserRoles.pm @@ -28,8 +28,8 @@ __PACKAGE__->set_primary_key("username", "role"); __PACKAGE__->belongs_to("username", "Hydra::Schema::Users", { username => "username" }); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6RgJY04rmD+PumWXz5KGoQ +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:W2Q6219GlZl2IqQkBoFmFA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Users.pm b/src/lib/Hydra/Schema/Users.pm index d0dbee72..4ad1f94d 100644 --- a/src/lib/Hydra/Schema/Users.pm +++ b/src/lib/Hydra/Schema/Users.pm @@ -50,8 +50,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZWzljXMF0IbU12wNUn+djg +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qH+qBI3xxQgTNf3v7E3sDw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/ReleaseSetJobs.pm b/src/lib/Hydra/Schema/ViewJobs.pm similarity index 75% rename from src/lib/Hydra/Schema/ReleaseSetJobs.pm rename to src/lib/Hydra/Schema/ViewJobs.pm index ad7f9abb..3dc22793 100644 --- a/src/lib/Hydra/Schema/ReleaseSetJobs.pm +++ b/src/lib/Hydra/Schema/ViewJobs.pm @@ -1,4 +1,4 @@ -package Hydra::Schema::ReleaseSetJobs; +package Hydra::Schema::ViewJobs; use strict; use warnings; @@ -6,7 +6,7 @@ use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components("Core"); -__PACKAGE__->table("ReleaseSetJobs"); +__PACKAGE__->table("ViewJobs"); __PACKAGE__->add_columns( "project", { @@ -16,7 +16,7 @@ __PACKAGE__->add_columns( is_nullable => 0, size => undef, }, - "release_", + "view_", { data_type => "text", default_value => undef, @@ -40,8 +40,6 @@ __PACKAGE__->add_columns( }, "isprimary", { data_type => "integer", default_value => 0, is_nullable => 0, size => undef }, - "mayfail", - { data_type => "integer", default_value => 0, is_nullable => 0, size => undef }, "description", { data_type => "text", @@ -56,18 +54,20 @@ __PACKAGE__->add_columns( is_nullable => 0, size => undef, }, + "autorelease", + { data_type => "integer", default_value => 0, is_nullable => 0, size => undef }, ); -__PACKAGE__->set_primary_key("project", "release_", "job", "attrs"); +__PACKAGE__->set_primary_key("project", "view_", "job", "attrs"); __PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }); __PACKAGE__->belongs_to( - "releaseset", - "Hydra::Schema::ReleaseSets", - { name => "release_", project => "project" }, + "view", + "Hydra::Schema::Views", + { name => "view_", project => "project" }, ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qSQjyHzxQp0qO3CbRdcXmw +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LkiGAkZOiLNJk6oDY0+zNw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/ReleaseSets.pm b/src/lib/Hydra/Schema/Views.pm similarity index 70% rename from src/lib/Hydra/Schema/ReleaseSets.pm rename to src/lib/Hydra/Schema/Views.pm index bf3a2cd3..78eee999 100644 --- a/src/lib/Hydra/Schema/ReleaseSets.pm +++ b/src/lib/Hydra/Schema/Views.pm @@ -1,4 +1,4 @@ -package Hydra::Schema::ReleaseSets; +package Hydra::Schema::Views; use strict; use warnings; @@ -6,7 +6,7 @@ use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components("Core"); -__PACKAGE__->table("ReleaseSets"); +__PACKAGE__->table("Views"); __PACKAGE__->add_columns( "project", { @@ -36,17 +36,14 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("project", "name"); __PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }); __PACKAGE__->has_many( - "releasesetjobs", - "Hydra::Schema::ReleaseSetJobs", - { - "foreign.project" => "self.project", - "foreign.release_" => "self.name", - }, + "viewjobs", + "Hydra::Schema::ViewJobs", + { "foreign.project" => "self.project", "foreign.view_" => "self.name" }, ); -# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-08 13:25:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pEjxqTAwP4ZmP/s6F4VOsg +# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-15 23:14:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hV+xzi564rgcYeDvz75zCA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/root/edit-releaseset.tt b/src/root/edit-view.tt similarity index 78% rename from src/root/edit-releaseset.tt rename to src/root/edit-view.tt index a8d847eb..6d9f0e6e 100644 --- a/src/root/edit-releaseset.tt +++ b/src/root/edit-view.tt @@ -1,8 +1,8 @@ -[% WRAPPER layout.tt title=(create ? "New Release Set" : "Release Set ‘$project.name:$releaseSet.name’") %] +[% WRAPPER layout.tt title=(create ? "New View" : "View ‘$project.name:$view.name’") %] [% PROCESS common.tt %] [% USE HTML %] -

[% IF create %]New Release Set[% ELSE %]Release Set [% project.name %]:[% releaseSet.name %][% END %]

+

[% IF create %]New View[% ELSE %]View [% project.name %]:[% view.name %][% END %]

[% BLOCK renderJob %] @@ -21,16 +21,16 @@ [% END %] -
+ - + - +
Identifier: releaseSet.name) %] /> view.name) %] />
Description: releaseSet.description) %] /> view.description) %] />
@@ -86,13 +86,13 @@ [% IF !create %] - -

+ +

diff --git a/src/root/project.tt b/src/root/project.tt index 8d4cbaf3..3784f0bd 100644 --- a/src/root/project.tt +++ b/src/root/project.tt @@ -99,28 +99,28 @@ -

Releases

+

Views

-[% IF releaseSets.size > 0 %] +[% IF views.size > 0 %] -

Project [% project.name %] has the following release sets:

+

Project [% project.name %] has the following views:

[% ELSE %] -

Project [% project.name %] has no release sets.

+

Project [% project.name %] has no views.

[% END %] -

[Create a new release set]

+

[Create a new view]

Channels

diff --git a/src/root/releases.tt b/src/root/releases.tt deleted file mode 100644 index e4407d85..00000000 --- a/src/root/releases.tt +++ /dev/null @@ -1,75 +0,0 @@ -[% WRAPPER layout.tt title="Release Set ‘$releaseSet.project.name:$releaseSet.name’" %] -[% PROCESS common.tt %] -[% USE HTML %] - -

Release Set [% releaseSet.project.name %]:[% releaseSet.name %]

- -

-[Edit] -[Latest] -

- -

Showing releases [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) * resultsPerPage + releases.size %] out of [% totalReleases %].

- - - - - - - - - [% FOREACH j IN jobs %] - - [% END %] - - - - - [% FOREACH release IN releases %] - [% link = c.uri_for('/release' releaseSet.project.name releaseSet.name release.id) %] - - - - - - [% FOREACH j IN release.jobs %] - - [% END %] - - [% END %] - -
#ReleaseDate[% INCLUDE renderReleaseJobName job=j %]
- [% IF release.status == 0 %] - - [% ELSIF release.status == 1 %] - - [% ELSIF release.status == 2 %] - - [% END %] - [% release.id %] - [% IF release.releasename %] - [% release.releasename %] - [% ELSE %] - No name - [% END %] - [% INCLUDE renderDateTime timestamp=release.timestamp %] - [% IF j.build %] - - [% IF j.build.get_column('buildstatus') == 0 %] - - [% ELSE %] - - [% END %] - - [% END %] -
- -[% IF page > 1 %] - [Prev] -[% END %] -[% IF page * resultsPerPage < totalReleases %] - [Next] -[% END %] -[Last] - -[% END %] diff --git a/src/root/view.tt b/src/root/view.tt new file mode 100644 index 00000000..78acf014 --- /dev/null +++ b/src/root/view.tt @@ -0,0 +1,76 @@ +[% WRAPPER layout.tt title="View ‘$view.project.name:$view.name’" %] +[% PROCESS common.tt %] +[% USE HTML %] + +

View [% view.project.name %]:[% view.name %]

+ +

+[Edit] +[Latest] +

+ +

Showing results [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) * resultsPerPage + results.size %] out of [% totalResults %].

+ + + + + + + + + [% FOREACH j IN jobs %] + + [% END %] + + + + + [% FOREACH result IN results %] + [% link = c.uri_for('/view' project.name view.name result.id) %] + + + + + + [% FOREACH j IN result.jobs %] + + [% END %] + + [% END %] + +
#NameDate[% INCLUDE renderReleaseJobName job=j %]
+ [% IF result.status == 0 %] + + [% ELSIF result.status == 1 %] + + [% ELSIF result.status == 2 %] + + [% END %] + [% result.id %] + [% IF result.releasename %] + [% result.releasename %] + [% ELSE %] + No name + [% END %] + [% INCLUDE renderDateTime timestamp=result.timestamp %] + [% IF j.build %] + + [% IF j.build.get_column('buildstatus') == 0 %] + + [% ELSE %] + + [% END %] + + [% END %] +
+ +[First] +[% IF page > 1 %] + [Prev] +[% END %] +[% IF page * resultsPerPage < totalResults %] + [Next] +[% END %] +[Last] + +[% END %] diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index bf651b5f..21f8c82e 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -184,8 +184,8 @@ create trigger cascadeProjectUpdate update JobsetInputs set project = new.name where project = old.name; update JobsetInputAlts set project = new.name where project = old.name; update Builds set project = new.name where project = old.name; - update ReleaseSets set project = new.name where project = old.name; - update ReleaseSetJobs set project = new.name where project = old.name; + update Views set project = new.name where project = old.name; + update ViewJobs set project = new.name where project = old.name; end; @@ -329,28 +329,19 @@ create trigger cascadeUserDelete end; --- Release sets are a mechanism to automatically group related builds --- together. A release set defines what an individual release --- consists of, namely: a release consists of a build of some --- "primary" job, plus all builds of the other jobs named in --- ReleaseSetJobs that have that build as an input. If there are --- multiple builds matching a ReleaseSetJob, then we take the oldest --- successful build, or the oldest unsuccessful build if there is no --- successful build. A release is itself considered successful if all --- builds (except those for jobs that have mayFail set) are --- successful. --- --- Note that individual releases aren't separately stored in the --- database, so they're really just a dynamic view on the universe of --- builds, defined by a ReleaseSet. -create table ReleaseSets ( +-- Views are a mechanism to automatically group related builds +-- together. A view definition consists of a build of some "primary" +-- job, plus all builds of the other jobs named in ViewJobs that have +-- that build as an input. If there are multiple builds matching a +-- ViewJob, then we take the oldest successful build, or the oldest +-- unsuccessful build if there is no successful build. +create table Views ( project text not null, name text not null, description text, - -- If true, don't garbage-collect builds belonging to the releases - -- defined by this row. + -- If true, don't garbage-collect builds included in this view. keep integer not null default 0, primary key (project, name), @@ -358,26 +349,23 @@ create table ReleaseSets ( ); -create trigger cascadeReleaseSetDelete - before delete on ReleaseSets +create trigger cascadeViewDelete + before delete on Views for each row begin - delete from ReleaseSetJobs where project = old.project and release_ = old.name; + delete from ViewJobs where project = old.project and view_ = old.name; end; -create trigger cascadeReleaseSetUpdate - update of name on ReleaseSets +create trigger cascadeViewUpdate + update of name on Views for each row begin - update ReleaseSetJobs set release_ = new.name where project = old.project and release_ = old.name; + update ViewJobs set view_ = new.name where project = old.project and view_ = old.name; end; -create table ReleaseSetJobs ( +create table ViewJobs ( project text not null, - -- `release' is a reserved keyword in sqlite >= 3.6.8. We could - -- quote them ("release") here, but since the Perl bindings don't - -- do that it still wouldn't work. So use `release_' instead. - release_ text not null, + view_ text not null, job text not null, @@ -386,19 +374,23 @@ create table ReleaseSetJobs ( -- be a separate table but I'm lazy. attrs text not null, - -- If set, this is the primary job for the release. There can be - -- onlyt one such job per release set. + -- If set, this is the primary job for the view. There can be + -- only one such job per view. isPrimary integer not null default 0, - mayFail integer not null default 0, - description text, jobset text not null, + + -- If set, once there is a successful build for every job + -- associated with a build of the view's primary job, that set of + -- builds is automatically added as a release to the Releases + -- table. + autoRelease integer not null default 0, - primary key (project, release_, job, attrs), + primary key (project, view_, job, attrs), foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite - foreign key (project, release_) references ReleaseSets(project, name) on delete cascade -- ignored by sqlite + foreign key (project, view_) references Views(project, name) on delete cascade -- ignored by sqlite foreign key (project, jobset) references Jobsets(project, name) on delete restrict -- ignored by sqlite );