Caching perl modules when running on Travis CI

The more dependencies a perl project has the longer the duration of each Travis CI job. Travis supports caching of defined directories to speed up builds.

To improve the build time we can use the local::lib perl module to create a new directory where all dependencies for the project will be installed. Then this directory can be specified in the Travis configuration to be cached.

Here is an example travis.yml file:

sudo: false
language: perl
  - perl_modules
- cpanm local::lib
- eval "$(perl -Mlocal::lib=${PWD}/perl_modules)"

Other than the changes above, the travis defaults can still be used for the builds steps that are not specified.

Once the perl project has been configured as above any subsequent builds will be quicker.

Last updated: 26/09/2016