cicd-statistics

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-08-19 14:42:13 +02:00
parent 842cc7ab06
commit f918d327a9
6 changed files with 49 additions and 47 deletions
+1 -45
View File
@@ -10,13 +10,9 @@ import { BackstagePlugin } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import { RouteRef } from '@backstage/core-plugin-api';
// Warning: (ae-missing-release-tag) "AbortError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export class AbortError extends Error {}
// Warning: (ae-missing-release-tag) "Build" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface Build {
branchType: FilterBranchType;
@@ -30,25 +26,17 @@ export interface Build {
triggeredBy?: TriggerReason;
}
// Warning: (ae-missing-release-tag) "BuildWithRaw" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export type BuildWithRaw<T = any> = Build & {
raw: T;
};
// Warning: (ae-missing-release-tag) "ChartType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export type ChartType = 'duration' | 'count';
// Warning: (ae-missing-release-tag) "ChartTypes" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
// @public
export type ChartTypes = Array<ChartType>;
// Warning: (ae-missing-release-tag) "CicdConfiguration" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface CicdConfiguration {
availableStatuses: ReadonlyArray<FilterStatusType>;
@@ -56,8 +44,6 @@ export interface CicdConfiguration {
formatStageName: (parentNames: Array<string>, stageName: string) => string;
}
// Warning: (ae-missing-release-tag) "CicdDefaults" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface CicdDefaults {
chartTypes: Record<FilterStatusType, ChartTypes>;
@@ -75,16 +61,12 @@ export interface CicdDefaults {
timeTo: Date;
}
// Warning: (ae-missing-release-tag) "CicdState" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface CicdState {
// (undocumented)
builds: Array<Build>;
}
// Warning: (ae-missing-release-tag) "CicdStatisticsApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface CicdStatisticsApi {
// (undocumented)
@@ -95,13 +77,9 @@ export interface CicdStatisticsApi {
): Promise<Partial<CicdConfiguration>>;
}
// Warning: (ae-missing-release-tag) "cicdStatisticsApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const cicdStatisticsApiRef: ApiRef<CicdStatisticsApi>;
// Warning: (ae-missing-release-tag) "cicdStatisticsPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const cicdStatisticsPlugin: BackstagePlugin<
{
@@ -111,18 +89,12 @@ export const cicdStatisticsPlugin: BackstagePlugin<
{}
>;
// Warning: (ae-missing-release-tag) "EntityCicdStatisticsContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityCicdStatisticsContent: EntityPageCicdCharts;
// Warning: (ae-missing-release-tag) "EntityPageCicdCharts" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function EntityPageCicdCharts(): JSX.Element;
// Warning: (ae-missing-release-tag) "FetchBuildsOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface FetchBuildsOptions {
// (undocumented)
@@ -141,13 +113,9 @@ export interface FetchBuildsOptions {
updateProgress: UpdateProgress;
}
// Warning: (ae-missing-release-tag) "FilterBranchType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export type FilterBranchType = 'master' | 'branch';
// Warning: (ae-missing-release-tag) "FilterStatusType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export type FilterStatusType =
| 'unknown'
@@ -160,16 +128,12 @@ export type FilterStatusType =
| 'stalled'
| 'expired';
// Warning: (ae-missing-release-tag) "GetConfigurationOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface GetConfigurationOptions {
// (undocumented)
entity: Entity;
}
// Warning: (ae-missing-release-tag) "Stage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface Stage {
duration: number;
@@ -179,13 +143,9 @@ export interface Stage {
status: FilterStatusType;
}
// Warning: (ae-missing-release-tag) "statusTypes" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const statusTypes: Array<FilterStatusType>;
// Warning: (ae-missing-release-tag) "TriggerReason" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type TriggerReason =
/** Triggered by source code management, e.g. a Github hook */
@@ -197,13 +157,9 @@ export type TriggerReason =
/** Triggered for some other reason */
| 'other';
// Warning: (ae-missing-release-tag) "triggerReasons" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const triggerReasons: Array<TriggerReason>;
// Warning: (ae-missing-release-tag) "UpdateProgress" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface UpdateProgress {
// (undocumented)
@@ -15,9 +15,9 @@
*/
import { createApiRef } from '@backstage/core-plugin-api';
import { CicdStatisticsApi } from './types';
/** @public */
export const cicdStatisticsApiRef = createApiRef<CicdStatisticsApi>({
id: 'cicd-statistics-api',
});
+44
View File
@@ -21,6 +21,8 @@ import { Entity } from '@backstage/catalog-model';
*
* If all of these aren't applicable to the underlying CI/CD, these can be
* configured to be hidden, using the `availableStatuses` in `CicdConfiguration`.
*
* @public
*/
export type FilterStatusType =
| 'unknown'
@@ -32,6 +34,10 @@ export type FilterStatusType =
| 'failed'
| 'stalled'
| 'expired';
/**
* @public
*/
export const statusTypes: Array<FilterStatusType> = [
'succeeded',
'failed',
@@ -50,9 +56,14 @@ export const statusTypes: Array<FilterStatusType> = [
* The concept of what constitutes a master branch is generic. It might be called
* something like 'release' or 'main' or 'trunk' in the underlying CI/CD system,
* which is then up to the Api to map accordingly.
*
* @public
*/
export type FilterBranchType = 'master' | 'branch';
/**
* @public
*/
export type TriggerReason =
/** Triggered by source code management, e.g. a Github hook */
| 'scm'
@@ -63,6 +74,9 @@ export type TriggerReason =
/** Triggered for some other reason */
| 'other';
/**
* @public
*/
export const triggerReasons: Array<TriggerReason> = [
'scm',
'manual',
@@ -76,6 +90,8 @@ export const triggerReasons: Array<TriggerReason> = [
* This may be called things like Stage or Step or Task in CI/CD systems, but is
* generic here. There's also no concept of parallelism which might exist within
* some stages.
*
* @public
*/
export interface Stage {
name: string;
@@ -94,6 +110,8 @@ export interface Stage {
* Generic Build type.
*
* A build has e.g. a build type (master/branch), a status and (possibly) sub stages.
*
* @public
*/
export interface Build {
raw?: unknown;
@@ -125,6 +143,8 @@ export interface Build {
*
* This can be useful in an Api to use while mapping internal data structures
* (raw) into generic builds.
*
* @public
*/
export type BuildWithRaw<T = any> = Build & {
raw: T;
@@ -136,8 +156,16 @@ export type BuildWithRaw<T = any> = Build & {
* Values are:
* * `duration`: shows an area chart of the duration over time
* * `count`: shows a bar chart of the number of build per day
*
* @public
*/
export type ChartType = 'duration' | 'count';
/**
* Chart types.
*
* @public
*/
export type ChartTypes = Array<ChartType>;
/**
@@ -145,6 +173,8 @@ export type ChartTypes = Array<ChartType>;
*
* These are all optional, but can be overridden from the Api to whatever makes
* most sense for that implementation.
*
* @public
*/
export interface CicdDefaults {
timeFrom: Date;
@@ -171,6 +201,8 @@ export interface CicdDefaults {
* configuration before anything else.
*
* All of these fields are optional though, and will fallback to hard-coded defaults.
*
* @public
*/
export interface CicdConfiguration {
/**
@@ -200,11 +232,15 @@ export interface CicdConfiguration {
/**
* If the Api implements support for aborting the fetching of builds, throw an
* AbortError of this type (or any other error with name === 'AbortError').
*
* @public
*/
export class AbortError extends Error {}
/**
* The result type for `fetchBuilds`.
*
* @public
*/
export interface CicdState {
builds: Array<Build>;
@@ -222,6 +258,8 @@ export interface CicdState {
* the UI.
*
* Optionally this can signal multiple progresses in several steps
*
* @public
*/
export interface UpdateProgress {
(completed: number, total: number, started?: number): void;
@@ -238,6 +276,8 @@ export interface UpdateProgress {
/**
* When reading configuration, the Api can return a custom settings depending on
* the entity being viewed.
*
* @public
*/
export interface GetConfigurationOptions {
entity: Entity;
@@ -252,6 +292,8 @@ export interface GetConfigurationOptions {
*
* When the UI re-fetches, it will abort any previous fetching, so polling
* `abortSignal.aborted`, and possibly throwing an `AbortError`, can be useful.
*
* @public
*/
export interface FetchBuildsOptions {
entity: Entity;
@@ -266,6 +308,8 @@ export interface FetchBuildsOptions {
/**
* The interface which is mapped to the `cicdStatisticsApiRef` which is used by
* the UI.
*
* @public
*/
export interface CicdStatisticsApi {
getConfiguration(
@@ -46,6 +46,7 @@ import { cleanupBuildTree } from './utils/stage-names';
import { renderFallbacks, useAsyncChain } from './components/progress';
import { sortFilterStatusType } from './utils/api';
/** @public */
export function EntityPageCicdCharts() {
const state = useCicdConfiguration();
+2
View File
@@ -26,6 +26,7 @@ const rootCatalogCicdStatsRouteRef = createRouteRef({
id: 'cicd-statistics',
});
/** @public */
export const cicdStatisticsPlugin = createPlugin({
id: 'cicd-statistics',
routes: {
@@ -33,6 +34,7 @@ export const cicdStatisticsPlugin = createPlugin({
},
});
/** @public */
export const EntityCicdStatisticsContent = cicdStatisticsPlugin.provide(
createRoutableExtension({
component: () => import('./entity-page').then(m => m.EntityPageCicdCharts),
-1
View File
@@ -201,7 +201,6 @@ const ALLOW_WARNINGS = [
'packages/core-components',
'plugins/catalog',
'plugins/catalog-import',
'plugins/cicd-statistics',
'plugins/circleci',
'plugins/cost-insights',
'plugins/dynatrace',