| Quaintous | Published: |
(tags)
|
(category)
|
|
| Updated: | ||||
| Test and Code Coverage with GitLab Docker Runners | ||||
IntroductionGitLab allows building complex pipelines for building, testing, packaging, etc. projects using Runners:
There are two types of Runners at the moment: shared and specific. Shared runners are provided by GitLab and can be used by everyone. Shared Runners, in contrast, are private Runners running on own infrastructure. Runners can also be utilized in various ways (shell, docker, etc.). This article is limited to shared Docker Runners. How is it done?The procedure of registering and enabling Runners for a project is fairly easy:
In the following steps JavaDocker imageThe docker image that I use for my projects uses Maven for building/testing and JaCoCo for code coverage reporting: This image must be either on Docker hub or any other registry accessible by GitLab. For the sake of simplicity, let’s say that the image is available in Docker registry as Wait a minute…: I will explain later why CI ScriptWhen using a Docker Runner, the CI script is as easy as it gets. You need to tell GitLab which image is to be pulled for build/test/coverage procedure and provide which scripts should be run after the repository is fetched:
You have to set it in your Node.jsDocker imageThe Docker image For my Node.js projects contains Mocha for testing, Istanbul for code coverage, and standard JS for code style: Lets say that this image is also available in a public registry as CI ScriptSimilar to the CI script, the steps are the same, except that the Runner is instructed to install all dependencies before running the test: The regular expression for GitLab to parse the coverage percent (for statements) is: One last wordI didn’t want to write this article: everytime that I figour out something, it appears to me that the solution have always been easy and even trivial. However, I saw this article and thought there might be more people like me struggling to get started with GitLab Runners. |
||||
| License: | ![]() |
🟢 No JavaScript | (Notes) | |
| 🟢 No Tracking | ||||
