We saw in the previous exciting episode how to automatically test your code on Linux even if you don't have easy access to Linux yourself. Next, we're going to look at doing the same on FreeBSD. This time I used Cirrus-CI, again because they were the first reasonable looking service that I found. Just like with Travis, you'll need to start by signing in using your Github account and granting Cirrus-CI some access. You then need to configure it on Github's website. Scroll to the bottom of that page, select "Public repositories", and then hit "Install it for free". Jump through a few minor hoops, being careful not to commit to paying anything, and finally you can add a config file to your repository.
As with Travis it will notice the new file almost immediately, and start to build. Note that this time you don't have to tell it about each repository individually, it will by default look for its build instructions in any of your repositories.
Cirrus's free service is slower than Travis's, as it takes longer to create the virtual machine which will run your code. Sometimes it even fails to provision the VM in a reasonable time and just aborts, because of resource limits in the free service. When that happens you can easily get it to try again through the web interface.
Wait a little while and - horrors! - the tests have failed.
This gets us to one of the bits of using these third-party CI systems that can be rather annoying. It can be hard to figure out exactly what's going wrong when you don't have interactive access to the machine in question, and the edit/test/review cycle is slow. My immediate suspicion was that my scripts wanted bash but that's a GNUism so might not be installed on FreeBSD. Just having Cirrus install that didn't immediately work, so I had to do a bit of noodling about before tracking down the problem - yes, I did need to install bash, but I also needed to change the
#! at the top of my scripts because it's installed in
/usr/local/bin instead of
/bin. If you want a laugh, you can watch me flailing around trying to debug that. It's worth noting that for each of those commits, if you click on the angry red crosses signifying an overall failure, that every commit is also being tested by Travis, and you only get a pleasing green tick if both builds pass.
In part 3 we'll add support for testing on MacOS
Claim your page on DEV before someone else does
Level up every day