From 3c439b7b217641d80b6dcac07560be4e41673f98 Mon Sep 17 00:00:00 2001 From: Andrei Stepanov Date: Fri, 5 Apr 2024 16:50:00 +0200 Subject: [PATCH] OSCI-5826 Signed-off-by: Andrei Stepanov --- Dockerfile | 2 +- src/components/ArtifactsList.tsx | 7 +++- src/components/GatingStatus.tsx | 66 ++++++++++++++++++++++++++------ src/queries/Artifacts.ts | 3 ++ src/slices/artifactsSlice.ts | 3 +- src/types.ts | 2 + src/utils/stages_states.ts | 2 + src/utils/utils.tsx | 2 +- 8 files changed, 72 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 062bfeb..d85379f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/fedoraci/ciboard-server:b466781 +FROM quay.io/fedoraci/ciboard-server:7e01b56 # npm mirror to use to install dependencies. ARG NPMLOCATION=open diff --git a/src/components/ArtifactsList.tsx b/src/components/ArtifactsList.tsx index 240bcc6..265fca4 100644 --- a/src/components/ArtifactsList.tsx +++ b/src/components/ArtifactsList.tsx @@ -56,7 +56,10 @@ import { } from '../types'; import { ExternalLink } from './ExternalLink'; import { store } from '../reduxStore'; -import { ArtifactGreenwaveStatesSummary } from './GatingStatus'; +import { + ArtifactStatesSummary, + ArtifactGreenwaveStatesSummary, +} from './GatingStatus'; interface ShowLoadingProps {} function ShowLoading(props: ShowLoadingProps) { @@ -98,6 +101,8 @@ const makeArtifactRowRpm = (artifact: ArtifactRpm): ArtifactRow => { const cell3: JSX.Element = <>{hit_source.nvr}; const cell4: JSX.Element = ( <> + {isLoading && } + ; export const resultColors: Record = { green: ['passed'], red: ['errored', 'failed'], - orange: ['missing', 'needs inspection'], + orange: ['missing', 'needs inspection', 'needs_inspection'], cyan: [ 'waived', @@ -77,6 +71,21 @@ const PrintRequirementsSize = (props: PrintRequirementsSizeProps) => { ); }; +interface PrintTestStateSizeProps { + state: string; + size: number; +} +const PrintTestStateSize = (props: PrintTestStateSizeProps) => { + const { state, size } = props; + const color: ColorPropType = + (resultColor(state) as ColorPropType | undefined) || 'grey'; + return ( + + ); +}; + // https://pagure.io/fedora-ci/messages/blob/master/f/schemas/test-complete.yaml#_14 const gwStateMappings: Record = { @@ -142,6 +151,41 @@ gwStatesUiPriority.forEach((key, index) => { uiPriorityMap[key] = index; }); +// artifact: ArtifactRpm | ArtifactContainerImage | ArtifactMbs; +interface ArtifactStatesSummaryProps { + artifact: Artifact; + isLoading?: boolean; +} +export const ArtifactStatesSummary: React.FC = ( + props, +) => { + const { artifact, isLoading } = props; + if (isGatingArtifact(artifact)) { + // Gating Artifacts are rendered by other component + return null; + } + if (isLoading) { + return null; + } + const stagesSummary = artifact.children?.stagesSummary; + // Conside only 'test' stage + const testStages = _.filter(stagesSummary, (element) => + _.isEqual(_.get(element, '[0]'), 'test'), + ); + const testStates = _.map(testStages, (element) => { + return [_.get(element, '[1]', 'unknown'), _.get(element, '[2]', 0)]; + }); + return ( + + {_.map(testStates, ([state, size]: [string, number]) => ( + + + + ))} + + ); +}; + // artifact: ArtifactRpm | ArtifactContainerImage | ArtifactMbs; interface ArtifactGreenwaveStatesSummaryProps { artifact: Artifact; @@ -156,11 +200,11 @@ export const ArtifactGreenwaveStatesSummary: React.FC< if (isScratch) { return null; } - if (!isGatingArtifact(artifact)) { + if (isLoading) { return null; } - if (isLoading) { - return ; + if (!isGatingArtifact(artifact)) { + return null; } const decision = getGwDecision(artifact); if (!decision) { diff --git a/src/queries/Artifacts.ts b/src/queries/Artifacts.ts index 3aa922b..57afac9 100644 --- a/src/queries/Artifacts.ts +++ b/src/queries/Artifacts.ts @@ -192,6 +192,9 @@ export const ArtifactsSearchSlowQuery2 = gql` hits { hit_info hit_source + children(onlyActual: true) { + stagesSummary + } greenwaveDecision { results waivers diff --git a/src/slices/artifactsSlice.ts b/src/slices/artifactsSlice.ts index ed2392d..42f36d4 100644 --- a/src/slices/artifactsSlice.ts +++ b/src/slices/artifactsSlice.ts @@ -106,10 +106,11 @@ const responseToState = (response: any) => { const { hits: hits_, hits_info } = response.data.artifacts; const hits = _.map( hits_, - ({ hit_info, hit_source, greenwaveDecision }) => ({ + ({ hit_info, hit_source, greenwaveDecision, children }) => ({ hit_info: hit_info, hit_source: hit_source, greenwaveDecision: greenwaveDecision, + children, }), ); return { hits: hits as Artifact[], hits_info }; diff --git a/src/types.ts b/src/types.ts index c90d4e7..bcf0407 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,6 +21,7 @@ import _ from 'lodash'; import { TabsProps } from '@patternfly/react-core'; import { mappingDatagrepperUrl, config } from './config'; +import { StageStateNumAChildren } from './utils/stages_states'; /** * Valid for: Version: 1.y.z @@ -839,6 +840,7 @@ export interface AChildGreenwaveAndTestMsg { export interface AChildrenMsg { hits: AChildMsg[]; hitsInfo: HitsInfo; + stagesSummary: StageStateNumAChildren[]; } export type AChildSchemaMsg = AChildBuildMsg | AChildTestMsg; diff --git a/src/utils/stages_states.ts b/src/utils/stages_states.ts index b8a02fc..91e2b92 100644 --- a/src/utils/stages_states.ts +++ b/src/utils/stages_states.ts @@ -70,6 +70,8 @@ import { */ export type StageStateAChildren = [MsgStageName, StateName, AChild[]]; +export type StageStateNumAChildren = [MsgStageName, StateName, number]; + type AChildrenByStageName = { msgStageName: MsgStageName; aChildrenByStateName: AChildrenByStateName; diff --git a/src/utils/utils.tsx b/src/utils/utils.tsx index 23fa132..51964b6 100644 --- a/src/utils/utils.tsx +++ b/src/utils/utils.tsx @@ -270,7 +270,7 @@ export function mapTypeToIconsProps(type: string): IconProps | null { export const isGatingArtifact = (artifact: Artifact): boolean => { if ( (isArtifactRpm(artifact) || isArtifactMbs(artifact)) && - _.size(artifact.hit_source.gateTag) > 0 + _.endsWith(artifact.hit_source.gateTag, '-gate') ) { return true; } else if (isArtifactRedhatContainerImage(artifact)) {