diff --git a/microsite/data/plugins/allure.yaml b/microsite/data/plugins/allure.yaml new file mode 100644 index 0000000000..a6f4c5d941 --- /dev/null +++ b/microsite/data/plugins/allure.yaml @@ -0,0 +1,9 @@ +--- +title: Allure Reports +author: Deepak Bhardwaj +authorUrl: https://github.com/deepak-bhardwaj-ps +category: Reporting +description: View Allure reports for your components in Backstage. +documentation: https://github.com/backstage/backstage/blob/plugin-allure/plugins/allure/README.md +iconUrl: https://avatars.githubusercontent.com/u/5879127 +npmPackageName: '@backstage/plugin-allure' \ No newline at end of file diff --git a/packages/app/package.json b/packages/app/package.json index a5407abe09..78ebe32e25 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -10,7 +10,6 @@ "@backstage/core-components": "^0.3.2", "@backstage/core-plugin-api": "^0.1.6", "@backstage/integration-react": "^0.1.7", - "@backstage/plugin-allure": "^0.1.0", "@backstage/plugin-api-docs": "^0.6.6", "@backstage/plugin-badges": "^0.2.7", "@backstage/plugin-catalog": "^0.6.12", diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx index 89bc39952f..d84a7341bc 100644 --- a/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/app/src/components/catalog/EntityPage.tsx @@ -110,7 +110,6 @@ import { } from '@roadiehq/backstage-plugin-travis-ci'; import { EntityCodeCoverageContent } from '@backstage/plugin-code-coverage'; import { EmptyState } from '@backstage/core-components'; -import { EntityAllureReportContent } from '@backstage/plugin-allure'; const EntityLayoutWrapper = (props: { children?: ReactNode }) => { const [badgesDialogOpen, setBadgesDialogOpen] = useState(false); @@ -357,10 +356,6 @@ const serviceEntityPage = ( - - - - ); diff --git a/plugins/allure/README.md b/plugins/allure/README.md index d28fe913b1..b9a8435a34 100644 --- a/plugins/allure/README.md +++ b/plugins/allure/README.md @@ -1,4 +1,4 @@ -# Allure +# [Allure](https://docs.qameta.io/allure/) Welcome to the Backstage Allure plugin. This plugin add an entity service page to display Allure test reports related to the service. @@ -24,7 +24,7 @@ Add below configuration in the `app-config.yaml`. ```yaml allure: - baseUrl: # Example: http://localhost:5050/allure-docker-service + baseUrl: # Example: https://allure.my-company.net or when running allure locally, http://localhost:5050/allure-docker-service ``` ### Setup entity service page diff --git a/plugins/allure/dev/example-entity.yaml b/plugins/allure/dev/example-entity.yaml new file mode 100644 index 0000000000..58a9ffd110 --- /dev/null +++ b/plugins/allure/dev/example-entity.yaml @@ -0,0 +1,11 @@ +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: allure-example-service + description: Allure Example Service + annotations: + qameta.io/allure-project: sample +spec: + type: service + lifecycle: experimental + owner: team-a diff --git a/plugins/allure/dev/index.tsx b/plugins/allure/dev/index.tsx index fc61dced03..d697febd56 100644 --- a/plugins/allure/dev/index.tsx +++ b/plugins/allure/dev/index.tsx @@ -16,11 +16,39 @@ import React from 'react'; import { createDevApp } from '@backstage/dev-utils'; import { EntityAllureReportContent } from '../src/plugin'; +import { Content, Header, Page } from '@backstage/core-components'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; +import { Entity } from '@backstage/catalog-model'; + +import exampleEntity from './example-entity.yaml'; +import { allureApiRef } from '../src/api'; createDevApp() - .registerPlugin() + .registerApi({ + api: allureApiRef, + deps: {}, + factory: () => + ({ + async getReportUrl(projectId: string) { + return Promise.resolve( + // Follow the instructions from https://github.com/fescobar/allure-docker-service-ui + // to setup Allure service locally + `http://localhost:5050/allure-docker-service/projects/${projectId}/reports/latest/index.html`, + ); + }, + } as unknown as typeof allureApiRef.T), + }) .addPage({ - element: , + element: ( + +
+ + + + + + + ), title: 'Allure Report', path: '/allure', }) diff --git a/plugins/allure/package.json b/plugins/allure/package.json index 81a37ed996..d55562a537 100644 --- a/plugins/allure/package.json +++ b/plugins/allure/package.json @@ -4,6 +4,7 @@ "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", + "private": false, "publishConfig": { "access": "public", "main": "dist/index.esm.js", diff --git a/plugins/allure/src/components/AllureReportComponent/AllureReportComponent.tsx b/plugins/allure/src/components/AllureReportComponent/AllureReportComponent.tsx index fd46fa0361..444930a3b0 100644 --- a/plugins/allure/src/components/AllureReportComponent/AllureReportComponent.tsx +++ b/plugins/allure/src/components/AllureReportComponent/AllureReportComponent.tsx @@ -21,8 +21,8 @@ import { useEntity } from '@backstage/plugin-catalog-react'; import { ALLURE_PROJECT_ID_ANNOTATION, isAllureReportAvailable, - useAllureProjectId, -} from '../useAllureProjectId'; + getAllureProjectId, +} from '../annotationHelpers'; import { MissingAnnotationEmptyState, Progress, @@ -31,9 +31,9 @@ import { useAsync } from 'react-use'; import { Entity } from '@backstage/catalog-model'; const AllureReport = (props: { entity: Entity }) => { - const allureApi = useApi(allureApiRef); + const allureApi = useApi(allureApiRef); - const allureProjectId = useAllureProjectId(props.entity); + const allureProjectId = getAllureProjectId(props.entity); const { value, loading } = useAsync(async () => { const url = await allureApi.getReportUrl(allureProjectId); return url; @@ -43,19 +43,15 @@ const AllureReport = (props: { entity: Entity }) => { return ; } return ( - <> - {!loading && ( -