Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show review badges also on group-level #1047

Merged
merged 1 commit into from
Nov 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/OpenQA/BuildResults.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ sub count_job {
return;
}

sub add_review_badge {
my ($build_res) = @_;

$build_res->{reviewed_all_passed} = $build_res->{passed} == $build_res->{total};
$build_res->{reviewed} = $build_res->{failed} > 0 && $build_res->{labeled} == $build_res->{failed};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we change this now to say $build_res->{labeled} >= $build_res->{failed} in case we label any other jobs additionally?

}

sub compute_build_results {
my ($group, $limit, $time_limit_days, $tags) = @_;

Expand Down Expand Up @@ -144,13 +151,13 @@ sub compute_build_results {
$child->{distri} //= $job->DISTRI;
$child->{version} //= $job->VERSION;
count_job($job, $child, \%labels);
add_review_badge($child);
}
}
$jr{escaped_id} = $b;
$jr{escaped_id} =~ s/\W/_/g;
$jr{reviewed_all_passed} = $jr{passed} == $jr{total};
$jr{reviewed} = $jr{failed} > 0 && $jr{labeled} == $jr{failed};
$builds{$b} = \%jr;
add_review_badge(\%jr);
$builds{$b} = \%jr;
$max_jobs = $jr{total} if ($jr{total} > $max_jobs);
}
return {
Expand Down
6 changes: 6 additions & 0 deletions t/22-dashboard.t
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ sub check_test_parent {
1, 'review badge for build 0048@0815 shown');
is($get->tx->res->dom->find('#review-' . $test_parent->id . '-0048')->size,
0, 'review badge for build 0048 NOT shown yet');
is($get->tx->res->dom->find('#child-review-' . $test_parent->id . '-0048')->size,
0, 'review badge for build 0048 also on child-level NOT shown yet');

my @progress_bars
= $get->tx->res->dom->find("div.children-$default_expanded .progress")->map('attr', 'title')->each;
Expand Down Expand Up @@ -193,13 +195,17 @@ my $not_reviewed_job = $jobs->create(
$get = $t->get_ok('/?limit_builds=20&show_tags=1')->status_is(200);
is($get->tx->res->dom->find('#review-' . $test_parent->id . '-0048@0815')->size,
0, 'review badge NOT shown for build 0048@0815 anymore');
is($get->tx->res->dom->find('#child-review-' . $test_parent->id . '-0048@0815')->size,
1, 'review badge for build 0048@0815 still shown on child-level');
$not_reviewed_job->delete();

# add review for job 99938 so build 0048 is reviewed, despite the unreviewed softfails
$opensuse_group->jobs->find({id => 99938})->comments->create({text => 'poo#4321', user_id => 99901});
$get = $t->get_ok('/?limit_builds=20')->status_is(200);
is($get->tx->res->dom->find('#review-' . $test_parent->id . '-0048')->size,
1, 'review badge for build 0048 shown, despite unreviewed softfails');
is($get->tx->res->dom->find('#child-review-' . $test_parent->id . '-0048')->size,
1, 'review badge for build 0048 shown on child-level, despite unreviewed softfails');

# change DISTRI/VERSION of test in opensuse group to test whether links are still correct then
$opensuse_group->jobs->update({VERSION => '14.2', DISTRI => 'suse'});
Expand Down
14 changes: 2 additions & 12 deletions templates/main/group_builds.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,7 @@
<i class="tag fa fa-tag" title="<%= $tag->{type}; %>"><%= $tag->{description} %></i>
</span>
% }
% my $reviewed = $build_res->{reviewed};
% if ($reviewed) {
<span id="review-<%= $group_build_id %>">
<i class="review fa fa-certificate" title="Reviewed (<%= $build_res->{labeled}; %> comments)"></i>
</span>
% }
% my $reviewed_all_passed = $build_res->{reviewed_all_passed};
% if ($reviewed_all_passed) {
<span id="review-all-passed-<%= $group_build_id %>">
<i class="review-all-passed fa fa-certificate" title="Reviewed (all passed)"></i>
</span>
% }
%= include 'main/review_badge', group_build_id => $group_build_id, build_res => $build_res, id_prefix => ''
</h4>
</div>
<div class="col-md-8">
Expand All @@ -52,6 +41,7 @@
<div class="col-md-4 text-nowrap">
<h4>
%= link_to $child->{name} => url_for('tests_overview')->query(distri => $child_res->{distri}, version => $child_res->{version}, build => $build, groupid => $child->{id})
%= include 'main/review_badge', group_build_id => $group_build_id, build_res => $child_res, id_prefix => 'child-'
</h4>
</div>
<div class="col-md-8">
Expand Down
12 changes: 12 additions & 0 deletions templates/main/review_badge.html.ep
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
% my $reviewed = $build_res->{reviewed};
% if ($reviewed) {
<span id="<%= $id_prefix %>review-<%= $group_build_id %>">
<i class="review fa fa-certificate" title="Reviewed (<%= $build_res->{labeled}; %> <%= $build_res->{labeled} == 1 ? 'comment' : 'comments' %>)"></i>
</span>
% }
% my $reviewed_all_passed = $build_res->{reviewed_all_passed};
% if ($reviewed_all_passed) {
<span id="<%= $id_prefix %>review-all-passed-<%= $group_build_id %>">
<i class="review-all-passed fa fa-certificate" title="Reviewed (all passed)"></i>
</span>
% }