$ show k1LoW/octocov
octocov is a Go CLI tool and GitHub Action for collecting, analyzing, and reporting code metrics. It measures code coverage (supporting Go cover, LCOV, SimpleCov, Clover, Cobertura, JaCoCo), code-to-test ratio, test execution time, and custom user-defined metrics. The tool integrates deeply with GitHub: it comments on pull requests, posts job summaries, generates SVG badges, uploads artifacts, and stores reports in configurable datastores (local, S3, GCS, BigQuery, GitHub artifacts, Mackerel). It also supports a central mode that aggregates reports from multiple repositories into a single index with per-repo badges. The architecture is a single Go binary with a Cobra CLI. Key entry points are the root command (cmd/root.go) which orchestrates the CI workflow, and subcommands for badge generation, diff comparison, report dump, and central aggregation. Configuration is via YAML (config/). The coverage package contains format-specific parsers that normalize reports into a common model. The datastore package provides a clean interface for storing/retrieving reports, with implementations for each backend. The badge package renders SVG badges using an embedded template and font. The internal page package serves a React-based viewer for coverage diffs. Primary data flow: Parse coverage files from CI (or local), compute metrics, optionally compare with previous report from a datastore, generate badges/comments/summaries, store the new report. Custom metrics are ingested via environment variable files and validated against a JSON schema. Acceptable conditions (using expr-lang) allow failing CI when metrics regress beyond thresholds. External dependencies include GitHub API (google/go-github), AWS SDK, GCP SDK, BigQuery client, Mackerel API, and a JS bundle for the viewer.
The LLM identified 3 files worth highlighting for reuse:
Defines the Datastore interface (StoreReport, Put, FS) and a factory function that parses URL schemes to create the appropriate backend (local, S3, GCS, BigQuery, GitHub, artifact, Mackerel). This is a clean, reusable abstraction for storing and retrieving reports. It could be extracted and applied to other projects needing polymorphic storage backends.
Provides the core coverage data structures (BlockCoverage, LineCoverage) and operations: parsing, merging, excluding files, computing patch coverage, and path normalization. The normalization logic resolves divergent format paths to git-relative paths using filesystem suffix matching. This package is well-isolated and could be reused by any tool that needs to process coverage data from multiple formats.
Renders SVG badges for coverage, ratio, and time metrics using a Go template and an embedded NotoSans font. Supports custom colors, icons, and condition-based color thresholds via expr-lang expressions. The badge package is self-contained (depends only on Go standard library and the embedded assets) and could be extracted to generate shields.io-style badges for any numeric metric.