The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

ctgetreports - Quickly fetch cpantesters results with all reports

SYNOPSIS

  ctgetreports [options] distroname ...
  ctgetreports [options] --report number ...
  ctgetreports -h

OPTIONS

--cachedir=s

Directory to keep mirrored data in. Defaults to $HOME/var/cpantesters.

--ctformat=s

Format of the cpan-testers file that should be downloaded. Available options are html and yaml. Default should be html but is temporarily switched to yaml because the cpantesters site is under reconstruction.

--cturl=s

Base URL of the cpantesters website. Defaults to http://www.cpantesters.org/show but sometimes it is interesting to set it to the old URL, http://cpantesters.perl.org/show> to diagnose bugs or whatever.

--dumpfile=s

If dumpvars are specified, dump them into this file. Defaults to "ctgetreports.out".

--dumpvars=s

Dump all queryable variables matching the regular expression given as argument at the end of the loop for a distro.

--help|h

Prints a brief message and exists.

--interactive|i

After every parsed report asks if you want to see it in a pager.

--local

Do not mirror, use a local *.html file. Dies if the HTML or YAML file is missing, skips missing report files.

--pager=s

Pager (needed when -i is given). Defaults to less.

--q=s@

Query, may be repeated.

Example: --q mod:Clone --q meta:writer

--quiet!

Do not output the usual query lines per parsed report. Quiet overrules verbose.

--raw!

Boolean which, if set, causes the full (HTML) report to be concatenated to STDOUT after every status line.

--report=s@

Avert going through a cpan testers index, go straight to the report with this number.

Example: --report 1238673

--solve!

Calls the solve function which tries to identify the best contenders for a blame using Statistics::Regression. Currently only limited to single variables and with simple heuristics. Implies --dumpvars=. unless the caller sets dumpvars himself.

The function prints at the moment to STDOUT the top 3 (set with --solvetop) candidates according to R^2 with their regression analysis.

A few words of advise: do not take the results as a prove ever. Take them just as a hint where you can most probablt prove a causal relationship. And keep in mind that causal relationships can be the other direction as well.

If you want to extend on that approach, I recommend you study the ctgetreports.out file where you find all the data you'd need and feed your assumptions to Statistics::Regression.

--solvetop=i

The number of top candidates from the --solve regression analysis to display.

--vdistro=s

Versioned distro. Needed if we do not want the most recent. Makes no sense if there is more than one argument on the command line.

Example: --vdistro IPC-Run-0.80

--verbose|v+

Feedback during download.

--ycb=s

Only used during --solve. Provides perl code to be used as a callback from the regression to determine the Y of the regression equation. The callback function gets a record (hashref) as the only argument and must return a value or undefined. If it returns undefined, the record is skipped, otherwise this record is processed with the returned value. The callback is pure perl code without any surrounding sub declaration.

The following example analyses diagnostic output from Acme-Study-Perl:

  ctgetreports --q qr:"#(.*native big math float/int.*)" --solve \
    --ycb 'my $rec = shift;
           my $nbfi = $rec->{"qr:#(.*native big math float/int.*)"};
          return undef unless defined $nbfi;
          my $VAR1 = eval($nbfi);
          return $VAR1->{">"}' Acme-Study-Perl

DESCRIPTION

!!!!Alert: alpha quality software, subject to change without warning!!!!

The intent is to get at both the summary at cpantesters and the individual reports and parse the reports and collect the data for further inspection.

We always only fetch the reports for the most recent (optionally picked) release. Target root directory is $HOME/var/cpantesters (can be overridden with the --cachedir option).

The --q paramater can be repeated. It takes one argument which stands for a query. This query must consist of two parts, a qualifier and the query itself. Qualifiers are one of the following

  conf       parameters from the output of 'perl -V'
             e.g.: conf:usethreads, conf:cc
  mod        for installed modules, either from prerequisites or from the toolchain
             e.g.: mod:Test::Simple, mod:Imager
  env        environment variables
             e.g.: env:TERM
  meta       all other parameters
             e.g.: meta:perl, meta:from, meta:date, meta:writer
  qr         boolean set if the appended regexp matches the report
             e.g.: qr:'division by zero'

The conf parameters specify a word used by the Config module.

The mod parameters consist of a package name.

The meta parameters are the following: perl for the perl version, from for the sender of the report, date for the date in the mail header, writer for the module that produced the report, output_from for the line that is reported to have produced the output.

Examples

This gets all recent reports for Object-Relation and outputs the version number of the prerequisite Clone:

  $0 --q mod:Clone Object-Relation

Collects reports about Clone and reports the default set of metadata:

  $0 Clone

Collect reports for Devel-Events and report the version number of Moose in thses reports and sort by success/failure. If Moose broke Devel-Events is becomes pretty obvious:

  $0 --q mod:Moose Devel-Events |sort

Which tool was used to write how many reports, sorted by frequency:

  $0 --q meta:writer Template-Timer | sed -e 's/.*meta:writer//' | sort | uniq -c | sort -n

Who was in the From field of the mails whose report writer was not determined:

  $0 --q meta:writer --q meta:from Template-Timer | grep 'UNDEF'

At the time of this writing this collected the results of IPC-Run-0.80_91 which was not really the latest release. In this case manual investigations were necessary to find out that 0.80 was the most recent:

  $0 IPC-Run

Pick the specific release IPC-Run-0.80:

  $0 --vdistro IPC-Run-0.80 IPC-Run

The following displays in its own column if the report contains the regexp division by zero:

  $0 --q qr:"division by zero" --vdistro 'CPAN-Testers-ParseReport-0.0.7' CPAN-Testers-ParseReport

The following is a simple job to refresh all HTML pages we already have and fetch new reports referenced there too:

  perl -le '
  for my $dirent (glob "$ENV{HOME}/var/cpantesters/cpantesters-show/*.html"){
    my($distro) = $dirent =~ m|/([^/]+)\.html$| or next;
    print $distro;
    my $system = "ctgetreports --verbose --verbose $distro";
    0 == system $system or die;
  }'