From 8543e9135568469d092c31510170ea6e224061ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Grabovsk=C3=BD?= Date: Tue, 2 May 2023 14:44:26 +0200 Subject: [PATCH] Load contact info from custom metadata --- src/artifact.ts | 3 +- .../PageResultsNew/DetailsDrawer.tsx | 9 ++++ .../PageResultsNew/TestSuitesAccordion.tsx | 16 +++++- src/components/PageResultsNew/index.tsx | 52 ++++++++++++++++--- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/artifact.ts b/src/artifact.ts index f737868c..76a6d2b6 100644 --- a/src/artifact.ts +++ b/src/artifact.ts @@ -19,7 +19,7 @@ */ import _ from 'lodash'; -import { BrokerMessagesType, EtaBrokerMessagesType } from './types'; +import { BrokerMessagesType, EtaBrokerMessagesType, Metadata } from './types'; export type ComposeArtifactType = 'productmd-compose'; export type ContainerImageArtifactType = 'redhat-container-image'; @@ -404,6 +404,7 @@ export interface KaiErrataToolAutomationStateType { export type StateKaiType = { broker_msg_body: BrokerMessagesType; + custom_metadata?: Metadata; kai_state: KaiStateType; }; diff --git a/src/components/PageResultsNew/DetailsDrawer.tsx b/src/components/PageResultsNew/DetailsDrawer.tsx index 461cc788..96597f2b 100644 --- a/src/components/PageResultsNew/DetailsDrawer.tsx +++ b/src/components/PageResultsNew/DetailsDrawer.tsx @@ -205,6 +205,10 @@ function ContactWidget({ contact }: ContactWidgetProps) { via Slack + ,{' '} + + via Chat + , or via email at{' '} {contact.email} @@ -243,6 +247,11 @@ export function DetailsDrawer(props: DetailsDrawerProps) { /> ) : null; + /* + * TODO: Load (ArtifactsXunitQuery) and parse (xunitParser) xunit + * and pass the test suites/loading/error state to . + */ + const panelContent = ( > >({}); const { suites } = props; - if (!suites) return null; + if (_.isEmpty(suites)) { + return ( + + + The CI system did not provide detailed results for this test + run. + + + ); + } const onToggle = (name: string): void => { const newExpandedIds = update(expandedSuites, { diff --git a/src/components/PageResultsNew/index.tsx b/src/components/PageResultsNew/index.tsx index 351da65b..702e85b0 100644 --- a/src/components/PageResultsNew/index.tsx +++ b/src/components/PageResultsNew/index.tsx @@ -51,7 +51,7 @@ import { StateKaiType, StateType, } from '../../artifact'; -import { MSG_V_1 } from '../../types'; +import { MSG_V_1, MetadataContact } from '../../types'; import { getDocsUrl, getKaiExtendedStatus, @@ -125,7 +125,7 @@ function transformGreenwaveOutcome( return 'failed'; } -function extractCotactFromUmb(test: StateKaiType): CiContact | undefined { +function extractContactFromUmb(test: StateKaiType): CiContact | undefined { // TODO: Incorporate contact info from metadata somehow. if (!MSG_V_1.isMsg(test.broker_msg_body)) return; const { contact } = test.broker_msg_body; @@ -141,16 +141,45 @@ function extractCotactFromUmb(test: StateKaiType): CiContact | undefined { }; } -function extractContact(test: StateType): CiContact | undefined { - // TODO: Pull data from "metadata" database. - // TODO: Handle the Greenwave-only case. - if (isGreenwaveState(test)) return; +function extractContact(test: StateType): CiContact { + let contact: CiContact = {}; + let metadataContact: MetadataContact | undefined; + + // TODO: Handle the Greenwave-only case. Is there any info in the Greenwave response? + // if (isGreenwaveState(test)) return; if (isKaiState(test)) { - return extractCotactFromUmb(test); + _.merge(contact, extractContactFromUmb(test)); + metadataContact = test.custom_metadata?.payload?.contact; } if (isGreenwaveKaiState(test)) { - return extractCotactFromUmb(test.ks); + _.merge(contact, extractContactFromUmb(test.ks)); + metadataContact = test.ks.custom_metadata?.payload?.contact; + } + + // Merge in data from the `custom_metadata` Kai state field. + if (metadataContact?.docs) { + contact.docsUrl = metadataContact.docs; + } + if (metadataContact?.email) { + contact.email = metadataContact.email; + } + if (metadataContact?.gchat_room_url) { + contact.gchatRoomUrl = metadataContact.gchat_room_url; } + if (metadataContact?.name) { + contact.name = metadataContact.name; + } + if (metadataContact?.report_issue_url) { + contact.reportIssueUrl = metadataContact.report_issue_url; + } + if (metadataContact?.team) { + contact.team = metadataContact.team; + } + if (metadataContact?.url) { + contact.url = metadataContact.url; + } + + return contact; } // TODO: This function is temporary only and will be removed once the UI is finalized. @@ -185,6 +214,13 @@ function transformTest( ) { status = transformGreenwaveOutcome(test.gs.result.outcome); } else if (isGreenwaveKaiState(test) && stateName === 'additional-tests') { + /* + * TODO: For some osci and baseos-ci tests, this will return `failed` + * even if the failure is in infrastructure. The message is sent to + * `/topic/VirtualTopic.eng.ci.osci.brew-build.test.error` and has + * `error.reason`, but `test.result === 'failed'`. For an example, see + * https://datagrepper.engineering.redhat.com/id?id=ID:osci-jenkins-master-0-43277-1681457299489-309:1:1:1:1&is_raw=true&size=extra-large + */ status = transformUmbStatus(getKaiExtendedStatus(test.ks)); }