Good practice: Setting up a CI process for bindings outside the official OpenHab repository

Hi all,

I would like to present an (in my opinion) good practice for all binding developers out there who are developing bindings outside the official OpenHab repository: Setting up a continuous integration process with Travis CI. Travis is completely free for open source projects just as GitHub and will check after each commit if your project is still buildable and ensures that there are no (syntactical) errors in it. Also, it can notify you about breaking changes within Eclipse or the OpenHab build and dependency mechanisms that may need some action by you. Last but not least it’ll check PRs if they do not introduce (syntactical) errors or cause unit tests to fail.

I did setup a mechanism for my binding (openhab2-flicbutton) which is working quite well for a while now and helped me to ensure that my binding remains up-to-date and API-compliant. Just two examples how Travis CI helped by informing me about necessary actions on my binding source code::

This is how it works:

  • Add a travis.yml file to the root directory of your binding. This is how my travis.yml is looking which contains a very simple build process: Load the latest master from openhab2-addons -> locally add your binding to it -> run mvn test:
language: java
jdk: oraclejdk8
  - wget
  - tar xzfv master.tar.gz
  - mkdir openhab2-addons-master/addons/binding/org.openhab.binding.YOURBINDINGNAME
  - shopt -s extglob dotglob 
  - mv !(openhab2-addons-master) openhab2-addons-master/addons/binding/org.openhab.binding.YOURBINDINGNAME
  - cd openhab2-addons-master/addons/binding/org.openhab.binding.YOURBINDINGNAME

This example is working for those who develop their binding in a seperate repository (which I prefer because GitHub offers more features for this). For those who just use a fork of the openhab2-addons repository, the file can be even shorter:

language: java
jdk: oraclejdk8
  - cd addons/binding/org.openhab.binding.YOURBINDINGNAME

I hope I could help some people by showing my approach and would be happy to discuss the topic with you. Maybe some of you guys also implemented another approach or have improvement suggestions for my one? I’d happy to see them.

Maybe, it’s also possible to extend this approach later on to Continous Delivery by also centralizing / automating the release process to the IoT Marketplace.