GitHub Action
Setup Perl environment
This action sets by perl environment for use in actions by:
- optionally downloading and caching a version of perl
- registering problem matchers for error output
See action.yml
Basic:
steps:
- uses: actions/checkout@v2
- uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.32'
- run: cpanm --installdeps .
- run: prove -lv t
Matrix Testing:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
perl: [ '5.32', '5.30', '5.28' ]
name: Perl ${{ matrix.perl }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ matrix.perl }}
- run: perl -V
- run: cpanm --installdeps .
- run: prove -lv t
actions-setup-perl uses the binaries customized for GitHub Actions by default.
If you want to use Strawberry Perl on Windows, add distribution: strawberry
into the "with" section.
steps:
- uses: actions/checkout@v2
- uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.30'
distribution: strawberry
- run: cpanm --installdeps .
- run: prove -lv t
This option is available on Windows and falls back to the default customized binaries on other platforms.
All inputs are optional. If not set, sensible defaults will be used.
Name | Description | Default |
---|---|---|
perl-version |
Specifies the Perl version to setup. Minor version and patch level can be omitted. The action uses the latest Perl version available that matches the specified value. This defaults to 5 , which results in the latest available version of Perl 5. In addition, the value latest is available, the actions uses the latest available version of Perl including 5 , 7 or later major versions. |
5 |
distribution |
Specify the distribution to use, this is either default or strawberry . (The value strawberry is ignored on anything but Windows.) |
default |
The GitHub runner come with a preinstalled version of Perl, used by the system Git. Unfortunately, some shell types prepend the directory containing the system Perl to the PATH
which makes it impossible to use the Perl installed by this action.
shell parameter |
Linux | macOS | Windows (default) | Windows (Strawberry) |
---|---|---|---|---|
bash |
✔️ | ✔️ | ❌1) | ❌1) |
pwsh |
✔️ | ✔️ | ✔️ | ✔️ |
python |
✔️ | ✔️ | ✔️ | ✔️ |
sh |
✔️ | ✔️ | n/a | n/a |
cmd |
n/a | n/a | ✔️ | ✔️ |
powershell |
n/a | n/a | ✔️ | ✔️ |
custom shell perl {0} |
✔️ | ✔️ | ✔️ | ✔️ |
- On Windows, the bash shell always gets
/usr/bin
prepended to thePATH
which contains the system Perl.
The following Perl scripts are pre-installed for convenience.
Perl port of @actions/core.
use Actions::Core;
# Inputs/Outputs
my $input = get_input('inputName', { required: true });
set_output('outputKey', 'outputVal');
# Exporting variables
export_variable('envVar', 'Val');
# Setting a secret
set_secret('myPassword');
# PATH Manipulation
add_path('/path/to/mytool');
# Exit codes
set_failed(`Action failed with error ${err}`);
# Logging
debug('debug message');
warning('warning');
if (is_debug()) {
# print verbose log
}
info('Output to the actions build log');
# Manually wrap output
start_group('Do some function');
do_some_function();
end_group();
# Wrap Subroutines
my $result = group 'Do something async' => sub {
return 'some results';
}
# Custom Functions of actions-setup-perl
# List Available Perl Versions
my @available_perls_on_current_platform = perl_versions(); # ('5.32.0', '5.30.3', '5.28.3', ...)
my @available_perls_on_linux = perl_versions(platform => 'linux');
my @available_perls_on_darwin = perl_versions(platform => 'darwin');
my @available_perls_on_win32 = perl_versions(platform => 'win32');
my @available_strawberry_perls = perl_versions(platform => 'win32', distribution => 'strawberry');
my @including_patch_versions = perl_versions(patch => 1); # ('5.32.0', '5.30.3', '5.30.2', ...)
Example matrix workflow of using perl_versions
:
jobs:
list:
name: list available perl versions
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-setup-perl@v1
- id: set-matrix
name: list available perl versions
shell: perl {0}
run: |
use Actions::Core;
set_output(matrix => {perl => [perl_versions()]});
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
run:
runs-on: ubuntu-latest
needs: list
strategy:
fail-fast: false
matrix: ${{fromJson(needs.list.outputs.matrix)}}
steps:
- uses: shogo82148/actions-setup-perl@v1
with:
perl_version: ${{ matrix.perl }}
# do something
- On Windows,
shell: bash
steps continue to use the system perl #328 - Perl 5.12, 5.10, and 5.8 of the default distribution on Windows sometimes cause
EXCEPTION_ACCESS_VIOLATION
#225
The scripts and documentation in this project are released under the MIT License