Skip to content

Lab 3 (Wed): Travis CI

Raymie Stata edited this page Jan 10, 2018 · 6 revisions

Lab instructions

In this lab we will configure TravisCI and watch it do builds and deploys.

  1. Configure Travis as described in this document.

  2. In your git fork of Limbo, make a branch off of master called lab3. Push this branch to GitHub and check that TravisCI can successfully build and test it. As this build illustrates, our Travis configuration will ordinarily only build and test Limbo, it will not deploy it. However, when Travis detects a change to a branch whose name ends with master, then it will build, test, and deploy that branch. Let's see that in action:

  3. Make another Git branch off of master called lab3-master. Checkout that branch. Type make ecs_start to ensure that your chatbot is running in ECS. Then push lab3-master to GitHub and check that TravisCI has successfully built, tested, and deployed it.

To determine if a build successfully deployed your bot, go to about the 6th line from the bottom of the build's log, and look for a line that reads ECS Service has reached a stable state. See, for example, this build), which did succeed in its deployment. If, instead, you see the message Service not running, so not pushing an update, this means the service wasn't already running when Travis tried to do a push (our Travis deployment script will not start a Limbo chatbot in ECS, it will only update one if it's already running). To get your bot running, you need to manually type make ecs_start from your laptop.

To reduce clutter, you'll want to delete these branches from both your local and GitHub repositories after you've been successful.

Now that you have a continuous integration and deployment system in place, you can continue working on your Hackday project with even more ease.

Supplemental Git instructions

If you are not very familiar with Git, the following instructions may help you get through the above steps more easily.

Get to clean master

The lab assumes you're starting on a master branch that hasn't been modified. (If you know what you doing with Git, you don't need to follow this assumption.)

To determine your current branch and it's state, make sure you are inside the directory containing your local clone of your fork of Limbo, and type git status. You should see something like the following:

Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$ 

Note that it says I'm on branch master which is up to date with origin. If you're not on master and/or you are not up to date, then let an instructor know.

Make the lab3 branch and push it to GitHub

Once you're in a clean master branch, use Git's checkout command to both create the lab3 branch and switch to it:

Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$ git checkout -b lab3
Switched to a new branch 'lab3'
Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$ 

To trigger TravisCI to build and test (but not deploy) this branch, use Git's push command:

Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$ git push origin lab3
Total 0 (delta 0), reused 0 (delta 0)
To github-rstata-verticloud:rstata-verticloud/limbo.git
 * [new branch]      lab3 -> lab3
Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$

If Travis is configured correctly, then this will trigger a build for the lab3 branch.

Make the lab3-master branch and push it to GitHub

As a shortcut, we're going to branch lab3-master from lab3, rather than directly from master. Again, this is done with Git's checkout command:

Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$ git checkout -b lab3-master
Switched to a new branch 'lab3-master'
Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$ 

Since the name of this branch ends with master, when you push it to GitHub, TravisCI will deploy it (as long as it builds and tests successfully). Recall that TravisCI will only update a running Limbo instance, it will not start one. So be sure to use make ecs_start to get your 'bot started on AWS if it isn't already.

To trigger TravisCI to build, test, and deploy from lab3-master, again use Git's push command:

Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$ git push origin lab3-master
Total 0 (delta 0), reused 0 (delta 0)
To github-rstata-verticloud:rstata-verticloud/limbo.git
 * [new branch]      lab3-master -> lab3-master
Admins-MacBook-Pro-4:rstata-verticloud-limbo raymie$

If Travis is configured correctly, then this will trigger it will build, test, and ultimately deploy lab3-master to ECS.