Setting up Gitlab CI for Golang Project
After searching how to set up gitlab CI for my golang project for a while (probably 1.5 day). I wanna take some note here to save your time.
The flow is basically talking to gitlab API.
The step is:
1. Get the output
Either from gitlab runner log or artifact
with Golang, It is the output from command: go test ./...
2. Config the regex for gitlab CI to parse the output from all runner
Setting -> CI/CD -> General Pipelines
Fill regex in section Test coverage parsing
That’s all.
You can do the whole process with .gitlab-ci.yml
without touching gitlab UI page by specifying coverage
in .gitlab-ci.yml
file
You can also change the label of showing the result in
Setting -> General -> Badges
References:
- https://blog.nolanemirot.com/posts/add_codecoverage_golang/
This site links to other 2 great helps.