Exercise 12

info

This is an in-class exercise. An exercise page like this one will contain a brief description but is intended to be supplemented by discussion during our meeting time. Complete the exercise to the best of your ability in the time given. Feel free to talk with other students as you work, and do not be afraid to ask questions. Aim to complete as much as possible during our meeting and continue to work at home to finish, but you need not hand it in.

Learning Objectives#

Objectives

This exercise should help you practice with:

  • Continuous integration/delivery
  • Github Actions and Docker technologies
  • CI automated unit tests and branch coverage

Answer the following questions#

  1. What is the difference between CI & CD?
  2. What is a CI/CD pipeline?
  3. In a CI/CD pipeline: what is a workflow? What is a job?
  4. What problem does the Docker technology solve?

Task#

  1. Go over the "Continuous Integration" section of the Readings tab on the course website and make sure you finish all subsections and parts to replicate the fully functioning CI/CD pipline on the simple program containing Main, ArrayUtils, and ArrayUtilsTest classes using Github Actions ad Docker; once you finish all parts, you should have your own ci-helloworld Github repo and when a push/pull request update is made to the master branch, an updated docker container image must get published to docker hub (under your own docker account.)

  2. Add the following method to your ArrayUtils class under the src, but do not add any tests for it to your ArrayUtilsTest test class.

public static int countOf(int[] x, int target) {
int count = 0;
for (int a: x) {
count = a == target ? count + 1 : count;
}
return count;
}

This should bring the overall BC coverage on ArrayUtils class under the current set threshold in the pipleline (i.e., gradle.yml). Now, commit and push the changes to the master branch and imediately go to Actions tab of your repo on Github to observe how the pipleline workflow fails once it reaches the Jacoco job. What is the mentioned failure reason for the failed pipeline?

  1. Add tests to ArrayUtilsTest to acheive 100% BC on ArrayUtils (and the new countOf function in particular), leaving in the existing tests! Commit, push, and confirm that all the steps in the pipleline run successfully and a new image is published to docker hub.
  1. Find the specs of jacoco-badge-generator Action on Github Actions "Marketplace". Modify your pipleline (i.e., gradle.yml) such that the workflow would fail "if branche coverage is less than it was on the previous run."

  2. Verify that the docker image of the containerized ci-helloworld app is deployed successfully on docker hub!

tip

On Docker Hub, you can make your containerized application public/private to share/hide it with/from the outside world by going to the "Settings" tab of the DockerHub repository and make adjustments under "Visibility settings".