Search code examples
perldockertravis-citravis-ci-cli

Local testing of Perl repository using Travis CI (with docker)


I'd like to fix a bug in a Perl repository (now owned by me, I just submitted some pull requests), but at the moment it's failing its Travis CI tests (before my pull requests).

My goal is to be able to run Travis CI tests locally starting from the repository's .travis.yml.

Note that I'm totally new to Travis CI.

Following other's solutions that pointed to this FAQ (http://web.archive.org/web/20180929150027/https://docs.travis-ci.com/user/common-build-problems/#troubleshooting-locally-in-a-docker-image), that as you can see is no longer officially available in travis-ci.com, I tried:

sudo  docker pull travisci/ci-amethyst:packer-1512508255-986baf0
sudo docker run --name travis-debug -dit travisci/ci-amethyst:packer-1512508255-986baf0 /sbin/init
sudo docker exec -it travis-debug bash -l

From the container:

su - travis
git clone https://github.com/{user}/{repo}.git

Now I don't know how to build the bash script to run the tests, as the last two steps (manually install dependencies / run your Travis CI build) looks cryptic (I don't know how to run the build, and possibly lead to lack of reproducibily (if I install dependencies manually, how do I know I'll get the same results as the cloud test?)

I tried starting from the procedure described here (https://github.com/travis-ci/travis-build ), one error is ´Could not locate Gemfile or .bundle/ directory´, but I probably need some missing steps.


Solution

  • For what its worth, I think you are going at it from the wrong angle.

    Travis is just running your stuff remotely. Instead of bringing Travis to your machine, you need to make your tests pass locally first - cryptic or not - there is no way around it, especially if you are going to own this repo.

    Another reason I am recommending this, is that - as you have already witnessed - the develop-debug-fix cycle is much lengthier when you rely on something to test your code remotely.

    It has been my experience that your .travis.yml should be super simple, since it just runs one or two scripts or commands that can comfortably run locally.

    If you are comfortable with Docker, I would consider building a local Dockerfile with all the dependencies, and bring your tests to work in your docker environment. Once you succeeded with this step, asking Travis to do the same (run tests in a docker) is trivial.

    Not sure if it is the answer you were looking for, but it was too long for a comment.