CI Practice

Overview

For this activity, we are going to use the gitlab environment to set up a CI (Continuous Integration) test environment.

Setup
  1. Download and create a file named exactly .gitlab-ci.yml at the top level of your directory. Note that you will have to rename the downloaded file to add a . at as the first character of the name!

  2. Below, we show the content in the file

    image:
      name: kalrabb/docker-swen-250-identifier-convention-chkr-img:latest
    
    variables:
      PROJECT_FOLDER: Filter #Change this to your current folder/ project
      BUILD_CMD: make #If you don't have a Makefile, put the build command here
      RUN_CMD: valgrind --leak-check=full ./test #Assume the executable file is called 'test'  
    before_script:
      - cat /etc/lsb-release
      - which gcc
      - which g++
      - which valgrind
      - which make
      - cd $PROJECT_FOLDER
      - pwd
      - ulimit -n 1048576
      - ulimit -a
    
    testrunner:
      script:
        - $BUILD_CMD  #Runs make, or custom command
        - $RUN_CMD  #Runs the executable against valgrind
        - echo "**Done**"
      stage: test
                
    • This sequence of commands will:
    • Build your code on the gitlab server
    • Run your code (using valgrind, which is a widely used memory check tool
  3. Review the .yml file, and check the names for the $PROJECT_FOLDER, $BUILD_CMD and $RUN_CMD. The sample is set up for the assignment Filter. For other assignments, you would need to change those variables to match the correct values.

    Save the file, and run git status. You should see the new .gitlab-ci.yml file

    Go ahead and add, commit, push the file.

  4. Go to gitlab, and find the CI/ CD menu (in the left side menu-bar)

    You should see a button saying (hopefully) running or completed. Click on the button and look at the output