Last Updated: February 25, 2016
·
456
· stevenl

Building Dist::Zilla distributions with Travis CI and Coveralls

I've been trying to get Travis CI to work with my distribution for a while. Recently I found this article that offered the right solution.

The solution is to use perl-travis-helper. I'd tried this before but with no success. The problem at that time was because I was trying to run it in auto mode, which doesn't handle Dzil.

Here's how my .travis.yml file looks like:

language: perl

perl:
  - "5.20"
  - "5.18"
  - "5.16"
  - "5.14"
  - "5.12"
  - "5.10"

before_install:
  - git clone git://github.com/haarg/perl-travis-helper
  - source perl-travis-helper/init
  - build-perl
  - perl -V
  - build-dist
  - cd $BUILD_DIR

install:
  - cpanm --quiet --notest --installdeps .

The trick here is in the line build-dist for handling Dzil setups with all of its dependencies.

Next, I could add coverage testing with a few more lines.

install:
  - export RELEASE_TESTING=1 AUTOMATED_TESTING=1 AUTHOR_TESTING=1 HARNESS_OPTIONS=c HARNESS_TIMER=1
  - cpanm --quiet --notest Devel::Cover::Report::Coveralls
  - cpanm --quiet --notest --installdeps .
  - cpanm --quiet --notest --with-develop .

script:
  - PERL5OPT=-MDevel::Cover=-coverage,statement,branch,condition,path,subroutine prove -lrsv t
  - cover

after_success:
  - cover -report coveralls

This requires that we run Devel::Cover and to format the reports using Devel::Cover::Report::Coveralls.

I also had to install suggested dependencies for running my author tests, which could be done with the --with-develop option for cpanm.