We host MyCollab open source source code on Github. We would love to share the build status of MyCollab in every commit, whether all unit tests are passed or is there any missing library. We do not want to share the status of MyCollab open source product on our build server which contains confidential build status of our premium products, then we seek a free but powerful service which can report to community users the build status and inform to us if the latest build is broken.
We choose Travis (https://travis-ci.org/) as the natural choice while Travis integrates with Github repository very well. Below are what we configure Travis does in every build:
- Run the build with Maven command.
- Compile all projects, with various Java platforms include Java 7, Java 8 and OpenJDK 7.
- Run the unit tests and integration tests against MySQL, which is the back-end database.
- Inform to development team if there is any broken build.
If someone is familiar with automation build process, it will take around 10-15 minutes to set up a build service on Travis. Their document is comprehensive and it is really simple to configure the necessary services for MyCollab build. We use Maven is our build tool, and it runs well independently with environments such as eclipse, hudson or command line. Then MyCollab community also be easily set up by using Travis. First of all, we create the Travis build file .travis.yml in the root folder of MyCollab repository.
Set up Java project
We define language: java in .travis.yml file
Tell Travis to compile and run tests with multiple JDKs
- oraclejdk8 - oraclejdk7 - openjdk7
MyCollab runs on Java 7+, so we need to be sure our source codes are compiled and run well on Oracle JDK7,8 and OpenJDK which is popular in several Unix distributions.
Create the MySQL schema for integration tests against database
MyCollab contains many integration test cases to verify complex SQL scripts run well with MySQL database. We need to create a database schema before to run the test
before_script: - mysql -e 'create database mycollab_test;'
Ask Travis send email to notify developer(s) if the build is failed
notifications: email: - email@example.com
The default notification setting is notify users when there is any change of status. You can configure the value by yourself. We would love to use the default value.
Complete the set up Travis build service
If you read to this paragraph then you can understand how we set up a build service with Travis. The sample build file could be previewed at https://raw.githubusercontent.com/esofthead/mycollab/master/.travis.yml. You can read Travis document for further configuration Travis service meet to your needs. We are welcome any question or contribution to this blog post 🙂