alfert / coverex

Coverage Reports for Elixir
Other
101 stars 26 forks source link

Added totals in output #36

Closed henb closed 7 years ago

henb commented 7 years ago

MOTIVATION

I want to see the report badge in my gitlab repository.

Reason

“If you use test coverage in your code, GitLab can capture its output in the build log using a regular expression. In the pipelines settings, search for the "Test coverage parsing" section.” https://gitlab.com/help/user/project/pipelines/settings#test-coverage-parsing

But coverex does not contain the totals.

Description

Calculating coverage values.

Tested

Environment:

Result

In my terminal:

Generating cover results ...
Coverage Report
---------------
Ratio  Covered  Uncovered  Module
 68.8%      53         24  Elixir.Coverex.Source
  5.8%       6         97  Elixir.Coverex.Task

--------------
Total
 37.3%      59        121

In my gitlab repository:

badge

Changes

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-1.6%) to 35.443% when pulling 109e3292c9d23f9eadcbfbe5f19eabe6720de0f1 on henb:feature/add-totals-in-output into c91a569d0586bbf23d7b439ae609142e156e3c53 on alfert:master.

alfert commented 7 years ago

Cool, this makes totally sense. And, btw, a nice feature of GitLab.

alfert commented 7 years ago

Release 1.4.12 is on hex.pm

razzeee commented 6 years ago

Did you ever get this to work? Gitlab doesn't seem to do multi-line regex. So matching for the correct output doesn't work.

https://gitlab.com/gitlab-org/gitlab-ee/issues/4744

Can we change the total label to be in the same line?

henb commented 6 years ago

@Razzeee

Did you ever get this to work?

Yes.

Gitlab doesn't seem to do multi-line regex.

You can replace the regular expression.

So matching for the correct output doesn't work.

I think you can create a PR and it will be successfully adopted.


At the time of writing the PR, gitlab did not have a default template. Right now, gitlab recommends the following:

Below are examples of regex for existing tools:

  • Simplecov (Ruby) - (\d+.\d+\%) covered
  • pytest-cov (Python) - \d+\%\s*$
  • phpunit --coverage-text --colors=never (PHP) - ^\sLines:\s\d+.\d+\%
  • gcovr (C/C++) - ^TOTAL.*\s+(\d+\%)$
  • tap --coverage-report=text-summary (NodeJS) - ^Statements\s:\s([^%]+)
  • excoveralls (Elixir) - [TOTAL]\s+(\d+.\d+)%
  • JaCoCo (Java/Kotlin) Total.*?([0-9]{1,3})%
  • go test -cover (Go) coverage: \d+.\d+% of statements

If you do not want to change the regex, just use excoveralls.

razzeee commented 6 years ago

Which regex are you using?

I'm pretty confident, that you can't match for this, as you can only match for single lines. And to get a unique match, you would need to match at least two lines. Changing the regex does nothing, as you can't change that matching rule from there.

I'm, aware of the default templates, thank you :)

I can't remember why I eneded up using coverex over excoveralls, I guess I thought the other is focused on coveralls.