X-Git-Url: https://git.exim.org/buildfarm-server.git/blobdiff_plain/7696f262f27714edbcf520399a61be1dc7e3e158..a78d9bf85e4e91b05abc18852c06e3ba65aff0aa:/cgi-bin/show_status.pl diff --git a/cgi-bin/show_status.pl b/cgi-bin/show_status.pl old mode 100644 new mode 100755 index 1e6ea32..1ac959e --- a/cgi-bin/show_status.pl +++ b/cgi-bin/show_status.pl @@ -1,97 +1,126 @@ #!/usr/bin/perl +=comment + +Copyright (c) 2003-2010, Andrew Dunstan + +See accompanying License file for license details + +=cut + use strict; use DBI; use Template; use CGI; -use vars qw($dbhost $dbname $dbuser $dbpass $dbport); - +use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; my $query = new CGI; -my @members = $query->param('member'); +my @members = $query->multi_param('member'); map { s/[^a-zA-Z0-9_ -]//g; } @members; my $dsn="dbi:Pg:dbname=$dbname"; $dsn .= ";host=$dbhost" if $dbhost; $dsn .= ";port=$dbport" if $dbport; -my $db = DBI->connect($dsn,$dbuser,$dbpass) or die("$dsn,$dbuser,$dbpass,$!"); - -# there is possibly some redundancy in this query, but it makes -# a lot of the processing simpler. - -my $statement = < now() - '30 days'::interval - ) m - where name = sysname - and s.status = 'approved' - order by branch = 'HEAD' desc, - branch desc, - snapshot desc -EOS -; +my $sort_clause = ""; +my $sortby = $query->param('sortby') || 'nosort'; +if ($sortby eq 'name') +{ + $sort_clause = 'lower(sysname),'; +} +elsif ($sortby eq 'os') +{ + $sort_clause = 'lower(operating_system), os_version desc,'; +} +elsif ($sortby eq 'compiler') +{ + $sort_clause = "lower(compiler), compiler_version,"; +} -$statement =< now() - '30 days'::interval - ) m - where name = sysname - and s.status = 'approved' - order by branch = 'HEAD' desc, - branch desc, - snapshot desc +my $db = DBI->connect($dsn,$dbuser,$dbpass,{pg_expand_array => 0}) + or die("$dsn,$dbuser,$dbpass,$!"); +my $statement =<prepare($statement); $sth->execute; + +# walk the set of result rows from the SQL query above while (my $row = $sth->fetchrow_hashref) { next if (@members && ! grep {$_ eq $row->{sysname} } @members); + $row->{build_flags} =~ s/^\{(.*)\}$/$1/; $row->{build_flags} =~ s/,/ /g; - $row->{build_flags} =~ s/--((enable|with)-)?//g; - $row->{build_flags} =~ s/\S+=\S+//g; + $row->{build_flags} =~ s/_PC\b//g; + $row->{build_flags} = lc($row->{build_flags}); + + if (defined($row->{log_text})) + { # convert to a hash, find ranges, output list of ranges + my $h = { split /\s+/, $row->{log_text} }; + my ($i, $start, $last); + my @ranges; + + foreach my $k (sort {$a<=>$b} keys %$h) + { + if (defined $start) + { + if ($h->{$k} ne $h->{$start} || $k != $last + 1) + { + # The result (skiped, Passed, Failed) for this testcase number + # is different to the start one of the range, + # or the range became non-contiguous. + # Add text for the range to list of ranges + # (these three elements get used by "status.tt" BLOCK colourbar) + # Reset the start and the count, for a new range. + + push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i); + $start = $k; + $i = 1; + } + else + { + # bump the size of this range + $i++; + } + } + else + { + # First ever range for this row + $start = $k; + $i = 1; + } + $last = $k; + } + if (defined $start) + { + # close out the final range + push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i); + } + + $row->{log_text} = \@ranges; + } push(@$statrows,$row); } $sth->finish; @@ -99,133 +128,14 @@ $sth->finish; $db->disconnect; -my $template = new Template({}); + +my $template_opts = { INCLUDE_PATH => $template_dir }; +my $template = new Template($template_opts); print "Content-Type: text/html\n\n"; -$template->process(\*DATA,{statrows=>$statrows}); +$template->process('status.tt', + {statrows=>$statrows}); exit; -=comment - -[%- BLOCK img ; flag ; END -%] -[%- BLOCK imgx ; IF flag_imgs.$flag ; '' . flag . ' ' ; ELSE flag . ' ' ; END ; END -%] - -=cut - -__DATA__ -[% - flag_imgs = { - perl = '/img/camel.png', - python = '/img/python.png', - debug = '/img/bug.png', - pam => '/img/pam.png', - cassert => '/img/cassert.png', - openssl => '/img/ssl_icon.gif', - nls => '/img/translateicon.gif', - krb5 => '/img/krb.gif', - tcl => '/img/tcl.png', - 'thread-safety' => '/img/threads.gif', - 'integer-datetimes' = '/img/days.png', - } --%] -[%- BLOCK img ; IF flag == 'depend' or flag == 'gnu-ld' ; ; ELSIF flag_imgs.$flag %][% flag %] [% ELSE %][%# - flag ; ' ' -%][% END ; END -%] -[%- BLOCK cl %] class=" [% SWITCH bgfor -%] - [%- CASE 'OK' %]pass[% CASE 'ContribCheck' %]warn[% CASE [ 'Check' 'InstallCheck' ] %]warnx[% CASE %]fail[% END %]" -[%- END -%] - - - - - PostgreSQL BuildFarm Status - - - - - -
- -
-

PostgreSQL BuildFarm Status

-

- Shown here is the latest status of each farm member - for each branch it has reported on in the last 30 days. -

-

- Use the farm member link for history of that member - on the relevant branch. -

- -[% FOREACH flagset IN flag_imgs %] - -[% IF loop.count == 5 %][% END %] -[% END %] -
Legend[% flagset.key %] = [% flagset.key %]
-
- -[% brch = "" %] -[% FOREACH row IN statrows %] -[% IF row.branch != brch ; brch = row.branch %] - - -[% END %] - - - - - - - -[% END %] -
Branch: [% brch %]
AliasSystemStatusFlags
[% row.sysname %][% row.operating_system %] - [% row.os_version %] - [%- row.compiler %] - [% row.compiler_version %] - [%- row.architecture %] - [%- row.when_ago | replace('\s',' ') %] ago  - [% row.stage -%] - - [%- IF row.stage != 'OK' %]Details[% ELSE %]Config[% END -%][% FOREACH flag IN row.build_flags.split().sort() ; PROCESS img ; END %]
-
-
-

-Hosting for the PostgreSQL Buildfarm is generously -provided by: -CommandPrompt, -The PostgreSQL Company -

-
- - - - - - - - - -