💾 Archived View for separateconcerns.com › 2015-03-08-travis-lua.gmi captured on 2024-05-12 at 15:22:26. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-09-28)

-=-=-=-=-=-=-

Continuous Integration for Lua with Travis

published 2015-03-08,updated 2015-10-16

Travis [1] is a Continuous Integration service which is free for Open Source projects and has very good GitHub integration. We will see how to use it for your Lua projects.

Your test suite will work well with Travis as long as executing it returns 0 on success and nonzero on failure. If you use plain Lua assertions, it is already the case. If you use a test framework, make sure that it works that way. I have added a helper [2] to cwtest for that purpose.

Travis does not support Lua out of the box, but using it with Lua projects is not hard because moteus [3] has done all the hard work for you. You just have to clone this repository [4] and copy the `.travis` directory to yours.

After that, you only have to write a single YAML file, `.travis.yml`. For example, here is the one I wrote for Haricot [5].

Most sections should be self-explanatory. `install` is where you set up your dependencies. The first line calls moteus' script which lets you use Lua and LuaRocks. A separate build and test run will occur for every Lua version declared in `matrix`; you can comment some lines there if you do not want to test some Lua versions. For Haricot I need Beanstalk [6] running in the background so I start it in `before_script`. `script` is where you run your actual tests.

To enable Travis, sign up, allow Travis to access your GitHub account, then go to your profile [7] and flip the switch for your repository:

travis

After that, commit `.travis` and `.travis.yml` and push to GitHub. It will trigger a test build, and so will every subsequent commit. If you want, you can now add a badge [8] with the status of your build to your README or your project's home page.

1: https://travis-ci.org

2: https://github.com/catwell/cwtest#exit

3: https://github.com/moteus

4: https://github.com/moteus/lua-travis-example

5: https://github.com/catwell/haricot/blob/2d5320633c76f14f12c0d8486606de4b9d95c015/.travis.yml

6: http://kr.github.io/beanstalkd/

7: https://travis-ci.org/profile

8: https://travis-ci.org/catwell/haricot.png?branch=master