When it comes to development - in general - we want to write fast and effective code and deploy without any defects. Testing the code we write manually and then having to save the
sha, and then merge the commits, and then hit the deploy button using the
sha again; this makes the process to production - long and defective - slow. Using some sort of development pipeline logic can make this process quick and effective communicating with providers creating continuous integration (CI).
Let's say that you're building a company and your engineering team is expanding - and you now feel it is time to automate the process of testing and deploying with constraints built in to trigger deployment. This will make the deployment process less likely to have a bad deploy, creating less defects and faster development. This article will go step-by-step and guide you on how to easily set up your Ruby on Rails project with CodeShip Basic.
Let's start with the essentials
Heroku account - You can create an account here.
CodeShip account - You can create an account here.
Github project - You can create an account here.
Setting up CodeShip in your project
What does everything mean?
Containers. I think it's safe to say that containers can be confusing topic to discuss at first. Although the reality is that it makes it easier for engineers to know that their software will run wherever deployed. Containers can run all kinds of applications and can be managed on Amazon AWS, Heroku, Docker, Kubernetes, etc.
Testing. CodeShip supports all Ruby-based test frameworks. The main ones being RSpec, Cucumber and Minitest; in this test project I will be using RSpec to setup my CI with my development pipeline. There are a few types of testing that are out there but the main two that I feel that are important are: behavioral-driven development and test-driven development, which lay out the best practices to writing great tests.
Once you have your testing framework setup, you can begin to separate your tests into groups and call a group into a certain pipeline.
Pipelines. Pipelining is a group of apps that share the same codebase. Each app represents stages like Development, Staging, Production to be a part of the continuous delivery workflow so that an environment can easily be promoted.
VCPU. This is what we call a virtual central processing unit and normally a few vCPUs are assigned to every virtual machine within a cloud environment and represents a portion of a physical CPU.
Next, you may want to fork my project.
To setup CodeShip Basic, it is quite easy as all we need to do after signup is connect our GitHub project, install CodeShip to our Github and conclude with pushing a commit to the repository to trigger our first build.
Click here to install CodeShip and select the repository you want CodeShip to communicate (trigger) with.
Then connect your repository that you're adding and push a commit to the repository. And you will see the project build in a container.
Setup and Test Pipeline commands
Test Pipeline Commands
bundle exec rspec spec
To set up Heroku, we will need to setup a
.pub key to communicate with CodeShip. Then we will need to configure our deployment information with CodeShip by giving our Heroku API key.
To begin, we will need to build a SSH key locally. To build a
.pub (public key) file we will need to run
ssh-keygen -t rsa in the terminal. Then we will need to add the key to heroku using the Heroku CLI in terminal
heroku keys:add [Public Key Path] which is normally defaulted to this location -
~/.ssh/id_rsa.pub. If you do not have Heroku CLI installed on your machine, you can go to the additional resources section at the bottom to learn how to install it.
Once we have added the key to Heroku, we will need to get out the Heroku API key.
Go to the Heroku Dashboard and [login] (https://dashboard.heroku.com/login).
Then go to Account Settings by clicking on your avatar.
Scroll down to API key and click reveal to copy it.
Now that we have the key, it is time to add it to CodeShip so we can have our deployment working off of our testing suite.
Go to the CodeShip Dashboard to login.
Your screen should look something similar to the above.
Next we will need to navigate over to the deploy tab after clicking on our project's Project Settings.
Click "Add new deployment pipeline" and pick the deployment branch that you want CodeShip to communicate with Heroku. Now we want to click on Heroku and add our key.
Now we have setup the communication for our Ruby on Rails project on GitHub to communicate with CodeShip and for CodeShip to communicate (trigger) builds after each commit. Now if we want to test our project - we can just do -
git add . -
git commit --allow-empty -m 'testing CodeShip' -
git push origin master and then if all the tests pass from the test suite it will deploy in Heroku; otherwise the build will fail.
We have now setup a deployment pipeline that can strengthen your projects for rapid development and faster deploys.
Stay up to date
We'll never share your email address and you can opt out at any time, we promise.