I was recently tasked with making Continuous Integration a regular citizen in our daily workflow. Read more...
You can find infinite writings on the web in regards to Continuous Integration; this one is specifically aimed at helping you get setup on Engine Yard Cloud using CI Joe.
Our application is hosted on Engine Yard Cloud, I believe they spoil us by making certain tools available (namely Chef recipes) when deploying an application. After reading this how-to, expect a smooth deploy process, while skipping the need to shell into a server and edit files manually!
If you are not sure what Continuous Integration is, or why it is important to have in-place, Wikipedia's Continuous Integration entry is worth a read.
Some of the code and ideas outlined were influenced by Chris Parsons Article on Running Multiple CI Joe instances with Rack and Passenger. I highly recommend you read through it as well.
The first step was evaluating the available options: CI Joe, Integrity, Hudson, & Cruise Control. The pros/cons of each option is beyond the scope of this post. We decided on CI Joe as our Continuous Integration solution as it is extremely easy to setup, and has a very understandable codebase.
Step 1: Fork It!
Fork the following Github repository "ci_server", and update the settings specific to your application. Review the README, as it explains the files you will need to configure to your needs. Sorry, no global settings file yet.
Step 2: Engine Yard Application Setup
Two important notes:
- Select RACK as the Application Type
- Under “EDIT ENVIRONMENT” select “CLI Deploy” process, this changes the default behavior of the deploy and rebuild processes. You normally select this after the application has been added to an instance.
Step 3: Custom Chef Recipe
Engine Yard Cloud gives you the ability to hook into the extensive Chef library, which gives you limitless possibilities when deploying an application. This is an essential part of a smooth deployment process.
Now that you have a basic understanding of Chef Recipes; create your own custom recipe named “ci_setup”:
This chef recipe is run when you rebuild your instance, and it will generate a test database connection, and checkout the repository you need to test against.
I’ve included an example Chef Recipe in the “ci_server” repo you forked above. Move this recipe into your own repository and push it to Github.
When you’ve finished editing the Chef recipe, you’ll need to upload the recipes to your server. Again, Engine Yard has documentation on this as well. If you have the Engine Yard gem installed simply run this command:
Step 4: Github POST-RECEIVE Hook
The last step of this guide is to configure Github to send a Post-Receive hook to our Continuous Integration build. On Github, click the “ADMIN” tab within your repository. Select “Service Hooks” from the options on the left side of the page. Select “Post-Receive URLs”, and complete the form with the URL of your CI server (which you set when adding the application in the Engine Yard dashboard).
Now, anytime a new commit comes into the Github repository, a POST will be sent to your CI server and the tests will be run.
This was our first implementation of Continuous Integration, if you have any suggestions on how this could be improved, tweet me @releod