Skip to content

Create a new code-coverage module for scorecard #3474

@christoph-jerolimov

Description

@christoph-jerolimov

Scorecard is a backstage plugin and supports multiple metric, grouped as modules in folder workspaces/scorecard/plugins.

There are already modules that support GitHub, OpenSSF, SonarQube. Add a new module for code-coverage.

That is different then the codecov module mentioned in #3473. Because codecov is dedicated for the codecov provider, while this "code-coverage" module is for the Backstage Community Plugin "code-coverage" from https://github.com/backstage/community-plugins/tree/main/workspaces/code-coverage.

With this, this new code-coverage module would support tools like cobertura, jacoco, and lcov.

This module will repopulate this code coverage values from that plugin into the scorecard plugin. For this, this new metrics should load the data from the code-coverage-backend and provide them as MetricProvider(s) in the newly created scorecard-backend-module-code-coverage module.

The https://github.com/backstage/community-plugins/blob/main/workspaces/code-coverage/plugins/code-coverage-backend/README.md explain which data are available throw the history API call:

GET /api/code-coverage/report?entity=component:default/entity-name
{
  "aggregate": {
    "branch": {
      "available": 0,
      "covered": 0,
      "missed": 0,
      "percentage": 0
    },
    "line": {
      "available": 5,
      "covered": 4,
      "missed": 1,
      "percentage": 80
    }
  },
  "entity": {
    "kind": "Component",
    "name": "entity-name",
    "namespace": "default"
  },
  "files": [
    {
      "branchHits": {},
      "filename": "main.go",
      "lineHits": {
        "117": 12,
        "142": 8,
        "34": 8,
        "42": 0,
        "58": 6
      }
    }
  ]
}

Based on that data the following metrics should be possible:

  1. Code coverage (Lines) (Percentage value based on aggregate.line.percentage)
  2. Code coverage - Tracked lines of code (based on aggregate.line.available)
  3. Code coverage - Covered lines of code (based on aggregate.line.covered)
  4. Code coverage - Missed lines of code (based on aggregate.line.missed)
  5. Code coverage (Files) (Percentage value based on aggregate.branch.percentage)
  6. Code coverage - Tracked lines of code (based on aggregate.branch.available)
  7. Code coverage - Covered lines of code (based on aggregate.branch.covered)
  8. Code coverage - Missed lines of code (based on aggregate.branch.missed)

All metrics providers should filter for entities with annotation backstage.io/code-coverage.

Add a type definition for the code-coverage Backend response

Add tests and integrate the new code-coverage module as well as the Code Coverage frontend and backend from the Backstage Community plugin into the existing Backstage app.

Add an example entity for code-coverage with the right annotation for it.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions