File Coverage

blib/lib/Dist/Zilla/Plugin/Author/KENTNL/TravisCI.pm
Criterion Covered Total %
statement 17 49 34.6
branch 0 6 0.0
condition 0 3 0.0
subroutine 6 7 85.7
pod 1 1 100.0
total 24 66 36.3


line stmt bran cond sub pod time code
1 1     1   478 use 5.006; # our
  1         2  
2 1     1   3 use strict;
  1         1  
  1         20  
3 1     1   10 use warnings;
  1         1  
  1         81  
4              
5             package Dist::Zilla::Plugin::Author::KENTNL::TravisCI;
6              
7             our $VERSION = '0.001003'; # TRIAL
8              
9             # ABSTRACT: A specific subclass of TravisCI that does horrible things
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 1     1   555 use Moose qw( extends has around );
  1         309059  
  1         6  
14             extends 'Dist::Zilla::Plugin::TravisCI';
15              
16 1     1   5113 use Path::Tiny qw(path);
  1         7700  
  1         201  
17              
18             has skip_perls => ( isa => 'ArrayRef[Str]', is => 'ro', default => sub { [] } );
19             has fail_perls => ( isa => 'ArrayRef[Str]', is => 'ro', default => sub { ['5.8'] } );
20              
21             around mvp_multivalue_args => sub {
22             my ( $orig, $self, @args ) = @_;
23             return ( $self->$orig(@args), qw( skip_perls fail_perls ) );
24             };
25              
26             around dump_config => sub {
27             my ( $orig, $self, @args ) = @_;
28             my $config = $self->$orig(@args);
29             my $localconf = $config->{ +__PACKAGE__ } = {};
30              
31             $localconf->{skip_perls} = $self->skip_perls;
32             $localconf->{fail_perls} = $self->fail_perls;
33              
34             $localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION
35             unless __PACKAGE__ eq ref $self;
36              
37             return $config;
38             };
39              
40             __PACKAGE__->meta->make_immutable;
41 1     1   6 no Moose;
  1         2  
  1         7  
42              
43              
44              
45              
46              
47             sub modify_travis_yml {
48 0     0 1   my ( $self, %yaml ) = @_;
49             my $allow_failures = [
50 0           ( map { +{ perl => $_ } } @{ $self->fail_perls } ),
  0            
  0            
51             { env => 'STERILIZE_ENV=0 RELEASE_TESTING=1 AUTHOR_TESTING=1' },
52             { env => 'STERILIZE_ENV=0 DEVELOPER_DEPS=1' },
53             ];
54              
55 0           my (%skip_perls) = map { $_ => 1 } @{ $self->skip_perls };
  0            
  0            
56 0           my (@sterile_perls) = grep { not exists $skip_perls{$_} } '5.8', '5.10', '5.20';
  0            
57 0           my (@normal_perls) = grep { not exists $skip_perls{$_} } '5.8', '5.10', '5.12', '5.14', '5.16', '5.20', '5.21';
  0            
58              
59             my $include = [
60             { perl => '5.21', env => 'STERILIZE_ENV=0 COVERAGE_TESTING=1' },
61             { perl => '5.21', env => 'STERILIZE_ENV=1' },
62 0           ( map { +{ perl => $_, env => 'STERILIZE_ENV=0' } } @normal_perls ),
63 0           ( map { +{ perl => $_, env => 'STERILIZE_ENV=1' } } @sterile_perls ),
  0            
64             { perl => '5.21', env => 'STERILIZE_ENV=0 DEVELOPER_DEPS=1' },
65             { perl => '5.21', env => 'STERILIZE_ENV=0 RELEASE_TESTING=1 AUTHOR_TESTING=1' },
66             ];
67             $yaml{matrix} = {
68 0           allow_failures => $allow_failures,
69             include => $include,
70             };
71             $yaml{before_install} = [
72 0           'perlbrew list',
73             ## no critic (ValuesAndExpressions::RestrictLongStrings)
74             'time git clone --depth 10 https://github.com/kentfredric/travis-scripts.git maint-travis-ci',
75             'time git -C ./maint-travis-ci reset --hard master',
76             'time perl ./maint-travis-ci/branch_reset.pl',
77             'time perl ./maint-travis-ci/sterilize_env.pl',
78             ];
79             $yaml{install} = [
80 0           'time perl ./maint-travis-ci/install_deps_early.pl',
81             'time perl ./maint-travis-ci/autoinstall_dzil.pl',
82             'time perl ./maint-travis-ci/install_deps_2.pl',
83             ];
84 0           $yaml{before_script} = [ 'time perl ./maint-travis-ci/before_script.pl', ];
85 0           $yaml{script} = [ 'time perl ./maint-travis-ci/script.pl', ];
86 0           $yaml{after_failure} = [ 'perl ./maint-travis-ci/report_fail_ctx.pl', ];
87 0           $yaml{branches} = { only => [ 'master', 'builds', 'releases', ] };
88 0           $yaml{sudo} = 'false';
89 0           delete $yaml{perl};
90              
91 0           my $script = path( $self->zilla->root, 'maint', 'travisci.pl' )->absolute->stringify;
92             {
93 0 0         if ( -e $script ) {
  0            
94 0           local ( $@, $! ); ## no critic (Variables::RequireInitializationForLocalVars)
95 0           my $callback = do $script;
96 0 0 0       $self->log_fatal("$@ $!") if $@ or $!;
97 0 0         $self->log_fatal('Did not return a callback') unless ref $callback;
98 0           $callback->( \%yaml );
99             }
100             }
101 0           return %yaml;
102             }
103              
104             1;
105              
106             __END__
107              
108             =pod
109              
110             =encoding UTF-8
111              
112             =head1 NAME
113              
114             Dist::Zilla::Plugin::Author::KENTNL::TravisCI - A specific subclass of TravisCI that does horrible things
115              
116             =head1 VERSION
117              
118             version 0.001003
119              
120             =head1 DESCRIPTION
121              
122             B<NO USER SERVICEABLE PARTS INSIDE>
123              
124             B<CHOKING HAZARD>
125              
126             =for Pod::Coverage modify_travis_yml
127              
128             =head1 AUTHOR
129              
130             Kent Fredric <kentnl@cpan.org>
131              
132             =head1 COPYRIGHT AND LICENSE
133              
134             This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
135              
136             This is free software; you can redistribute it and/or modify it under
137             the same terms as the Perl 5 programming language system itself.
138              
139             =cut