Software Development Methods and Tools—CSCI-3308

Lab 14—Continuous integration

Objective

Exercise

In this lab, we will explore and use continuous integration systems. CI’s exist to automatically build and test our code and simplify the process of testing.

Typically, we’ll integrate a CI system with a Git repository, then write tests and add them to the CI system. These tests will then be automatically run each time we commit and push code to our repository.

Prerequisites

To complete this assignment, you will need a GitHub account. You will also need a copy of the Check C Unit Testing Framework. This will be installed in the VM when you run the make dep target in the Makefile included in the repository for this lab.

Part 1 - Fork the repository and run Make

  1. Fork the lizboese/CU-CSCI3308-CIPractice repository to your GitHub account. This will create a copy of the repository attached to your own GitHub account. Clone your forked repository onto your local machine.
  2. Run Make on the repository code, using the make command to build an executable (on the command line). Are there any build errors?
  3. Run the existing unit tests by executing the ./geometry_test file that Make generates. Do they all pass?
  4. Now, add a phony target called test to the Makefile. This target should depend on geometry_test, and should run ./geometry_test.
  5. Run make clean followed by make test to confirm the tests still build and run correctly with our changes added in via Make.
  6. Commit your changes and push them to your repository fork.

Part 2 - Continuous integration

You will use Travis CI for this lab and integrate it into your repository fork. This is a learning experience—explore the documentation to get started.

Part 3 - Add a new function and unit tests

  1. You will now edit geometry.c and geometry.h to add a new function:

     double coord_2d_area_triangle(const coord_2d_t *a, const
     coord_2d_t *b, const coord_2d_t *c)
    

    This function should take three 2D coordinates and return a double equal to the area of the triangle formed by those coordinates.

  2. After adding your new function, edit geometry_test.c to add at least one new unit test for it.
  3. Build and run the tests locally to confirm everything still works.
  4. Commit your changes and push them to your fork.
  5. Visit your project page at Travis CI. Did your git push trigger a new build? Do all tests pass? If not, fix, commit, and push until the code builds and tests successfully. You are not done until all tests that you have written pass!

Credit

To get credit for this lab exercise, show your CI system’s project page and forked repository to the TA, and sign the lab’s completion log.

Lab material by Liz Boese.