Skip to content

Commit

Permalink
add perl 5.8.x and 5.6.x (#453)
Browse files Browse the repository at this point in the history
* add perl 5.8.x and 5.6.x

* remove dependency to cpanm from build.pl

* set PERL_MM_USE_DEFAULT

* skip windows builds

* add perl 5.8.5 on windows

* fix dirname

* skip to install MakeMaker

* install File::Temp

* add some modules

* fix tests

* install  JSON-PP-Compat5006
  • Loading branch information
shogo82148 committed Nov 14, 2020
1 parent c7d2638 commit 87b2693
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 36 deletions.
98 changes: 82 additions & 16 deletions scripts/darwin/build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
use File::Path qw/make_path/;
use version 0.77 ();
use Carp qw/croak/;
use Actions::Core qw/group set_failed/;
use Actions::Core qw/info group set_failed/;

my $version = $ENV{PERL_VERSION};
my $tmpdir = File::Spec->rel2abs($ENV{RUNNER_TEMP} || "tmp");
make_path($tmpdir);
my $install_dir = File::Spec->rel2abs(
File::Spec->catdir($ENV{RUNNER_TOOL_CACHE} || $tmpdir, "perl", $version, "x64"));
my $perl = File::Spec->catfile($install_dir, 'bin', 'perl');

sub execute_or_die {
my $code = system(@_);
Expand All @@ -21,13 +28,35 @@ sub execute_or_die {
}
}

sub run {
my $version = $ENV{PERL_VERSION};
my $tmpdir = File::Spec->rel2abs($ENV{RUNNER_TEMP} || "tmp");
make_path($tmpdir);
my $install_dir = File::Spec->rel2abs(
File::Spec->catdir($ENV{RUNNER_TOOL_CACHE} || $tmpdir, "perl", $version, "x64"));
sub cpan_install {
my ($url, $min_version, $max_version) = @_;

# this perl is too old to install the module.
if ($min_version && version->parse("v$version") < version->parse("v$min_version")) {
info "skip installing $url";
return;
}

# no need to install
if ($max_version && version->parse("v$version") >= version->parse("v$max_version")) {
return;
}

my @path = split m(/), $url;
my $filename = $path[-1];
my @ext = split /[.]tar[.]/, $filename;
my $dirname = $ext[0];

info "installing $url";
chdir $tmpdir or die "failed to cd $tmpdir: $!";
execute_or_die('curl', '-sSL', $url, '-o', $filename);
execute_or_die('tar', 'xvf', $filename);
chdir File::Spec->catfile($tmpdir, $dirname) or die "failed to cd $dirname: $!";
execute_or_die($perl, 'Makefile.PL');
execute_or_die('make', 'install');
}

sub run {
group "build perl $version" => sub {
local $ENV{PERL5_PATCHPERL_PLUGIN} = "GitHubActions";

Expand All @@ -54,20 +83,57 @@ sub run {
};

group "perl -V" => sub {
system(File::Spec->catfile($install_dir, 'bin', 'perl'), '-V') == 0 or die "$!";
execute_or_die($perl, '-V');
};

group "install common CPAN modules" => sub {
my $perl = File::Spec->catfile($install_dir, 'bin', 'perl');
my $cpanm = File::Spec->catfile($FindBin::Bin, '..', '..', 'bin', 'cpanm');
# JSON
cpan_install('https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/JSON-4.02.tar.gz', '5.5.3');

# Cpanel::JSON::XS
cpan_install('https://cpan.metacpan.org/authors/id/R/RU/RURBAN/Cpanel-JSON-XS-4.25.tar.gz', '5.6.2');

# some requirements of JSON::XS
cpan_install('https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/Canary-Stability-2013.tar.gz', '5.8.3');
cpan_install('https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/common-sense-3.75.tar.gz', '5.8.3');
cpan_install('https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/Types-Serialiser-1.0.tar.gz', '5.8.3');
# JSON::XS
cpan_install('https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/JSON-XS-4.03.tar.gz', '5.8.3');

# some requirements of JSON::PP
cpan_install('https://cpan.metacpan.org/authors/id/C/CO/CORION/parent-0.238.tar.gz', '5.6.0', '5.10.1');
cpan_install('https://cpan.metacpan.org/authors/id/J/JK/JKEENAN/File-Path-2.18.tar.gz', '5.6.0', '5.6.1');
cpan_install('https://cpan.metacpan.org/authors/id/P/PE/PEVANS/Scalar-List-Utils-1.55.tar.gz', '5.6.0', '5.8.1');
cpan_install('https://cpan.metacpan.org/authors/id/T/TO/TODDR/Exporter-5.74.tar.gz', '5.6.0', '5.6.1');
cpan_install('https://cpan.metacpan.org/authors/id/E/ET/ETHER/File-Temp-0.2311.tar.gz', '5.6.0', '5.6.1');
cpan_install('https://cpan.metacpan.org/authors/id/M/MA/MAKAMAKA/JSON-PP-Compat5006-1.09.tar.gz', '5.6.0', '5.8.0');
# JSON::PP
cpan_install('https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/JSON-PP-4.05.tar.gz', '5.6.0');

# JSON::MaybeXS
cpan_install('https://cpan.metacpan.org/authors/id/E/ET/ETHER/JSON-MaybeXS-1.004003.tar.gz', '5.6.0');

# YAML
cpan_install('https://cpan.metacpan.org/authors/id/T/TI/TINITA/YAML-1.30.tar.gz', '5.8.1');

# YAML::Tiny
cpan_install('https://cpan.metacpan.org/authors/id/E/ET/ETHER/YAML-Tiny-1.73.tar.gz', '5.8.1');

# YAML::XS
cpan_install('https://cpan.metacpan.org/authors/id/T/TI/TINITA/YAML-LibYAML-0.82.tar.gz', '5.8.1');

### SSL/TLS

# Net::SSLeay
cpan_install('https://cpan.metacpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.88.tar.gz', '5.8.1');

# JSON and YAML
execute_or_die($perl, $cpanm, '-n', 'JSON', 'Cpanel::JSON::XS', 'JSON::XS', 'JSON::MaybeXS', 'YAML', 'YAML::Tiny', 'YAML::XS');
# Mozilla::CA
cpan_install('https://cpan.metacpan.org/authors/id/A/AB/ABH/Mozilla-CA-20200520.tar.gz', '5.6.0');

# SSL/TLS
execute_or_die($perl, $cpanm, '-n', 'Net::SSLeay');
execute_or_die($perl, $cpanm, '-n', 'IO::Socket::SSL');
execute_or_die($perl, $cpanm, '-n', 'Mozilla::CA');
# IO::Socket::SSL
local $ENV{NO_NETWORK_TESTING} = 1;
local $ENV{PERL_MM_USE_DEFAULT} = 1;
cpan_install('https://cpan.metacpan.org/authors/id/S/SU/SULLR/IO-Socket-SSL-2.068.tar.gz', '5.8.0');
};

group "archiving" => sub {
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/Actions/Core.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Actions::Core;

use 5.8.5;
use 5.006_001;
use utf8;
use warnings;
use strict;
Expand Down
97 changes: 83 additions & 14 deletions scripts/linux/build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
use Try::Tiny;
use Perl::Build;
use File::Spec;
use File::Path qw/make_path/;
use version 0.77 ();
use Carp qw/croak/;
use Actions::Core qw/group set_failed/;
use Actions::Core qw/info group set_failed/;

my $version = $ENV{PERL_VERSION};
my $tmpdir = File::Spec->rel2abs($ENV{RUNNER_TEMP} || "tmp");
make_path($tmpdir);
my $install_dir = File::Spec->rel2abs(
File::Spec->catdir($ENV{RUNNER_TOOL_CACHE} || $tmpdir, "perl", $version, "x64"));
my $perl = File::Spec->catfile($install_dir, 'bin', 'perl');

sub execute_or_die {
my $code = system(@_);
Expand All @@ -20,11 +28,35 @@ sub execute_or_die {
}
}

sub run {
my $version = $ENV{PERL_VERSION};
my $install_dir = File::Spec->catdir($ENV{RUNNER_TOOL_CACHE}, "perl", $version, "x64");
my $tmpdir = $ENV{RUNNER_TEMP};
sub cpan_install {
my ($url, $min_version, $max_version) = @_;

# this perl is too old to install the module.
if ($min_version && version->parse("v$version") < version->parse("v$min_version")) {
info "skip installing $url";
return;
}

# no need to install
if ($max_version && version->parse("v$version") >= version->parse("v$max_version")) {
return;
}

my @path = split m(/), $url;
my $filename = $path[-1];
my @ext = split /[.]tar[.]/, $filename;
my $dirname = $ext[0];

info "installing $url";
chdir $tmpdir or die "failed to cd $tmpdir: $!";
execute_or_die('curl', '-sSL', $url, '-o', $filename);
execute_or_die('tar', 'xvf', $filename);
chdir File::Spec->catfile($tmpdir, $dirname) or die "failed to cd $dirname: $!";
execute_or_die($perl, 'Makefile.PL');
execute_or_die('make', 'install');
}

sub run {
group "build perl $version" => sub {
local $ENV{PERL5_PATCHPERL_PLUGIN} = "GitHubActions";

Expand All @@ -51,20 +83,57 @@ sub run {
};

group "perl -V" => sub {
system(File::Spec->catfile($install_dir, 'bin', 'perl'), '-V') == 0 or die "$!";
execute_or_die($perl, '-V');
};

group "install common CPAN modules" => sub {
my $perl = File::Spec->catfile($install_dir, 'bin', 'perl');
my $cpanm = File::Spec->catfile($FindBin::Bin, '..', '..', 'bin', 'cpanm');
# JSON
cpan_install('https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/JSON-4.02.tar.gz', '5.5.3');

# Cpanel::JSON::XS
cpan_install('https://cpan.metacpan.org/authors/id/R/RU/RURBAN/Cpanel-JSON-XS-4.25.tar.gz', '5.6.2');

# some requirements of JSON::XS
cpan_install('https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/Canary-Stability-2013.tar.gz', '5.8.3');
cpan_install('https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/common-sense-3.75.tar.gz', '5.8.3');
cpan_install('https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/Types-Serialiser-1.0.tar.gz', '5.8.3');
# JSON::XS
cpan_install('https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/JSON-XS-4.03.tar.gz', '5.8.3');

# some requirements of JSON::PP
cpan_install('https://cpan.metacpan.org/authors/id/C/CO/CORION/parent-0.238.tar.gz', '5.6.0', '5.10.1');
cpan_install('https://cpan.metacpan.org/authors/id/J/JK/JKEENAN/File-Path-2.18.tar.gz', '5.6.0', '5.6.1');
cpan_install('https://cpan.metacpan.org/authors/id/P/PE/PEVANS/Scalar-List-Utils-1.55.tar.gz', '5.6.0', '5.8.1');
cpan_install('https://cpan.metacpan.org/authors/id/T/TO/TODDR/Exporter-5.74.tar.gz', '5.6.0', '5.6.1');
cpan_install('https://cpan.metacpan.org/authors/id/E/ET/ETHER/File-Temp-0.2311.tar.gz', '5.6.0', '5.6.1');
cpan_install('https://cpan.metacpan.org/authors/id/M/MA/MAKAMAKA/JSON-PP-Compat5006-1.09.tar.gz', '5.6.0', '5.8.0');
# JSON::PP
cpan_install('https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/JSON-PP-4.05.tar.gz', '5.6.0');

# JSON::MaybeXS
cpan_install('https://cpan.metacpan.org/authors/id/E/ET/ETHER/JSON-MaybeXS-1.004003.tar.gz', '5.6.0');

# YAML
cpan_install('https://cpan.metacpan.org/authors/id/T/TI/TINITA/YAML-1.30.tar.gz', '5.8.1');

# YAML::Tiny
cpan_install('https://cpan.metacpan.org/authors/id/E/ET/ETHER/YAML-Tiny-1.73.tar.gz', '5.8.1');

# YAML::XS
cpan_install('https://cpan.metacpan.org/authors/id/T/TI/TINITA/YAML-LibYAML-0.82.tar.gz', '5.8.1');

### SSL/TLS

# Net::SSLeay
cpan_install('https://cpan.metacpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.88.tar.gz', '5.8.1');

# JSON and YAML
execute_or_die($perl, $cpanm, '-n', 'JSON', 'Cpanel::JSON::XS', 'JSON::XS', 'JSON::MaybeXS', 'YAML', 'YAML::Tiny', 'YAML::XS');
# Mozilla::CA
cpan_install('https://cpan.metacpan.org/authors/id/A/AB/ABH/Mozilla-CA-20200520.tar.gz', '5.6.0');

# SSL/TLS
execute_or_die($perl, $cpanm, '-n', 'Net::SSLeay');
execute_or_die($perl, $cpanm, '-n', 'IO::Socket::SSL');
execute_or_die($perl, $cpanm, '-n', 'Mozilla::CA');
# IO::Socket::SSL
local $ENV{NO_NETWORK_TESTING} = 1;
local $ENV{PERL_MM_USE_DEFAULT} = 1;
cpan_install('https://cpan.metacpan.org/authors/id/S/SU/SULLR/IO-Socket-SSL-2.068.tar.gz', '5.8.0');
};

group "archiving" => sub {
Expand Down
6 changes: 3 additions & 3 deletions scripts/t/02_perl_versions.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use Actions::Core qw(perl_versions);

# use in array context
my @versions = perl_versions();
is $versions[-1], '5.8.9', 'the latest version of 5.8.x';
is $versions[-1], ($^O eq 'MSWin32' ? '5.8.9' : '5.6.2'), 'the oldest version of perl';

# use in scalar context
my $versions = perl_versions();
is $versions->[-1], '5.8.9', 'the latest version of 5.8.x';
is $versions->[-1], ($^O eq 'MSWin32' ? '5.8.9' : '5.6.2'), 'the oldest version of perl';

$versions = perl_versions(patch => 1);
is $versions->[-1], '5.8.5', 'the oldest version of 5.8.x';
is $versions->[-1], ($^O eq 'MSWin32' ? '5.8.5' : '5.6.0'), 'the oldest version of perl';

# distribution: 'stawberry'
$versions = perl_versions( platform => 'win32', distribution => 'strawberry' );
Expand Down
10 changes: 9 additions & 1 deletion versions/darwin.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,13 @@
"5.8.8",
"5.8.7",
"5.8.6",
"5.8.5"
"5.8.5",
"5.8.4",
"5.8.3",
"5.8.2",
"5.8.1",
"5.8.0",
"5.6.2",
"5.6.1",
"5.6.0"
]
10 changes: 9 additions & 1 deletion versions/linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,13 @@
"5.8.8",
"5.8.7",
"5.8.6",
"5.8.5"
"5.8.5",
"5.8.4",
"5.8.3",
"5.8.2",
"5.8.1",
"5.8.0",
"5.6.2",
"5.6.1",
"5.6.0"
]

0 comments on commit 87b2693

Please sign in to comment.