-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I spent some time this evening adding caching of modules installed with this action to one of my projects (rra/rra-c-util). The cache action doesn't support running with sudo, so this required disabling sudo and installing into the local::lib
path, which isn't ideal, but it seems to work.
I had to add some inobvious configuration to the action that would be easier if it were encapsulated in a configuration option. Specifically, I needed:
- uses: perl-actions/[email protected]
env:
PERL5LIB: ${{ env.HOME }}/perl5
with:
args: "--local-lib=~/perl5"
path: /usr/bin/cpanm
sudo: false
to make everything work. Setting PERL5LIB
was inobvious (cpanm --local-lib=~/perl5
does not set that variable and thus installation of modules that have dependencies that also have to be installed fails), as was needing to pre-install cpanminus with apt-get
and then set path
. I think the latter is because the default path cannot be written to without using sudo
, and maybe there's an easier approach.
Would you be willing to add something like:
with:
local-lib: ~/perl5
that sets both args
and the environment variable (after tilde expansion)? Or even a boolean that always uses ~/perl5
, since that's what local::lib
wants. An option to use the pre-installed cpanm
or maybe just switch to a different path when sudo: false
would also be useful.
For the record, here's the full working workflow with caching:
jobs:
build:
runs-on: ubuntu-latest
env:
AUTHOR_TESTING: 1
C_TAP_VERBOSE: 1
steps:
- uses: actions/checkout@v2
- name: install
run: sudo -E ci/install
- name: Get Perl version
id: get-perl
run: |
perl -e 'print "::set-output name=version::", $^V, "\n"'
- name: Cache Perl modules
uses: actions/cache@v2
with:
path: ~/perl5
key: ${{ runner.os }}-perl-${{ steps.get-perl.outputs.version }}-${{ hashFiles('ci/cpanfile') }}
restore-keys: |
${{ runner.os }}-perl-${{ steps.get-perl.outputs.version }}-
- uses: perl-actions/[email protected]
env:
PERL5LIB: ${{ env.HOME }}/perl5
with:
args: "--local-lib=~/perl5"
cpanfile: ci/cpanfile
path: /usr/bin/cpanm
sudo: false
- name: test
run: ci/test