Use docker in travis ci perl builds

Shoichi Kaji
1 min readAug 3, 2019

Recently, the default ubuntu version in travis ci has changed from trusty (14.04) to xenial (16.04).

This may cause test failures for some perl projects because old perls are not available for xenial. And it seems that it is intentional https://travis-ci.community/t/failure-with-perl-5-16-5-18-5-20/2458.
To be fair, I think it is reasonable they does not support old perls.

So if you still want to test your projects against old perls, you need to set dist: trusty in your travis.yml explicitly. In fact, I did so in WWW-Mechanize https://github.com/libwww-perl/WWW-Mechanize/pull/279.

TMTOWTDI. How about using docker directly? I think it is simpler and does not care about which ci platform we are using. Here is an example of travis.yml:

language: minimal
services: docker
env:
- image=perl:5.8
- image=perl:5.10
- image=perl:5.16
- image=perl:5.30
- image=perl:5.30-threaded
before_install:
- docker pull $image
- docker run $image perl -V
script:
- |
docker run --init -it -v $PWD:/$TRAVIS_REPO_SLUG -w /$TRAVIS_REPO_SLUG $image bash -c '
set -euxo pipefail
cpanm --notest --quiet --installdeps .
prove -lr t
'

I’ve just switched to docker in cpm https://github.com/skaji/cpm/commit/7497257. So far so good 😄

--

--