Skip to content

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

gototal-cobertura

A Go utility that reports the total code coverage from a cobertura XML code coverage report.

Usage

This is useful in cases like the gitlab pipelines that take a regular expression and uses the last match found from the output to find the coverage. For go test --cover this becomes an issue if you have multiple packages as only the last packages coverage will be reported on.

This utility will read the generated cobertura report and output the total coverage. If this utility is run at the end of the gitlab job, then the regex can match on the total code coverage.

An example .gitlab-ci.yml job might look something like the following:

golang:
  stage: test
  script:
    - go install gotest.tools/gotestsum
    - go install github.com/boumenot/gocover-cobertura
    - go install github.com/ggere/gototal-cobertura
    - gotestsum --junitfile report.xml --format testname -- -coverprofile=coverage.out ./...
    - gocover-cobertura < coverage.out > coverage.xml
    - gototal-cobertura < coverage.xml
  coverage: "/coverage: \d+.\d+% of statements/"
  artifacts:
    when: always
    reports:
      junit: report.xml
      cobertura: coverage.xml

Output

Total coverage: 62.50% of statements

Installation

go install gitlab.com/ggere/gototal-cobertura@latest

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages