File Coverage

blib/lib/Alien/Build/Plugin/Probe/OverrideCI.pm
Criterion Covered Total %
statement 22 24 91.6
branch 5 6 83.3
condition 8 16 50.0
subroutine 6 7 85.7
pod 1 1 100.0
total 42 54 77.7


line stmt bran cond sub pod time code
1             package Alien::Build::Plugin::Probe::OverrideCI;
2              
3 2     2   161310 use strict;
  2         5  
  2         65  
4 2     2   11 use warnings;
  2         6  
  2         54  
5 2     2   269 use Alien::Build::Plugin;
  2         1832  
  2         11  
6 2     2   140 use Path::Tiny qw( path );
  2         4  
  2         78  
7 2     2   478 use File::chdir;
  2         4494  
  2         458  
8              
9             # ABSTRACT: Override logic for continuous integration
10             our $VERSION = '0.01'; # VERSION
11              
12              
13             sub init
14             {
15 8     8 1 102712 my($self, $meta) = @_;
16            
17 8         19 my $ci_build_root;
18              
19 8 100 66     108 if(defined $ENV{TRAVIS} && $ENV{TRAVIS} eq 'true' && defined $ENV{TRAVIS_BUILD_DIR})
    50 66        
      33        
      33        
20             {
21 4         16 $ci_build_root = path($ENV{TRAVIS_BUILD_DIR})->realpath;
22             }
23             elsif(defined $ENV{APPVEYOR} && $ENV{APPVEYOR} eq 'True' && $ENV{APPVEYOR_BUILD_FOLDER})
24             {
25 4         22 $ci_build_root = path($ENV{APPVEYOR_BUILD_FOLDER})->realpath;
26             }
27             else
28             {
29             # are you sure you are running under CI?
30 0         0 die "unable to detect the type of CI";
31             }
32              
33             my $override =
34             $ci_build_root->subsumes(path($CWD)->realpath)
35             ? $ENV{ALIEN_INSTALL_TYPE_CI} || ''
36 8 100 50     1581 : $ENV{ALIEN_INSTALL_TYPE} || '';
      50        
37              
38             #Alien::Build->log("override = $override");
39            
40             $meta->register_hook(
41             override => sub {
42 0     0     $override;
43             },
44 8         2386 );
45             }
46              
47             1;
48              
49             __END__