GitLab Continuous Integration

Last update: 10 Nov 2020 [History] [Edit]

Continuous Integration (CI) is the concept of literal continuous integration of code changes. That is, every time a contributor (student, colleague, random bystander) provides new changes to your codebase, those changes are tested to make sure they don’t “break” anything.

Continuous Deployment (CD), similarly, is the literal continuous deployment of code changes. That means that, assuming the CI passes, you’d like to automatically deploy those changes.

GitLab CI/CD is configured by a file called .gitlab-ci.yml inside the base of your repository. This file is written in yaml, which stands for Yet Another Markup Language. The language is very similar to xml and JSON and is often used for configuration files. The language is relatively simple and is designed to be human-readable.

An example .gitlab-ci.yml is defined below

image: rikorose/gcc-cmake

before_script:
  - mkdir build

build_code:
  script:
    - cd build
    - cmake ../src
    - cmake --build .

The .gitlab-ci.yml file creates a pipeline which can consist of multiple jobs to be executed by Runners when you commit your code to GitLab. The jobs can be configured to do many things such as: run tests, format code, produce plots and even run your whole analysis if needed. Essentially the gitlab-ci.yml is a collection of commands you want to run with your repository.

The GitLab Runner responsible for executing your jobs are able to interpret bash and Windows Powershell, so mkdir and cd here would have the same effect as if you were to do them on your local machine.

GitLab CI can use a Docker engine to test and build any application, so in your .gitlab-ci.yml you can define a docker image, the GitLab CI will then run your job from within a separate and isolated container. Docker Hub has a large range of pre-built images, including AnalysisBase and AthAnalysis.

The before_script keyword here is executed before the script for your job build_code and then the runner will execute the script you have defined for that job. Simple.

Please read up on GitLab CI/CD and yaml to see some examples of what is possible.

This will definitely make your analysis work easier! There is also a push for reproducing analyses and analysis preservation within your research, CI/CD makes this very easy.

We will try work through some very simple examples and how you might begin to incorporate this into your work.