[Bps-public-commit] smokingit branch, master, updated. 53d9373e4d6ed8d6e04bd71a9a2b4b024cb09e5a

Alex Vandiver alexmv at bestpractical.com
Fri Jul 29 15:17:28 EDT 2011


The branch, master has been updated
       via  53d9373e4d6ed8d6e04bd71a9a2b4b024cb09e5a (commit)
       via  6da83d54c7d3872120dc58a1451075c1690d35af (commit)
       via  f9d57da9145f33c49b19228013be9320071e7421 (commit)
       via  3dce2e0f9859bf3202d5499e0e7e4a191c6ac34c (commit)
       via  6d4d9a1238c7c1922409af90e2364c13f57edc6c (commit)
       via  65c7d495484b6ee7fe5830519452eeb0c600e1f3 (commit)
       via  12532ee38ed0a6f9ff7ffaac587c7770bb91ef7a (commit)
      from  df9903fce63af5409cacc9ea1fed813e7839bbaf (commit)

Summary of changes:
 bin/local_updates                  |    8 +--
 etc/config.yml                     |    2 +-
 lib/Smokingit/Model/Branch.pm      |   34 ++++++++++++++
 lib/Smokingit/Model/Commit.pm      |    2 +-
 lib/Smokingit/Model/Project.pm     |   11 ++--
 lib/Smokingit/Model/SmokeResult.pm |   12 ++++-
 lib/Smokingit/Upgrade.pm           |   36 ++++++++++++++
 lib/Smokingit/View/Branch.pm       |    2 +-
 lib/Smokingit/View/Project.pm      |   89 ++++++++++++++++++-----------------
 9 files changed, 137 insertions(+), 59 deletions(-)
 create mode 100644 lib/Smokingit/Upgrade.pm

- Log -----------------------------------------------------------------
commit 12532ee38ed0a6f9ff7ffaac587c7770bb91ef7a
Author: Alex Vandiver <alex at chmrr.net>
Date:   Fri Jul 29 02:04:40 2011 -0400

    Refactor a laundry-list of status into a method

diff --git a/lib/Smokingit/Model/Branch.pm b/lib/Smokingit/Model/Branch.pm
index bce4adc..a7e4a60 100644
--- a/lib/Smokingit/Model/Branch.pm
+++ b/lib/Smokingit/Model/Branch.pm
@@ -162,6 +162,13 @@ sub long_status_html {
     return $html;
 }
 
+sub is_under_review {
+    my $self = shift;
+    return unless $self->status =~ /^(needs-review|awaiting-merge|merged)$/;
+    return unless $self->review_by;
+    return 1;
+}
+
 sub is_tested {
     my $self = shift;
     return $self->status ne "ignore";
diff --git a/lib/Smokingit/View/Branch.pm b/lib/Smokingit/View/Branch.pm
index 6a8c8ea..6511889 100644
--- a/lib/Smokingit/View/Branch.pm
+++ b/lib/Smokingit/View/Branch.pm
@@ -127,7 +127,7 @@ template '/fragments/branch/properties' => sub {
             };
         }
 
