Lab 14—Continuous integration
Objective
- Pair-program today (required, not optional)!
- Write and update a basic Makefile
- Explore a continuous integration system
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
- 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.
- Run Make on the repository code, using the
make
command to build an executable (on the command line). Are there any build errors? - Run the existing unit tests by executing the
./geometry_test
file that Make generates. Do they all pass? - Now, add a phony target called
test
to the Makefile. This target should depend ongeometry_test
, and should run./geometry_test
. - Run
make clean
followed bymake test
to confirm the tests still build and run correctly with our changes added in via Make. - 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
-
You will now edit
geometry.c
andgeometry.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.
- After adding your new function, edit
geometry_test.c
to add at least one new unit test for it. - Build and run the tests locally to confirm everything still works.
- Commit your changes and push them to your fork.
- 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.