-
Notifications
You must be signed in to change notification settings - Fork 108
feat(scorecard): add codecov backend module with 7 coverage metrics #3477
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
Open
fullsend-ai-coder
wants to merge
4
commits into
main
Choose a base branch
from
fs/3473-scorecard-codecov-module
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4640fc9
feat(scorecard): add codecov backend module with 7 coverage metrics
fullsend-ai-coder[bot] 331e7e5
chore(scorecard): generate api report for codecov module
fullsend-ai-coder[bot] cc44a77
docs(scorecard): add README, changeset, and fix version for codecov m…
fullsend-ai-coder[bot] c893be9
style(scorecard): run prettier on codecov module files
fullsend-ai-coder[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-codecov': minor | ||
| --- | ||
|
|
||
| Add new codecov backend module for the scorecard plugin with 7 code coverage metrics. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
workspaces/scorecard/examples/components/codecov-scorecard-only.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| # Component with Codecov Scorecard only | ||
| apiVersion: backstage.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: codecov-scorecard-only | ||
| annotations: | ||
| codecov.io/repo: redhat-developer/rhdh-plugins | ||
| github.com/project-slug: redhat-developer/rhdh-plugins | ||
| spec: | ||
| type: service | ||
| owner: group:development/guests | ||
| lifecycle: experimental |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
workspaces/scorecard/plugins/scorecard-backend-module-codecov/.eslintrc.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
92 changes: 92 additions & 0 deletions
92
workspaces/scorecard/plugins/scorecard-backend-module-codecov/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # Scorecard Backend Module: Codecov | ||
|
|
||
| Adds [Codecov](https://about.codecov.io/) code coverage metrics to the scorecard plugin. All 7 metrics are fetched from a single Codecov API call per entity. | ||
|
|
||
| ## Metrics | ||
|
|
||
| | Metric ID | Type | Description | | ||
| | ------------------------ | ------ | --------------------------------------- | | ||
| | `codecov.coverage` | number | Current code coverage percentage | | ||
| | `codecov.coverage_trend` | number | Code coverage trend for the last 7 days | | ||
| | `codecov.tracked_files` | number | Number of files tracked by Codecov | | ||
| | `codecov.tracked_lines` | number | Total lines of code tracked by Codecov | | ||
| | `codecov.covered_lines` | number | Number of lines covered by tests | | ||
| | `codecov.partial_lines` | number | Number of partially covered lines | | ||
| | `codecov.missed_lines` | number | Number of lines not covered by tests | | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| yarn workspace backend add @red-hat-developer-hub/backstage-plugin-scorecard-backend-module-codecov | ||
| ``` | ||
|
|
||
| Then register the module in your backend: | ||
|
|
||
| ```ts | ||
| // packages/backend/src/index.ts | ||
| backend.add( | ||
| import('@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-codecov'), | ||
| ); | ||
| ``` | ||
|
|
||
| ## Entity annotation | ||
|
|
||
| Entities need the `codecov.io/repo` annotation to opt in: | ||
|
|
||
| ```yaml | ||
| metadata: | ||
| annotations: | ||
| codecov.io/repo: owner/repo | ||
| ``` | ||
|
|
||
| The module resolves the Codecov service from the entity's annotations. If the entity also has a `github.com/project-slug` annotation, the service defaults to `github`. Otherwise, set the service explicitly: | ||
|
|
||
| ```yaml | ||
| metadata: | ||
| annotations: | ||
| codecov.io/repo: owner/repo | ||
| codecov.io/service: github | ||
| ``` | ||
|
|
||
| ### Optional annotations | ||
|
|
||
| | Annotation | Description | | ||
| | -------------------- | ---------------------------------------------------------------------------------------------------------- | | ||
| | `codecov.io/repo` | **Required.** The Codecov repository in `owner/repo` or `repo` format. | | ||
| | `codecov.io/service` | Git hosting service (`github`, `gitlab`, `bitbucket`). Inferred from `github.com/project-slug` if present. | | ||
| | `codecov.io/owner` | Override the repository owner (if not using `owner/repo` format). | | ||
| | `codecov.io/account` | Codecov account name for multi-account setups (maps to config accounts). | | ||
|
|
||
| ## Configuration | ||
|
|
||
| Configuration is optional for public repositories. For private repositories, configure an auth token: | ||
|
|
||
| ```yaml | ||
| # app-config.yaml | ||
| codecov: | ||
| accounts: | ||
| - name: default | ||
| authToken: ${CODECOV_API_TOKEN} | ||
| ``` | ||
|
|
||
| ### Multiple accounts | ||
|
|
||
| ```yaml | ||
| # app-config.yaml | ||
| codecov: | ||
| defaultAccount: primary | ||
| accounts: | ||
| - name: primary | ||
| authToken: ${CODECOV_PRIMARY_TOKEN} | ||
| - name: oss | ||
| # authToken optional for public repos | ||
| ``` | ||
|
|
||
| Then set the `codecov.io/account` annotation on entities to route them to the correct account: | ||
|
|
||
| ```yaml | ||
| metadata: | ||
| annotations: | ||
| codecov.io/repo: owner/repo | ||
| codecov.io/account: oss | ||
| ``` |
44 changes: 44 additions & 0 deletions
44
workspaces/scorecard/plugins/scorecard-backend-module-codecov/config.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| export interface Config { | ||
| /** Optional configurations for the Codecov plugin */ | ||
| codecov?: { | ||
| /** | ||
| * The default account name to use when the codecov.io/account annotation is not set. | ||
| * Defaults to "default". | ||
| * @visibility frontend | ||
| */ | ||
| defaultAccount?: string; | ||
|
|
||
| /** | ||
| * The list of codecov accounts. | ||
| */ | ||
| accounts?: Array<{ | ||
| /** | ||
| * The name of the codecov account. | ||
| * @visibility frontend | ||
| */ | ||
| name: string; | ||
|
|
||
| /** | ||
| * The auth token for the codecov account. Optional for public repositories. | ||
| * @visibility secret | ||
| */ | ||
| authToken?: string; | ||
| }>; | ||
| }; | ||
| } | ||
49 changes: 49 additions & 0 deletions
49
workspaces/scorecard/plugins/scorecard-backend-module-codecov/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| { | ||
| "name": "@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-codecov", | ||
| "version": "0.0.0", | ||
| "license": "Apache-2.0", | ||
| "description": "The codecov backend module for the scorecard plugin.", | ||
| "main": "src/index.ts", | ||
| "types": "src/index.ts", | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "main": "dist/index.cjs.js", | ||
| "types": "dist/index.d.ts" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/redhat-developer/rhdh-plugins", | ||
| "directory": "workspaces/scorecard/plugins/scorecard-backend-module-codecov" | ||
| }, | ||
| "backstage": { | ||
| "role": "backend-plugin-module", | ||
| "pluginId": "scorecard", | ||
| "pluginPackage": "@red-hat-developer-hub/backstage-plugin-scorecard-backend" | ||
| }, | ||
| "scripts": { | ||
| "start": "backstage-cli package start", | ||
| "build": "backstage-cli package build", | ||
| "lint": "backstage-cli package lint", | ||
| "test": "backstage-cli package test", | ||
| "clean": "backstage-cli package clean", | ||
| "prepack": "backstage-cli package prepack", | ||
| "postpack": "backstage-cli package postpack" | ||
| }, | ||
| "dependencies": { | ||
| "@backstage/backend-plugin-api": "^1.8.0", | ||
| "@backstage/catalog-client": "^1.14.0", | ||
| "@backstage/catalog-model": "^1.7.7", | ||
| "@backstage/config": "^1.3.6", | ||
| "@red-hat-developer-hub/backstage-plugin-scorecard-common": "workspace:^", | ||
| "@red-hat-developer-hub/backstage-plugin-scorecard-node": "workspace:^" | ||
| }, | ||
| "devDependencies": { | ||
| "@backstage/backend-test-utils": "^1.11.1", | ||
| "@backstage/cli": "^0.36.0" | ||
| }, | ||
| "configSchema": "config.d.ts", | ||
| "files": [ | ||
| "config.d.ts", | ||
| "dist" | ||
| ] | ||
| } |
11 changes: 11 additions & 0 deletions
11
workspaces/scorecard/plugins/scorecard-backend-module-codecov/report.api.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ## API Report File for "@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-codecov" | ||
|
|
||
| > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
|
|
||
| ```ts | ||
| import { BackendFeature } from '@backstage/backend-plugin-api'; | ||
|
|
||
| // @public (undocumented) | ||
| const scorecardModuleCodecov: BackendFeature; | ||
| export default scorecardModuleCodecov; | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low] scope-alignment
The defaultAccount field is marked @visibility frontend, but this is a backend-only module with no frontend counterpart.