Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added totals in output #36

Merged
merged 1 commit into from
Jan 16, 2017
Merged

Conversation

henb
Copy link
Contributor

@henb henb commented Jan 16, 2017

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:

  • Elixir Version: 1.3.0
  • Erlang Version: Erlang/OTP 19.0
  • Operating System: macOS 10.12.2 (16C67)

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

  • Added totals in the console output
  • Added totals in the html output

@coveralls
Copy link

coveralls commented Jan 16, 2017

Coverage Status

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

@alfert
Copy link
Owner

alfert commented Jan 16, 2017

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

@alfert alfert closed this Jan 16, 2017
@alfert alfert reopened this Jan 16, 2017
@alfert alfert merged commit 2c13a71 into alfert:master Jan 16, 2017
@alfert
Copy link
Owner

alfert commented Jan 16, 2017

Release 1.4.12 is on hex.pm

@razzeee
Copy link

razzeee commented Oct 26, 2018

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
Copy link
Contributor Author

henb commented Oct 26, 2018

@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
Copy link

razzeee commented Oct 27, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants