Adding Travis to SWI-Prolog packs
Travis CI is a continuous integration service that is freely available for Open Source projects. I recently got a pull request to add Travis support to one of my libraries on GitHub. While I had thought about adding Travis support+badge before, I never got to do it. It comes out that this is pretty easy, even for custom runtimes (SWI-Prolog is not in the list of officially supported/documented runtimes).
Travis supports custom APT repositories and packages. There are two infrastructures: container-based and non-container-based (legacy). In order to install a package in the container-based infrastructure, it must be white-listed. If a package requires a custom (PPA) repository, it must be whitelisted too. I have opened an issue to whitelist the SWI-Prolog development version PPA. As it has not been added yet, only the legacy infrastructure can be used for now.
Example: simple-template project
Here is my commit to add Travis support for the simple-template pack. After adding the configuration, I also had to enable builds in my Travis account. You get your Travis account by logging in using the GitHub authentication. You also get a nice badge image link to add to the project's README.
The contents of
before_script: - sudo apt-add-repository ppa:swi-prolog/devel -y - sudo apt-get update -q - sudo apt-get install swi-prolog-nox script: make test
README.md update for badge (change username and project name!):
make test command in the pack root must work. I use Make as my build tool and have the test target implemented. Implementing the
target (or just calling swipl directly in the
script option) is easy:
swipl -s tests/tests.pl -g run_tests,halt -t 'halt(1)'
Here it assumes that tests are loaded from
tests/tests.pl file and run with plunit (
-g switch). When
halt(1) is executed that shuts down the SWI process with the exit code 1.
when tests fail, although it has not been
I have added Travis support to all of my packs and considering adding it to some others as well.