Fl4m3Ph03n1x

Fl4m3Ph03n1x

Background

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.

Questions

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 … ) Is there any jenkins plugin compatible with this? · Issue #167 · parroty/excoveralls · GitHub

Showing Posts 1 to 3

shanesveller

shanesveller

Try using a JUnit Formatter Elixir package together with the junit pipeline step in your Jenkinsfile.

hauleth

hauleth

covertool exports coverage data in Cobertura format that is supported by Jenkins.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

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 Jenkinsfile:

pipeline {
  agent any

  environment { 
    SOME_VAR = "/home/deployer"
  }

  stages {
    stage("Build") {
      steps {
        sh "MIX_ENV=test mix do deps.get, deps.compile"
      }
    }

    stage("Test") {
      steps {
        sh "mix test --cover"
      }
    }

    stage("Credo"){
      steps{
        sh "mix credo --strict"
      }
    }

    stage("Deploy"){
      when{
        expression{
          env.BRANCH_NAME == "master"
        }
      }
      steps{
        sh '''
         echo "Deploy with AWS or GCP or whatever"                                                         
        '''
      }
    }

  }

  post{
    always{
      cobertura coberturaReportFile: "coverage.xml"
    }
  }
}

Of notice:

  1. 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.
  2. 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!

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews