GitLab.com offers free git repositories and similarly to GitHub, free CI which comes by default in your repository. GitLabCI can automatically generate badges for your project like build status and test coverage.
To start using GitLabCI without a hassle, GitLab repository manager offers
.gitlabci.yml templates for your projects. For a Golang project, edit the default template, find the line that starts with
go test -race and append
-coverprofile .testCoverage.txt, so it looks like the one below:
- go test -race $(go list ./... | grep -v /vendor/) -v -coverprofile .testCoverage.txt
Go to Settings -> CI / CD, expand section
General pipelines settings and add this regular expression
Test coverage parsing
Next time you run your pipelines, test stage will contain something like:
coverage: 83.9% of statements
It will generate badges with build status and test coverage:
This topic presents who to setup kcov with cargo to get a test coverage for a cargo project, so I just assume you got kcov working in your Linux distribution and you have a project with source code and tests that you can run. I also assume you have gitlab-ci-multi-runner installed. So I will just quickly present who to configure it to use with GitLab CI to get test coverage badge in your new project.
I use my own CI runner, I’m not using shared runners or docker for it. So it’s pretty straightforward, your configuration will differ a bit.
In my spare time I develop applications on Android. I also “maintain” F-Droid repository for some of my public projects. I wanted to automatically publish each build after:
- Compilation passed
- Test on a connected device passed
- Signed build completed
So I made a simple setup with help of GitLabCI and own F-Droid repository. This post does not describe how to configure F-Droid repository or configuration of GItLabCI-runner, because official documentation is much better than I could write it. This post just describes how I use both services to automate boring deployment.
GtiLabCI is run on your own hardware, so it can have access to your files, configuration etc. It’s an advantage over Travis, as you can run any custom command, like testing on connected device or on pre-configured emulator, connected to remote hosts where CI slave is on a trusted machine.
GitLab.com is a competitor of Github. It’s a service provider for git-based source code repositories that offers much more than it’s bigger brother. In this post I will try to convince you to try it out for your next project.
GitLab is not only a simple git hosting; its features impact the whole development process, the way of contributing to a project, executing and running tests, protecting source code from changes, more and more.