Create code-coverage plugin
In order to use this plugin, you must set the
`backstage.io/code-coverage` annotation on your entity.
```yaml
backstage.io/code-coverage: enabled
```
There's a feature to only include files that are in SCM in the coverage
report, this is helpful to not count generated files for example. To
enable this set the `backstage.io/code-coverage` annotation to
`scm-only`.
```yaml
backstage.io/code-coverage: scm-only
```
The backend plugin provides API endpoints for submitting code-coverage
reports. Currently jacoco and cobertura are supported. These reports
are normalized to a json format that is stored in the database.
```json
// curl -X POST -H "Content-Type:text/xml" -d @cobertura.xml "localhost:7000/api/code-coverage/Component/default/entity-name?coverageType=cobertura"
{
"links": [
{
"href": "http://localhost:7000/api/code-coverage/Component/default/entity-name",
"rel": "coverage"
}
]
}
```
It also provides some additional API endpoints:
* Viewing the latest report
* Viewing a more condensed history of code coverage values
* Retrieving file contents from source-control, used by the UI
Provides a graph of code coverage change over time, as well as a file
view where you can see the highlighted lines.
Co-authored-by: nissayeva <natashaaay@gmail.com>
Signed-off-by: alde <r.dybeck@gmail.com>
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"@backstage/plugin-catalog-react": "^0.1.3",
|
||||
"@backstage/plugin-circleci": "^0.2.12",
|
||||
"@backstage/plugin-cloudbuild": "^0.2.13",
|
||||
"@backstage/plugin-code-coverage": "^0.1.0",
|
||||
"@backstage/plugin-cost-insights": "^0.8.4",
|
||||
"@backstage/plugin-explore": "^0.3.2",
|
||||
"@backstage/plugin-gcp-projects": "^0.2.5",
|
||||
|
||||
@@ -102,6 +102,7 @@ import {
|
||||
EntityTravisCIOverviewCard,
|
||||
isTravisciAvailable,
|
||||
} from '@roadiehq/backstage-plugin-travis-ci';
|
||||
import { EntityCodeCoverageContent } from '@backstage/plugin-code-coverage';
|
||||
|
||||
const EntityLayoutWrapper = (props: { children?: ReactNode }) => {
|
||||
const [badgesDialogOpen, setBadgesDialogOpen] = useState(false);
|
||||
@@ -303,6 +304,10 @@ const serviceEntityPage = (
|
||||
<EntityGithubInsightsContent />
|
||||
</EntityLayout.Route>
|
||||
|
||||
<EntityLayout.Route path="/code-coverage" title="Code Coverage">
|
||||
<EntityCodeCoverageContent />
|
||||
</EntityLayout.Route>
|
||||
|
||||
<EntityLayout.Route path="/kafka" title="Kafka">
|
||||
<EntityKafkaContent />
|
||||
</EntityLayout.Route>
|
||||
@@ -347,6 +352,10 @@ const websiteEntityPage = (
|
||||
<EntityGithubInsightsContent />
|
||||
</EntityLayout.Route>
|
||||
|
||||
<EntityLayout.Route path="/code-coverage" title="Code Coverage">
|
||||
<EntityCodeCoverageContent />
|
||||
</EntityLayout.Route>
|
||||
|
||||
<EntityLayout.Route path="/todos" title="TODOs">
|
||||
<EntityTodoContent />
|
||||
</EntityLayout.Route>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"@backstage/plugin-auth-backend": "^0.3.7",
|
||||
"@backstage/plugin-badges-backend": "^0.1.1",
|
||||
"@backstage/plugin-catalog-backend": "^0.7.0",
|
||||
"@backstage/plugin-code-coverage-backend": "^0.1.0",
|
||||
"@backstage/plugin-graphql-backend": "^0.1.6",
|
||||
"@backstage/plugin-kubernetes-backend": "^0.3.3",
|
||||
"@backstage/plugin-kafka-backend": "^0.2.3",
|
||||
|
||||
@@ -37,6 +37,7 @@ import { Config } from '@backstage/config';
|
||||
import healthcheck from './plugins/healthcheck';
|
||||
import auth from './plugins/auth';
|
||||
import catalog from './plugins/catalog';
|
||||
import codeCoverage from './plugins/codecoverage';
|
||||
import kubernetes from './plugins/kubernetes';
|
||||
import kafka from './plugins/kafka';
|
||||
import rollbar from './plugins/rollbar';
|
||||
@@ -75,6 +76,9 @@ async function main() {
|
||||
|
||||
const healthcheckEnv = useHotMemoize(module, () => createEnv('healthcheck'));
|
||||
const catalogEnv = useHotMemoize(module, () => createEnv('catalog'));
|
||||
const codeCoverageEnv = useHotMemoize(module, () =>
|
||||
createEnv('code-coverage'),
|
||||
);
|
||||
const scaffolderEnv = useHotMemoize(module, () => createEnv('scaffolder'));
|
||||
const authEnv = useHotMemoize(module, () => createEnv('auth'));
|
||||
const proxyEnv = useHotMemoize(module, () => createEnv('proxy'));
|
||||
@@ -90,6 +94,7 @@ async function main() {
|
||||
|
||||
const apiRouter = Router();
|
||||
apiRouter.use('/catalog', await catalog(catalogEnv));
|
||||
apiRouter.use('/code-coverage', await codeCoverage(codeCoverageEnv));
|
||||
apiRouter.use('/rollbar', await rollbar(rollbarEnv));
|
||||
apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv));
|
||||
apiRouter.use('/auth', await auth(authEnv));
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { createRouter } from '@backstage/plugin-code-coverage-backend';
|
||||
import { PluginEnvironment } from '../types';
|
||||
|
||||
export default async function createPlugin(env: PluginEnvironment) {
|
||||
return await createRouter({
|
||||
config: env.config,
|
||||
discovery: env.discovery,
|
||||
database: env.database,
|
||||
urlReader: env.reader,
|
||||
logger: env.logger,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user