After a lot of hard work we finally got a Jenkins CI pulling code from out GitHub repositories and are now doing Continuous Integration as well as Deployment.
We get the code and only deploy it if all the tests pass, as usual.
Now I have checked that there are a number of plugins for Java that besides running the tests, also do test coverage, like Cobertura.
But we don’t use Java. We use Elixir.
In the Elixir world, we have excoveralls, which is a facade for the coveralls API. The coveralls API supports jenkins so it stands to reason I would find a Coveralls Plugin for Jenkins.
I was wrong. There is nothing.
So now I have a test coverage metric that is basically useless because I can’t integrate it with Jenkins.
Are there any Erlang/Elixir plugins one can use with Jenkins for code coverage?
I also created a Issue in the projects ( which seems to be abandoned … ) https://github.com/parroty/excoveralls/issues/167
Try using a JUnit Formatter Elixir package together with the
junit pipeline step in your Jenkinsfile.
covertool exports coverage data in Cobertura format that is supported by Jenkins.
I have tested both suggestions.
@shanesveller This solution works and is quite nice. It forces me to change the
test_helper.exs but that is a minor inconvenience overall. It is nice but it only offers the most basic of reports and for me this is where it fails.
@hauleth The option I decided to go with. Yes, making the
Jenkinsfile work for Cobertura was a nightmare, specially because in previous versions it was not even possible and because there contradictory information scattered all over the place.
However, once you get that
Jenkinsfile going, you get to rip those sweet reports from Cobertura. Cobertura was made with Java in mind, there is no two ways about it. In the reports you see things like Class coverage and such, but you can easily translate that do modules. The interface offers a lot more information and tracks coverage over time, which is something I actually want.
For future notice, here is my
SOME_VAR = "/home/deployer"
sh "MIX_ENV=test mix do deps.get, deps.compile"
sh "mix test --cover"
sh "mix credo --strict"
env.BRANCH_NAME == "master"
echo "Deploy with AWS or GCP or whatever"
cobertura coberturaReportFile: "coverage.xml"
- I am extremely Nazi with my code, so I also use Credo. You can further configure it as to not blow the entire pipeline because you missed a new line at the end of file but as I said, I am quite Nazi with my code.
- The Deploy stage only runs if the pushed branch is Master. There are other ways of doing this, but I found it that having this way for a small project was good enough.
Overall I like covertools for now but I don’t know if the first solution has the same potential. At least I didn’t see it.
Hope this post helps!