Skip to content

Chapati-Systems/covpeek

Repository files navigation

covpeek

Coverage

Cross-language Coverage Report CLI Parser in Go

Parse coverage reports from Rust, Go, TypeScript, JavaScript, and Python with one unified tool.

Demo

asciicast

Features

  • Multi-language Support: Parses coverage files from:

    • Rust: LCOV format (.lcov, .info) generated by grcov or tarpaulin
    • Go: Native coverage format (.out)
    • TypeScript/JavaScript: LCOV format (lcov.info) generated by nyc (Istanbul)
    • Python: Cobertura XML and JSON formats
  • Auto-detection: Automatically detects coverage file format by extension or content

  • Multiple Output Formats: Table (default), JSON, CSV

  • Interactive TUI: Explore coverage data with a terminal user interface

  • Robust Parsing: Handles malformed lines gracefully with warnings

  • High Test Coverage: >80% test coverage for all parser modules

  • Direct Upload: Upload coverage reports directly to SonarQube and Codecov platforms

  • CI Integration: Check coverage thresholds for continuous integration

  • Coverage Diff: Compare coverage between git commits

Install

From Source

git clone https://github.com/Chapati-Systems/covpeek.git
cd covpeek
go build -o covpeek ./cmd/covpeek

Using Go Install

go install github.com/Chapati-Systems/covpeek/cmd/covpeek@latest

Pre-built Binaries

Download from GitHub Releases.

Usage

Parse a Coverage File

Parse a coverage file and display summary table:

covpeek --file coverage.lcov

Parse with different output formats:

# Table format (default) - sorted by coverage descending
covpeek --file coverage.lcov --output table

# JSON format for programmatic use
covpeek --file lcov.info --output json

# CSV format for spreadsheet import
covpeek --file coverage.out --output csv

Launch interactive TUI for exploring coverage data:

covpeek --file coverage.lcov --tui

Force a specific format (bypass auto-detection):

covpeek --file coverage.txt --format lcov
covpeek --file coverage.dat --format go

Filter files below coverage threshold:

covpeek --file coverage.lcov --below 80

Generate Coverage Badge

Generate an SVG badge for embedding in README or dashboards:

covpeek badge --file coverage.lcov --output coverage-badge.svg

Auto-detect coverage file:

covpeek badge --output coverage-badge.svg

Customize label and style:

covpeek badge --file coverage.out --label "test coverage" --style plastic --output badge.svg

Supported styles: flat, plastic, flat-square

Upload Coverage Reports

Upload parsed coverage reports directly to popular platforms like SonarQube and Codecov:

# Upload to SonarQube
covpeek upload --to sonarqube --project-key myproject --file coverage/lcov.info --token $SONAR_TOKEN

# Upload to Codecov
covpeek upload --to codecov --repo-token $CODECOV_TOKEN

Auto-detect coverage file:

covpeek upload --to codecov --repo-token $CODECOV_TOKEN

Custom SonarQube server URL:

covpeek upload --to sonarqube --project-key myproj --url https://sonar.mycompany.com/ --token $SONAR_TOKEN

CI Integration

Check total coverage against minimum threshold:

covpeek ci --min 80

Compare Coverage Between Commits

Compare coverage reports from two git commits:

covpeek diff --file coverage/lcov.info --commit-a HEAD~5 --commit-b HEAD

Generate Coverage Badge

Generate an SVG badge for embedding in README or dashboards:

covpeek badge --file coverage.lcov --output coverage-badge.svg

Auto-detect coverage file:

covpeek badge --output coverage-badge.svg

Customize label and style:

covpeek badge --file coverage.out --label "test coverage" --style plastic --output badge.svg

Supported styles: flat, plastic, flat-square

Upload Coverage Reports

Upload parsed coverage reports directly to popular platforms like SonarQube and Codecov:

# Upload to SonarQube
covpeek upload --to sonarqube --project-key myproject --file coverage/lcov.info --token $SONAR_TOKEN

# Upload to Codecov
covpeek upload --to codecov --repo-token $CODECOV_TOKEN

Auto-detect coverage file:

covpeek upload --to codecov --repo-token $CODECOV_TOKEN

Custom SonarQube server URL:

covpeek upload --to sonarqube --project-key myproj --url https://sonar.mycompany.com/ --token $SONAR_TOKEN

Examples

Parse Rust coverage (generated by grcov):

cargo tarpaulin --out Lcov
covpeek --file lcov.info

Parse Go coverage:

go test -coverprofile=coverage.out ./...
covpeek --file coverage.out

Parse TypeScript/JavaScript coverage (generated by nyc):

nyc --reporter=lcov npm test
covpeek --file coverage/lcov.info

Parse Python coverage (Cobertura XML):

coverage xml
covpeek --file coverage.xml

Parse Python coverage (JSON):

coverage json
covpeek --file coverage.json

Supported Coverage Formats

LCOV Format

Used by Rust (grcov, tarpaulin) and TypeScript/JavaScript (nyc):

  • File extensions: .lcov, .info, lcov.info
  • Records: TN, SF, FN, FNDA, DA, LH, LF, end_of_record
  • Branch coverage (BRF, BRH, BRDA) is supported but optional

Go Coverage Format

Native Go coverage format:

  • File extension: .out
  • Format: mode: set|count|atomic followed by coverage entries
  • Example: file.go:5.10,7.2 1 1

Python Coverage Formats

Cobertura XML and JSON formats generated by the coverage package:

  • XML: coverage.xml
  • JSON: coverage.json

Development

Install pre-commit hooks:

pre-commit install

Run program:

go run ./cmd/covpeek

Run tests:

go test ./...

Run tests with coverage:

go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

Build

Build for current platform

go build -o covpeek ./cmd/covpeek

Build for Linux

See https://freshman.tech/snippets/go/cross-compile-go-programs/

GOOS=linux GOARCH=amd64 go build -o covpeek ./cmd/covpeek

Build for macOS

GOOS=darwin GOARCH=arm64 go build -o covpeek ./cmd/covpeek

Project Structure

covpeek/
├── cmd/covpeek/          # CLI application entry point
│   ├── main.go
│   ├── root.go
│   ├── parse.go
│   ├── upload.go
│   ├── ci.go
│   ├── badge.go
│   ├── diff.go
│   └── tui.go
├── pkg/
│   ├── models/           # Data structures
│   │   └── coverage.go
│   ├── parser/           # Coverage file parsers
│   │   ├── lcov.go       # LCOV format parser
│   │   ├── gocover.go    # Go coverage parser
│   │   ├── pycover_xml.go # Python XML parser
│   │   └── pycover_json.go # Python JSON parser
│   └── uploader/         # Platform uploaders
│       └── uploader.go
├── internal/
│   └── detector/         # Format auto-detection
│       ├── detector.go
│       └── detector_test.go
└── testdata/             # Sample coverage files for testing
    ├── coverage.json
    ├── coverage.xml
    ├── sample.lcov
    ├── sample.out
    └── typescript.info

Testing

All parser modules maintain >80% test coverage with comprehensive test cases including:

  • Valid coverage files
  • Malformed/incomplete entries
  • Edge cases (empty files, missing fields)
  • Multiple files
  • Different coverage modes

Run tests:

go test -v ./...

License

Licensed under the AGPL-3.0 license

See LICENSE file for details.