Skip to content

Commit

Permalink
Tweak GitHub CI to address consistent failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
trwyant committed Oct 28, 2023
1 parent ef4b7f7 commit 9c49bb4
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 13 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ jobs:
- name: Customize environment
run: |
perl -V:make
cpanm -v
cpanm File::HomeDir Getopt::Long version
cpanm File::Spec Getopt::Long version
perl .github/workflows/environment.PL
- name: Display local envoronment variables
Expand All @@ -90,6 +91,7 @@ jobs:
echo MY_IS_GITHUB_ACTION=${{ env.MY_IS_GITHUB_ACTION }}
echo MY_IS_UNIX=${{ env.MY_IS_UNIX }}
echo MY_IS_WINDOWS=${{ env.MY_IS_WINDOWS }}
echo MY_MAKE=${{ env.MY_MAKE }}
echo MY_WANT_POD_MAN=${{ env.MY_WANT_POD_MAN }}
# Non-core toolchain Module::Build needs Pod::Man, which is in
Expand All @@ -111,8 +113,8 @@ jobs:
- name: Run ExtUtils::MakeMaker tests
run: |
perl Makefile.PL
make
make test
${{ env.MY_MAKE }}
${{ env.MY_MAKE }} test
- name: Run Module::Build tests
run: |
Expand Down
106 changes: 96 additions & 10 deletions .github/workflows/environment.PL
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use 5.006002;
use strict;
use warnings;

use File::HomeDir;
use Config;
use File::Spec;
use Getopt::Long;
use version;

Expand Down Expand Up @@ -45,11 +46,15 @@ sub compute_environment {
dos => 1,
}->{$^O} || '';
my $is_unix = $is_windows ? '' : 1;
my $my_home = $is_windows ?
__PACKAGE__->my_home_windows() :
__PACKAGE__->my_home_unix();
my %env = (
MY_HOME => File::HomeDir->my_home(),
MY_HOME => $my_home,
MY_IS_GITHUB_ACTION => 1,
MY_IS_UNIX => $is_unix,
MY_IS_WINDOWS => $is_windows,
MY_MAKE => $Config{make},
MY_WANT_POD_MAN => want_pod_man(),
);

Expand All @@ -59,6 +64,92 @@ sub compute_environment {
return \%env;
}

# BEGIN Stolen shamelessly from File::HomeDir::Windows

sub my_home_windows
{
my $class = shift;

# A lot of unix people and unix-derived tools rely on
# the ability to overload HOME. We will support it too
# so that they can replace raw HOME calls with File::HomeDir.
if (exists $ENV{HOME} and defined $ENV{HOME} and length $ENV{HOME})
{
return $ENV{HOME};
}

# Do we have a user profile?
if (exists $ENV{USERPROFILE} and $ENV{USERPROFILE})
{
return $ENV{USERPROFILE};
}

# Some Windows use something like $ENV{HOME}
if (exists $ENV{HOMEDRIVE} and exists $ENV{HOMEPATH} and $ENV{HOMEDRIVE} and $ENV{HOMEPATH})
{
return File::Spec->catpath($ENV{HOMEDRIVE}, $ENV{HOMEPATH}, '',);
}

return undef;
}

sub my_home_unix
{
my $class = shift;
my $home = $class->_guess_home(@_);

# On Unix in general, a non-existent home means "no home"
# For example, "nobody"-like users might use /nonexistent
if (defined $home and not -d $home)
{
$home = undef;
}

return $home;
}

sub _guess_env_home
{
my $class = shift;
if (exists $ENV{HOME} and defined $ENV{HOME} and length $ENV{HOME})
{
return $ENV{HOME};
}

# This is from the original code, but I'm guessing
# it means "login directory" and exists on some Unixes.
if (exists $ENV{LOGDIR} and $ENV{LOGDIR})
{
return $ENV{LOGDIR};
}

return;
}

sub _guess_determined_home
{
my $class = shift;

# Light desperation on any (Unixish) platform
SCOPE:
{
my $home = (getpwuid($<))[7];
return $home if $home and -d $home;
}

return;
}

sub _guess_home
{
my $class = shift;
my $home = $class->_guess_env_home($@);
$home ||= $class->_guess_determined_home($@);
return $home;
}

# END Stolen shamelessly from File::HomeDir::Windows

sub want_pod_man {
my ( $perl_ver ) = @_;
defined $perl_ver
Expand Down Expand Up @@ -102,8 +193,8 @@ environment. The following environment variables are added:
=head2 MY_HOME
The job's home directory, as determined by
L<File::HomeDir|File::HomeDir>.
The job's home directory, as determined by internal code stolen
shamelessly from L<File::HomeDir|File::HomeDir>.
=head2 MY_IS_GITHUB_ACTION
Expand All @@ -121,15 +212,10 @@ True (i.e. C<1>) if running under Windows, and false (i.e. C<''>)
othewise. At the moment this is true if C<$^O> is C<'MSWin32'> or
C<'dos'>.
=head2 MY_PERL_IS_5_10
True (i.e. C<1>) if running under at least Perl 5.10.0, and false
(i.e. C<''>) otherwise.
=head2 MY_WANT_POD_MAN
The specification of the C<podlators> distribution to install.
Emptu if the version that comes with the running Perl is OK. This
Empty if the version that comes with the running Perl is OK. This
is needed because Module::Build requires it.
=head1 AUTHOR
Expand Down

0 comments on commit 9c49bb4

Please sign in to comment.