2

I'm familiar with CI, but this is the first time I deal with Travis CI (and docker). I have a github project and I'd like to run the .travis.yml locally. Let's take this project as an example.

Looking at this question and this article, I see that executing locally is possible with docker, but it's dependent on the programming language. I installed docker, but I'm having trouble picking the docker image, because there's no "C++ image" or a "Trusty image" or anything that I see close to the project at hand.

What image should I choose? Am I looking at this from the wrong angle, since C++ is somewhat a system component, unlike those images with scripting languages (Python, Ruby, etc.)? Please advise.

The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
  • Have you looked into using a remote shell? Basically let travis run a program that connects to your server which you also connect to so it forwards commands you type to the travis shell. You get kicked out after an hour losing all your progress, but that might be enough, and you can restart it. Might be against the rules though, not sure. – nwp Jan 31 '18 at 13:56
  • @nwp That's a little scary from a security point of view. If I understand this correctly, you want the travis script to get access to my server through ssh? – The Quantum Physicist Jan 31 '18 at 14:03
  • No. I want you to get access to travis through a program with forwarding help from your server. There will only be commands sent by you to the server to travis. There doesn't even need to be a reply because you see the output on the travis website. Technically you can use that to do bad things inside the travis VM, but then again anyone can do that already, so no loss in security. – nwp Jan 31 '18 at 14:07
  • @nwp I see. I'll consider that next time (my current campaign on this is over). Thanks for the suggestion. :-) – The Quantum Physicist Jan 31 '18 at 14:09

3 Answers3

3

I'm the asker of the question, and here are things I learned from this journey.

Don't waste your time trying to get travis CI to work locally. You'd be super-lucky to have travis-build (which is the library that converts travis scripts to bash) work with no problems for you. But it doesn't have to. For me I got ruby library errors out of the blue and couldn't debug it (maybe this is my ruby ignorance, but this depends on how much you want to invest debugging travis-build, if you can, because my error seemed to be not something I can fix).

The bottom line is: Just live with creating a new branch on github and push your work to it to test your changes, and then delete that branch.

A way I used to encapsulate the testing process and be able to test it locally, is that I don't use only travis to do the tests, but I use another set of Python scripts (or your preferred scripting language) inside the travis script. This way, you can use these scripts to test the complicated logic manually, and then you do something like this in the travis script:

install:
    - python tests/install_ubuntu_packages.py
script:
    - python tests/test_daemon_compile.py
    - python tests/test_gui_compile.py

These scripts you can run individually in docker, super-cleanly, in a new environment, and they can contain complicated logic that needs to be tested locally. But the travis script itself is so simple that it's not worth testing locally.

The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
2

How to use Trusty images is explained in https://docs.travis-ci.com/user/common-build-problems/#Troubleshooting-Locally-in-a-Docker-Image.

banzaiman
  • 2,631
  • 18
  • 27
1

When choosing an image, I looked through https://quay.io/travisci and found that te-main is regularly built on (as of 2018/01/23). I'd pick te-main, since that's probably the closest for c/c++. Running a lsb_release -a on that image, I get

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:    14.04
Codename:   trusty

confirming that the image is based off of trusty

StephenG
  • 2,851
  • 1
  • 16
  • 36