DEV Community

Cover image for A tour of Perl Github actions

A tour of Perl Github actions

403 Forbidden
・4 min read

I am using A LOT github actions.

I like them well and nothing hurts me too much (except the scheduled jobs auto disabling, but I now accepted to live with it 😢).

Crowd Surfing

I use them for instance for doing strange things like CI poor-man dashboards like the picture below:


Or I simply use them to test my modules.

I even produced this showcase (not limited to github) or posted a long writing about a crypto-mining attack that targeted my github actions recently.

"Github actions" actually designates both the CI system in general and the ready-to-use modules made for it (what you could find on Circle CI under the name "Orbs" or "pipeline libraries" in Jenkins).

Now I will talk about "Github action" modules 😄

You can almost live without Github actions (I would at least use checkout action), but they bring so much convenience that you should really give them a try 😀

The status of github actions for Perl

There are already some github actions to satisfy most needs like installing CPAN deps, testing a distribution or linting (validating with perlcritic).

You have the excellent Setup Perl to install the perl version of your choice + install CPAN modules (cpanm and cpm inside!)

    - uses: actions/checkout@v1
    - name: Setup Perl
      uses: shogo82148/actions-setup-perl@v1
        perl-version: '5.30'
    - name: perl -V
      run: perl -V
    - run: cpanm --installdeps .
    - run: prove -lv t
Enter fullscreen mode Exit fullscreen mode

Note: The "Setup X" is common for actions and we find that for lot of technologies ("Setup Python", "Setup Ruby", "Setup Jira"...)

"Setup perl" installs perl but if you want, there is also the possibility to use a docker image having already the version you want:


    runs-on: ubuntu-latest

          - '5.10'
          - '5.16'
          - 'latest'
          - 'threaded'

      image: perl:${{ matrix.perl-version }}

      - uses: actions/checkout@v2
      - name: perl -V
        run: perl -V
Enter fullscreen mode Exit fullscreen mode

This will connect to a ubuntu-latest VM having docker, launch 4 containers perl:5.10, perl:5.16, perl:latest and perl:threaded and run your perl -V inside.


You can even come with your own customized image (that you can create and push from another github repo with its own github action).
Another example is ci-perl-helpers-ubuntu from houseabsolute/ci-perl-helpers that seems to target transparent multi ci providers tooling.

With containers, the actual perl setup has been done during the docker packaging.

There are the also excellent install-with-cpanm or install-with-cpm that give you convenient and unified actions to install CPAN modules:


- name: install cpanm and multiple modules
  uses: perl-actions/install-with-cpanm@v1
    install: |
Enter fullscreen mode Exit fullscreen mode

The | is for introducing multiline.


- name: install cpm and multiple modules
  uses: perl-actions/install-with-cpm@stable
    install: |
Enter fullscreen mode Exit fullscreen mode

Do you know that cpm is fast?

... Or their poor man versions

I'm decidedly a poor man!

You can also simulate install-with-cpanm with:

      - name: Install alien
        run: curl -L | perl - --configure-timeout=1920 Alien::FFI
Enter fullscreen mode Exit fullscreen mode

Or for cpm:

      - name: Install alien
        run: curl -sL | perl - install --show-build-log-on-failure --test --configure-timeout=1920 Alien::FFI
Enter fullscreen mode Exit fullscreen mode

Please note the --configure-timeout option to increase the configure time (Alien modules can take long time)

The cpm --show-build-log-on-failure is a candy ❤️

The --test is to run tests (cpm by default disables them, for speed!)

You probably noticed that these versions use the pre-installed perl that comes with the VM but it is generally OK.

More and more with ci-perl-tester-helpers

There is even more in ci-actions-perl-helpers since it configures with dzil or minil, installs deps and builds your code.

(I haven't tested this one)

Perlcritic actions

I haven't tested any, but there is multiple perlcritic github actions. See gugod-perlcritic or gugod-perlcritic-with-reviewdog or perl-critic-action or perl-critic or action-perlcritic.

So much choices...


Your first action?

It appears a bit late in this post 😀 but if you never jumped into github actions, here is my quickstart:

  1. Create a file in .github/workflows/ (need to create the directory) named for install check.yml
  2. Put this yml code inside:
name: check-syntax

on: [push]

    runs-on: ubuntu-latest
    - uses: actions/checkout@v2
    - name: Check syntax 
      run: for f in `find . -name "*.pm" -o -name "*.pl" -o -name "*.t"`; do perl -c $f; done
Enter fullscreen mode Exit fullscreen mode

Push then wait and see 😄


This is the end of my tour of Github actions for Perl.

I have still plenty of things to say but won't fall into too much details 😄 maybe in another blog post 😄

I hope you learned something or that I gave you the motivation to setup a github action on your repository!

Discussion (0)