From b3d8e8697c056b409772cd63145088d5cec4d153 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Fri, 25 Aug 2017 21:23:21 -0600 Subject: [PATCH] automatically figure out perl_versions for Travis --- .travis.yml | 1 + lib/Dist/Zilla/PluginBundle/Author/CCM.pm | 47 +++++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0fa429..e90dbdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ sudo: false language: perl perl: + - '5.26' - '5.24' - '5.22' - '5.20' diff --git a/lib/Dist/Zilla/PluginBundle/Author/CCM.pm b/lib/Dist/Zilla/PluginBundle/Author/CCM.pm index 7a51fd8..177b79b 100644 --- a/lib/Dist/Zilla/PluginBundle/Author/CCM.pm +++ b/lib/Dist/Zilla/PluginBundle/Author/CCM.pm @@ -126,8 +126,25 @@ our $VERSION = '999.999'; # VERSION use Dist::Zilla::Util; use Moose; +use Perl::Version; use namespace::autoclean; +=attr max_target_perl + +Specify the minimum perl version. Defaults to C<5.10.1>. + +=cut + +has max_target_perl => ( + is => 'ro', + isa => 'Str', + lazy => 1, + default => sub { + my $self = shift; + $self->payload->{'Test::MinimumVersion.max_target_perl'} // $self->payload->{max_target_perl} // '5.10.1'; + }, +); + =attr authority Specify the release authority. Defaults to C. @@ -158,7 +175,7 @@ has installer => ( is => 'ro', isa => 'Str', lazy => 1, - default => sub { shift->payload->{installer} || 'MakeMaker' }, + default => sub { shift->payload->{installer} // 'MakeMaker' }, ); =attr airplane @@ -204,9 +221,8 @@ sub configure { my @allow_dirty = (@copy_from_build, qw(.travis.yml Changes LICENSE README.md)); my @git_remotes = qw(github origin); my @check_files = qw(:InstallModules :ExecFiles :TestFiles :ExtraTestFiles); - my $perl_version_target = '5.10.1'; - my $perl_version = '5.24 5.22 5.20 5.18 5.16 5.14'; - my $perl_version_build = $perl_version . ' 5.12 5.10 -5.8'; + my $perl_version_target = $self->max_target_perl; + my ($perl_version, $perl_version_build) = $self->_travis_perl_versions($perl_version_target); if ($self->no_upload) { say '[@Author::CCM] WARNING! WARNING! WARNING! *** You are in no_upload mode!! ***'; @@ -318,6 +334,29 @@ sub configure { $self->add_plugins(@plugins); } +sub _travis_perl_versions { + my $self = shift; + + my $perl_version_target = Perl::Version->new(shift or die 'Missing target version'); + my $min_version = Perl::Version->new('5.14'); + my $min_version_build = Perl::Version->new($perl_version_target); + $min_version_build->subversion(0); + + my @versions; + my @versions_build; + + for my $v (qw{5.26 5.24 5.22 5.20 5.18 5.16 5.14 5.12 5.10 5.8}) { + my $version = Perl::Version->new($v); + push @versions, "$version" if $version >= $min_version_build && $version >= $min_version; + push @versions_build, "$version" if $version >= $min_version_build; + } + + my $perl_version = join(' ', @versions); + my $perl_version_build = join(' ', @versions_build); + + return ($perl_version, $perl_version_build); +} + with 'Dist::Zilla::Role::PluginBundle::Easy'; with 'Dist::Zilla::Role::PluginBundle::PluginRemover'; with 'Dist::Zilla::Role::PluginBundle::Config::Slicer'; -- 2.45.2