-        if ($b->status =~ /^(needs-review|awaiting-merge|merged)$/ ) {
+        if ($b->is_under_review) {
             row {
                 th { "Review by" };
                 cell { $b->review_by };
diff --git a/lib/Smokingit/View/Project.pm b/lib/Smokingit/View/Project.pm
index 39972dd..0a7c0b2 100644
--- a/lib/Smokingit/View/Project.pm
+++ b/lib/Smokingit/View/Project.pm
@@ -194,7 +194,7 @@ template '/cooking.txt' => sub {
             $out .= " "x 4 . $b->name." - ".$b->owner . "\n";
             $out .= " "x 6 . "[ " . $b->current_commit->long_status;
             $out .= " - " . $b->display_status;
-            $out .= " by ". $b->review_by if $b->status eq "needs-review" and $b->review_by;
+            $out .= " by ". $b->review_by if $b->is_under_review;
             $out .= " ]\n";
             $out .= Text::Wrap::wrap(" "x 8," "x 8,$b->long_status)."\n"
                 if $b->long_status;

commit 65c7d495484b6ee7fe5830519452eeb0c600e1f3
Author: Alex Vandiver <alex at chmrr.net>
Date:   Fri Jul 29 02:11:33 2011 -0400

    Add a column which caches whose court the ball is in currently

diff --git a/etc/config.yml b/etc/config.yml
index df93b0b..2735a2b 100644
--- a/etc/config.yml
+++ b/etc/config.yml
@@ -11,7 +11,7 @@ framework:
     Host: localhost
     Password: ''
     User: postgres
-    Version: 0.0.2
+    Version: 0.0.3
   DevelMode: 1
   LogLevel: INFO
   Mailer: Sendmail
diff --git a/lib/Smokingit/Model/Branch.pm b/lib/Smokingit/Model/Branch.pm
index a7e4a60..63c58a4 100644
--- a/lib/Smokingit/Model/Branch.pm
+++ b/lib/Smokingit/Model/Branch.pm
@@ -50,6 +50,10 @@ use Smokingit::Record schema {
 
     column to_merge_into =>
         references Smokingit::Model::Branch;
+
+    column current_actor =>
+        type is 'text',
+        since '0.0.3';
 };
 
 sub create {
@@ -74,6 +78,8 @@ sub create {
     my ($ok, $msg) = $self->SUPER::create(%args);
     return ($ok, $msg) unless $ok;
 
+    $self->update_current_actor;
+
     $self->set_to_merge_into( $self->guess_merge_into )
         unless $self->project->branches->count == 1
             or $self->to_merge_into->id;
@@ -128,6 +134,25 @@ sub branches {
     return $branches;
 }
 
+sub update_current_actor {
+    my $self = shift;
+    if ($self->is_under_review) {
+        $self->set_current_actor($self->review_by);
+    } else {
+        $self->set_current_actor($self->owner);
+    }
+}
+
+sub after_set_owner {
+    my $self = shift;
+    $self->update_current_actor;
+}
+
+sub after_set_review_by {
+    my $self = shift;
+    $self->update_current_actor;
+}
+
 sub set_status {
     my $self = shift;
     my $val = shift;
@@ -135,6 +160,8 @@ sub set_status {
 
     my @ret = $self->_set(column =>'status', value => $val);
 
+    $self->update_current_actor;
+
     if (not $prev_tested and $self->is_tested) {
         # It's no longer ignored; start testing where the tip is now,
         # not where it was when we first found it
diff --git a/lib/Smokingit/Upgrade.pm b/lib/Smokingit/Upgrade.pm
new file mode 100644
index 0000000..ee8a40f
--- /dev/null
+++ b/lib/Smokingit/Upgrade.pm
@@ -0,0 +1,22 @@
+use warnings;
+use strict;
+
+package Smokingit::Upgrade;
+
+use Jifty::Upgrade;
+use base qw/Jifty::Upgrade/;
+
+my $super = Smokingit::CurrentUser->superuser;
+
+# Added the concept of the current actor on the branch -- either the
+# reviewer, if the branch is under review, otherwise the owner.  Go
+# through and force this column to update for each outstanding branch.
+since '0.0.3' => sub {
+    my $branches = Smokingit::Model::BranchCollection->new( current_user => $super );
+    $branches->unlimit;
+    while (my $branch = $branches->next) {
+        $branch->update_current_actor;
+    }
+};
+
+1;
diff --git a/lib/Smokingit/View/Project.pm b/lib/Smokingit/View/Project.pm
index 0a7c0b2..3d717c9 100644
--- a/lib/Smokingit/View/Project.pm
+++ b/lib/Smokingit/View/Project.pm
@@ -187,7 +187,7 @@ template '/cooking.txt' => sub {
         $sub->limit( column => "status", operator => "!=", value => "releng", entry_aggregator => "AND");
         $sub->order_by(
             { function => "status = 'releng'", order => "desc"},
-            { column   => "owner" },
+            { column   => "current_actor" },
             { column   => "name" },
         );
         while ($b = $sub->next) {

commit 6d4d9a1238c7c1922409af90e2364c13f57edc6c
Author: Alex Vandiver <alex at chmrr.net>
Date:   Fri Jul 29 02:21:43 2011 -0400

    Update cooking to better use current_actor

diff --git a/lib/Smokingit/View/Project.pm b/lib/Smokingit/View/Project.pm
index 3d717c9..ac770e2 100644
--- a/lib/Smokingit/View/Project.pm
+++ b/lib/Smokingit/View/Project.pm
@@ -191,11 +191,14 @@ template '/cooking.txt' => sub {
             { column   => "name" },
         );
         while ($b = $sub->next) {
-            $out .= " "x 4 . $b->name." - ".$b->owner . "\n";
-            $out .= " "x 6 . "[ " . $b->current_commit->long_status;
-            $out .= " - " . $b->display_status;
-            $out .= " by ". $b->review_by if $b->is_under_review;
-            $out .= " ]\n";
+            $out .= " "x 4
+                . $b->name." - " . $b->current_commit->long_status
+                . "\n";
+
+            $out .= " "x 6 . "[ "
+                . $b->display_status ." by ". ($b->current_actor || 'someone')
+                . " ]\n";
+
             $out .= Text::Wrap::wrap(" "x 8," "x 8,$b->long_status)."\n"
                 if $b->long_status;
             $out .=  "\n";

commit 3dce2e0f9859bf3202d5499e0e7e4a191c6ac34c
Author: Alex Vandiver <alex at chmrr.net>
Date:   Fri Jul 29 02:54:44 2011 -0400

    Use the perfectly-functional $commit->run_smoke unstead of rolling our own

diff --git a/bin/local_updates b/bin/local_updates
index 011fe7d..7b5e102 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -186,12 +186,8 @@ $worker->register_function(
                 $smoke->set_gearman_process(undef);
                 $tests += $smoke->run_smoke;
             } elsif ($branch->id) {
-                $smoke->create(
-                    %lookup,
-                    from_branch_id => $branch->id,
-                );
                 warn "Smoking new @{[$smoke->id]}\n";
-                $tests += $smoke->run_smoke;
+                $tests += $commit->run_smoke( $config, $branch );
             } else {
                 warn "No existing smoke for $sha found, and no branch given\n";
             }

commit f9d57da9145f33c49b19228013be9320071e7421
Author: Alex Vandiver <alex at chmrr.net>
Date:   Fri Jul 29 02:57:36 2011 -0400

    Cache branch nae, not id, as branches do get deleted

diff --git a/bin/local_updates b/bin/local_updates
index 7b5e102..096d2b2 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -90,7 +90,7 @@ $worker->register_function(
             . $smoke->project->name
             ." ". $smoke->commit->short_sha
             ." using ". $smoke->configuration->name
-            ." on ". $smoke->from_branch->name
+            ." on ". $smoke->branch_name
             .": ".($smoke->is_ok ? "OK" : "NOT OK")."\n";
 
         return 1;
diff --git a/etc/config.yml b/etc/config.yml
index 2735a2b..9e78e13 100644
--- a/etc/config.yml
+++ b/etc/config.yml
@@ -11,7 +11,7 @@ framework:
     Host: localhost
     Password: ''
     User: postgres
-    Version: 0.0.3
+    Version: 0.0.4
   DevelMode: 1
   LogLevel: INFO
   Mailer: Sendmail
diff --git a/lib/Smokingit/Model/Commit.pm b/lib/Smokingit/Model/Commit.pm
index 71bcc02..3c11e7e 100644
--- a/lib/Smokingit/Model/Commit.pm
+++ b/lib/Smokingit/Model/Commit.pm
@@ -82,7 +82,7 @@ sub run_smoke {
 
     $smoke->create(
         %lookup,
-        from_branch_id => $branch->id,
+        branch_name => $branch->name,
     );
     return $smoke->run_smoke;
 }
diff --git a/lib/Smokingit/Model/SmokeResult.pm b/lib/Smokingit/Model/SmokeResult.pm
index 2ee227f..5024f6f 100644
--- a/lib/Smokingit/Model/SmokeResult.pm
+++ b/lib/Smokingit/Model/SmokeResult.pm
@@ -21,7 +21,12 @@ use Smokingit::Record schema {
         references Smokingit::Model::Commit;
 
     column from_branch_id =>
-        references Smokingit::Model::Branch;
+        references Smokingit::Model::Branch,
+        till '0.0.4';
+
+    column branch_name =>
+        type is 'text',
+        since '0.0.4';
 
     column gearman_process =>
         type is 'text';
diff --git a/lib/Smokingit/Upgrade.pm b/lib/Smokingit/Upgrade.pm
index ee8a40f..71476d9 100644
--- a/lib/Smokingit/Upgrade.pm
+++ b/lib/Smokingit/Upgrade.pm
@@ -19,4 +19,18 @@ since '0.0.3' => sub {
     }
 };
 
+# The branch name beceom a fixed part of the smoke test, and not a
+# reference to the branch id; thus, when branches are removed, the smoke
+# result still knows what branch it was on originally.
+since '0.0.4' => sub {
+    my $tests = Smokingit::Model::SmokeResultCollection->new( current_user => $super );
+    $tests->unlimit;
+    $tests->prefetch( name => "from_branch" );
+    my %branches;
+    while (my $test = $tests->next) {
+        my $branch = $test->prefetched( "from_branch" );
+        $test->set_branch_name($test->from_branch->name);
+    }
+};
+
 1;
diff --git a/lib/Smokingit/View/Project.pm b/lib/Smokingit/View/Project.pm
index ac770e2..59b7af3 100644
--- a/lib/Smokingit/View/Project.pm
+++ b/lib/Smokingit/View/Project.pm
@@ -83,7 +83,7 @@ template '/project' => page {
                             url     => "/test/".$test->commit->sha."/".$test->configuration->name,
                             label   => $test->commit->short_sha,
                         );
-                        outs( " on ".($test->from_branch->name || "?") . " using ".$test->configuration->name );
+                        outs( " on ".($test->branch_name || "?") . " using ".$test->configuration->name );
                     }
                 }
             };
@@ -107,7 +107,7 @@ template '/project' => page {
                             attr { class => "sha", title => $msg };
                             $test->commit->short_sha
                         };
-                        outs( " on ".$test->from_branch->name . " using ".$test->configuration->name );
+                        outs( " on ".$test->branch_name . " using ".$test->configuration->name );
                     }
                 }
             }

commit 6da83d54c7d3872120dc58a1451075c1690d35af
Author: Alex Vandiver <alex at chmrr.net>
Date:   Fri Jul 29 03:16:10 2011 -0400

    Refactor SmokeResult rendering

diff --git a/lib/Smokingit/View/Project.pm b/lib/Smokingit/View/Project.pm
index 59b7af3..6b89131 100644
--- a/lib/Smokingit/View/Project.pm
+++ b/lib/Smokingit/View/Project.pm
@@ -66,26 +66,7 @@ template '/project' => page {
                 id is "recent-tests";
                 class is "commitlist";
                 h2 { "Recent tests" };
-                while (my $test = $tests->next) {
-                    my ($status, $msg) = $test->commit->status($test);
-                    div {
-                        class is "commit $status";
-                        hyperlink(
-                            class   => "okbox $status",
-                            label   => " ",
-                            escape_label => 0,
-                            url     => "/test/".$test->commit->sha."/".$test->configuration->name,
-                            tooltip => $msg,
-                        );
-                        hyperlink(
-                            tooltip => $msg,
-                            class   => "sha",
-                            url     => "/test/".$test->commit->sha."/".$test->configuration->name,
-                            label   => $test->commit->short_sha,
-                        );
-                        outs( " on ".($test->branch_name || "?") . " using ".$test->configuration->name );
-                    }
-                }
+                test_result($_) while $_ = $tests->next;
             };
         }
 
@@ -95,26 +76,45 @@ template '/project' => page {
                 id is "planned-tests";
                 class is "commitlist";
                 h2 { "Planned tests" };
-                for my $test (@planned) {
-                    my ($status, $msg, $in) = $test->commit->status($test);
-                    div {
-                        class is "commit $status";
-                        span {
-                            attr { class => "okbox $status", title => $msg };
-                            outs_raw($in || " ")
-                        };
-                        span {
-                            attr { class => "sha", title => $msg };
-                            $test->commit->short_sha
-                        };
-                        outs( " on ".$test->branch_name . " using ".$test->configuration->name );
-                    }
-                }
+                test_result($_) for @planned;
             }
         }
     };
 };
 
+sub test_result {
+    my $test = shift;
+    my ($status, $msg, $in) = $test->commit->status($test);
+    div {
+        class is "commit $status";
+        if ($status =~ /^(untested|queued|testing|broken)$/) {
+            span {
+                attr { class => "okbox $status", title => $msg };
+                outs_raw($in || " ")
+            };
+            span {
+                attr { class => "sha", title => $msg };
+                $test->commit->short_sha
+            };
+        } else {
+            hyperlink(
+                class   => "okbox $status",
+                label   => " ",
+                escape_label => 0,
+                url     => "/test/".$test->commit->sha."/".$test->configuration->name,
+                tooltip => $msg,
+            );
+            hyperlink(
+                tooltip => $msg,
+                class   => "sha",
+                url     => "/test/".$test->commit->sha."/".$test->configuration->name,
+                label   => $test->commit->short_sha,
+            );
+        }
+        outs( " on ".$test->branch_name. " using ".$test->configuration->name );
+    }
+};
+
 template '/fragments/project/branch-list' => sub {
     div {
         id is "branch-list";

commit 53d9373e4d6ed8d6e04bd71a9a2b4b024cb09e5a
Author: Alex Vandiver <alex at chmrr.net>
Date:   Fri Jul 29 15:15:57 2011 -0400

    id isn't queue order if a SmokeResult is re-tested
    
    Add a queued_at timestamp to order the upcoming tests list correctly

diff --git a/etc/config.yml b/etc/config.yml
index 9e78e13..268d8c9 100644
--- a/etc/config.yml
+++ b/etc/config.yml
@@ -11,7 +11,7 @@ framework:
     Host: localhost
     Password: ''
     User: postgres
-    Version: 0.0.4
+    Version: 0.0.5
   DevelMode: 1
   LogLevel: INFO
   Mailer: Sendmail
diff --git a/lib/Smokingit/Model/Project.pm b/lib/Smokingit/Model/Project.pm
index 323e030..e34da0e 100644
--- a/lib/Smokingit/Model/Project.pm
+++ b/lib/Smokingit/Model/Project.pm
@@ -110,13 +110,12 @@ sub planned_tests {
         value => "NULL"
     );
     $tests->limit( column => "project_id", value => $self->id );
+    $tests->order_by(
+        { column => "queued_at", order  => "asc" },
+        { column => "id",        order  => "asc" },
+    );
     $tests->prefetch( name => "commit" );
-    my @tests = @{ $tests->items_array_ref };
-    @tests = sort { $a->gearman_status->known       <=>  $b->gearman_status->known
-                or  $b->gearman_status->running     <=>  $a->gearman_status->running
-                or ($b->gearman_status->percent||0) <=> ($a->gearman_status->percent||0)
-                or  $a->id                          <=>  $b->id} @tests;
-    return @tests;
+    return $tests;
 }
 
 sub update_repository {
diff --git a/lib/Smokingit/Model/SmokeResult.pm b/lib/Smokingit/Model/SmokeResult.pm
index 5024f6f..09b3d8c 100644
--- a/lib/Smokingit/Model/SmokeResult.pm
+++ b/lib/Smokingit/Model/SmokeResult.pm
@@ -31,6 +31,10 @@ use Smokingit::Record schema {
     column gearman_process =>
         type is 'text';
 
+    column queued_at =>
+        is timestamp,
+        since '0.0.5';
+
     column submitted_at =>
         is timestamp;
 
@@ -111,6 +115,7 @@ sub run_smoke {
         return 0;
     }
     $self->set_gearman_process($job_id);
+    $self->set_queued_at( Jifty::DateTime->now );
     return 1;
 }
 
diff --git a/lib/Smokingit/View/Project.pm b/lib/Smokingit/View/Project.pm
index 6b89131..f55c864 100644
--- a/lib/Smokingit/View/Project.pm
+++ b/lib/Smokingit/View/Project.pm
@@ -70,13 +70,13 @@ template '/project' => page {
             };
         }
 
-        my @planned = get('project')->planned_tests;
-        if (@planned) {
+        my $planned = get('project')->planned_tests;
+        if ($planned->count) {
             div {
                 id is "planned-tests";
                 class is "commitlist";
                 h2 { "Planned tests" };
-                test_result($_) for @planned;
+                test_result($_) while $_ = $planned->next;
             }
         }
     };

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list