Speedup Travis by tweaking your Dist::Zilla config

Dist::Zilla is a great tool... but its main weakness is nearly its main advantage...
In My Opinion, Dist::Zilla Plugins are what makes my dzil workflow so great....
but on the other side, installing all the plugins and their dependencies is painful and can be very slow...

It's acceptable to install all these packages that are going to let you save time while developing and releasing your distro.... but contributors and Travis CI should not be slowed down by requiring the installation of these extra packages...

By tweaking the dist.ini of my distro by using a combo of GatherDir + Run::AfterBuild plugins, I could reduced the travis build time for a single Perl version from more than 4 minutes to about 30 seconds...

When smoking with Perl versions from 5.14 to 5.28 the total build time was reduced from 32 min to 5 min.

; extract from dist.ini

exclude_filename = Makefile.PL

; provide a friendly Makefile.PL in our repo
; Travis CI and other contributors does not need
; to install Dist::Zilla::*
run = cp %d/Makefile.PL ./
run = git status --porcelain | grep 'M Makefile.PL' \
&& git commit -m 'Makefile.PL auto-updated by dist.ini' Makefile.PL \
&& echo "# Makefile.PL auto-update" \
|| echo "# Makefile.PL up to date"

This recipe was inspired by Ovid post from 2014 about A Simple dist.ini for Dist::Zilla

It will automatically steal (/copy) the Makefile.PL when running a build and copy it to your codebase, then commit it if needed.

Note that you need to be sure that the file Makefile.PL is not gathered when building a distro.

Ovid also came with one alternate suggestion

run = ( test -f Makefile.PL && rm Makefile.PL ) ||:

which in my case became useless with the GatherDr exclusion.

I guess this could probably be provided as Dist::Zilla plugin so it could be easier to reuse in other distro. Maybe there is already such a plugin available?

Anyway, I thought this would worth sharing as some other authors can take benefits of having their Travis CI builds running faster when using Dist::Zilla :-)

This is a small change to your dist.ini file, that could let you help save a lot of time.


I despise working with any Dist::Zilla setup that modifies the working directory during a normal build. Doing automatic commits is even worse.

If have files you want to regenerate easily, I think the [Regenerate] and [Regenerate::AfterRelease] plugins are much more sane.

Agreed with Graham, and I have made great use of CopyFilesFromRelease + Regenerate::AfterReleasers to have files regenerated at release time (for consistency's sake, and these get automatically committed in the release commit) as well as when I run dzil regenerate (which I can then commit at my leisure). This is now also behavior the @Starter bundle can automatically enable with the regenerate option. Additionally, make sure to copy your META.json as well so that cpanm has a complete picture of what is needed (esp. any configure dependencies).

Leave a comment

About atoomic

user-pic I blog about Perl.