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::
- When the static code analysis tools were introduced a few days ago, my project was not buildable anymore. Travis informed me that the build failed now (central build log).
- When all (official) bindings were bumped to version 2.1-SNAPSHOT, the build was also failing (central build log) as I also had to increase the version to 2.1-SNAPSHOT in my pom.xml
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 before_install: - wget https://github.com/openhab/openhab2-addons/archive/master.tar.gz - 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 before_install: - cd addons/binding/org.openhab.binding.YOURBINDINGNAME
- Register / log-in to Travis CI
- Go to the profile page and enable the repository of your binding.
- Enable a weekly cronjob to test that your binding remains compliant to the ESH API and the OpenHab build process.
- (optional) Add a Travis icon to your README.md
- Now Travis will inform you via e-mail about broken builds and also appears within the GitHub interface and shows the build status.
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.