Skip to content

Experimenting with testing a Perl project on a Travis CI Windows Host

Notifications You must be signed in to change notification settings

theory/winperl-travis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis CI Windows + Strawberry Perl

Build Status

A simple sample project for installing dependencies and running tests with Strawberry Perl on the Travis CI Windows Build Environment. See the .travis.yml file for the working code. The basic steps are:

  • Install Strawberry Perl
  • Add Strawberry Perl to the path
  • Install dependencies with cpanminus
  • Build and test your Perl project as usual

Stages

There are three basic approaches to testing Perl project on Travis Windows:

  1. Windows-Only default "Test" stage with version matrix
  2. Windows stage test with the latest version of Perl
  3. Hack stage to test on multiple versions of Perl

Default Test Stage Matrix

If you only want to test on Windows with Strawberry Perl, and don't care about any other OS, this is the way to go. First, set the OS, language, and matrix of Strawberry Perl versions via Environment variables :

os: windows
language: shell
env:
  - PERL_VERSION: 5.28.1.1
  - PERL_VERSION: 5.26.3.1

Next, use Chocolatey to install a specific version of Strawberry Perl and add it to the path:

before_install:
  - cinst -y strawberryperl --version $PERL_VERSION
  - export "PATH=/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Strawberry/c/bin:$PATH"

And finally, install any dependencies and then build and test your project as usual:

install:
  - cpanm --notest --installdeps .
script:
  - perl Makefile.PL
  - gmake
  - gmake test

Single Windows Stage

If you already use the standard Travis environment for a matrix of Perl versions, and just want to test your project against a single version of Perl on Windows, Add a custom stage, perhaps named "Windows", like so:

jobs:
  include:
    - stage: Windows
      os: windows
      language: shell
      before_install:
        - cinst -y strawberryperl
        - export "PATH=/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Strawberry/c/bin:$PATH"
      install:
        - cpanm --notest --installdeps .
      script:
        - perl Makefile.PL
        - gmake
        - gmake test

Note that the before_install phase installs the latest version of Strawberry Perl, without regard to any environment variables. All the other phases are the same as the default stage.

Windows Matrix Stage

To test on multiple versions of Perl on Windows but still keep the default "Test" stage on Linux, it's possible, although build stages do not (yet?) support matrix expansion. Instead, we have to rely on a workaround where multiple stages with the same name are considered a matrix. To avoid a ton of redundancy, use YAML anchors and aliases in the .travis.yml:

jobs:
  include:

    # First instance of "stage: Strawberry" creates alias and tests 5.28.1.1.
    - &strawberry
      stage: Strawberry
      os: windows
      language: shell
      env: PERL_VERSION=5.28.1.1
      before_install:
        - cinst -y strawberryperl --version $PERL_VERSION
        - export "PATH=/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Strawberry/c/bin:$PATH"
      install:
        - cpanm --notest --installdeps .
      script:
        - perl Makefile.PL
        - gmake
        - gmake test

    # Subsequent instances use the alias to test different versions.
    - <<: *strawberry
      env: PERL_VERSION=5.26.3.1
    - <<: *strawberry
      env: PERL_VERSION=5.26.2.1

Caveats

  • The Travis CI Windows Build Environment is in an early release and subject to change. Be sure to consult the known issues when you run into problems.

  • The shell environment on is Git Bash, not cmd.exe or PowerShell (though Travis is "looking into adding first class Powershell support very soon")

  • The prove utility does not currently work, perhaps because prove.bat is installed but Git Bash requires just prove? That's just a guess (bug report).

  • As of this writing, Strawberry Perl 5.24 doesn't work well with Makefile.PL distributions, including dependencies. Theoretically, one can use dmake instead of gmake, but even then, there seems to be some sort of conflict with the system Perl. See issue #1 for details.

Author

David E. Wheeler

About

Experimenting with testing a Perl project on a Travis CI Windows Host

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages