Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
arrow-down

GitHub Action

install with cpanminus

v1.1

install with cpanminus

arrow-down

install with cpanminus

install Perl Modules with App::cpanminus

Installation

Copy and paste the following snippet into your .yml file.

              

- name: install with cpanminus

uses: perl-actions/install-with-cpanm@v1.1

Learn more about this action in perl-actions/install-with-cpanm

Choose a version

Actions Status

install-with-cpanm

GitHub action to install Perl Modules App::cpanminus

This action installs 'cpanminus' then use it if needed to install some Perl Modules.

- name: install cpanm and multiple modules
  uses: perl-actions/install-with-cpanm@v1.1
  with:
    install: |
      Simple::Accessor
      Test::Parallel

# or you can use a cpanfile
#     cpanfile: 'your-cpanfile'
# default values you can customize
#     sudo: true
# where to install cpanm
#     path: "$Config{installsitescript}/cpanm"
# which perl binary to use
#     perl: 'perl'

Using install-with-cpanm in a GitHub workflow

Here is a sample integration using install-with-cpanm action to test your Perl Modules using multiple Perl versions via the perl-tester images.

# .github/workflows/linux.yml
jobs:
  perl_tester:
    runs-on: ubuntu-latest
    name: "perl v${{ matrix.perl-version }}"

    strategy:
      fail-fast: false
      matrix:
        perl-version:
          - "5.30"
          - "5.28"
          - "5.26"
        # ...
        # - '5.8'

    container:
      image: perldocker/perl-tester:${{ matrix.perl-version }}

    steps:
      - uses: actions/checkout@v2
      - name: uses install-with-cpm
        uses: perl-actions/install-with-cpanm@v1.1
        with:
          cpanfile: "cpanfile"
          sudo: false
      - run: perl Makefile.PL
      - run: make test

Inputs

install

List of one or more modules, separated by a newline \n character.

cpanfile

Install modules from a cpanfile.

tests

Boolean variable used to disable unit tests during installation Possible values: true | false [default: false]

args

Extra arguments to pass to the cpanm command line.

example:

args: "-L vendor"

sudo

Run commands as sudo: true | false [default: true]

perl

Which perl path to use. Default to use perl from the current PATH. By setting PATH correctly you probably do not need to use it.

path

Where to install cpanm. Default value is $Config{installsitescript}/cpanm. You can use any $Config variable in your string.

Outputs

none

Example usage

Install cpanm and use it manually later

uses: perl-actions/install-with-cpanm@v1.1
# you can then use it later
run: sudo cpanm Module::To::Install

but you should prefer let the action install your modules

Install cpanm and a single module

- name: install cpanm and one module
  uses: perl-actions/install-with-cpanm@v1.1
  with:
    install: "Simple::Accessor"

Install cpanm and multiple modules

- name: install cpanm and one module
  uses: perl-actions/install-with-cpanm@v1.1
  with:
    install: |
      Simple::Accessor
      Test::Parallel

Install modules from a cpanfile

- name: install cpanm and files from cpanfile
  uses: perl-actions/install-with-cpanm@v1.1
  with:
    cpanfile: "your-cpanfile"

Install a module and enable tests

Install modules with tests.

- name: install cpm and files from cpanfile
  uses: perl-actions/install-with-cpanm@v1.1
  with:
    install: "Simple::Accessor"
    tests: true

Using install-with-cpm on Windows / win32

Here is a sample job using cpanm to install modules on windows.

windows:
  runs-on: windows-latest
  name: "windows"

  steps:
    - name: Set up Perl
      run: |
        choco install strawberryperl
        echo "##[add-path]C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin"

    - name: perl -V
      run: perl -V

    - uses: actions/checkout@v2
    - name: "install-with-cpanm"
      uses: perl-actions/install-with-cpm@v1.1
      with:
        install: |
          abbreviation
          ACH
    # checking that both modules are installed
    - run: perl -Mabbreviation -e1
    - run: perl -MACH -e1