@@ -628,8 +628,7 @@ export async function runQaLabSelfCheckCommand(opts: QaLabSelfCheckCommandOption
628628}
629629
630630export async function runQaProfileCommand ( opts : QaProfileCommandOptions ) {
631- const evidencePath = await runQaSuiteEvidenceLifecycle ( opts , async ( resolved ) => {
632- const { repoRoot, outputDir, target } = resolved ;
631+ await runQaSuiteEvidenceLifecycle ( opts , async ( { repoRoot, outputDir } ) => {
633632 const scenarioPack = readQaScenarioPack ( ) ;
634633 const scorecardReport = readQaScorecardTaxonomyReport ( scenarioPack . scenarios ) ;
635634 const profile = normalizeQaRunProfile (
@@ -720,10 +719,10 @@ export async function runQaProfileCommand(opts: QaProfileCommandOptions) {
720719 process . stdout . write (
721720 `QA run profile: ${ profile } ; categories: ${ categories . length } ; scenarios: ${ scenarios . length } \n` ,
722721 ) ;
723- let expectedCells : QaProfileEvidencePlan [ "expectedCells" ] = [ ] ;
724- let observedCells : QaProfileEvidencePlan [ "observedCells" ] = [ ] ;
725- await withTemporaryQaProfileEnv ( profile , async ( ) => {
726- const suiteResult = await runQaSuiteCommandCore (
722+ let suiteCompletion : Awaited < ReturnType < typeof runQaSuiteCore > > | undefined ;
723+ let commandCompletion : ( ( ) => Promise < void > ) | undefined ;
724+ const suiteResult = await withTemporaryQaProfileEnv ( profile , async ( ) =>
725+ runQaSuiteCommandCore (
727726 {
728727 repoRoot,
729728 outputDir : opts . outputDir ,
@@ -741,35 +740,50 @@ export async function runQaProfileCommand(opts: QaProfileCommandOptions) {
741740 channelDriver : profileReport . channelDriver ,
742741 expandScenarioChannels : true ,
743742 } ,
744- ( params ) => runQaSuiteCore ( { ...params , outputDir } , target ) ,
745- ) ;
746- expectedCells =
747- suiteResult && "expectedCells" in suiteResult ? suiteResult . expectedCells : [ ] ;
748- observedCells =
749- suiteResult && "observedCells" in suiteResult ? suiteResult . observedCells : [ ] ;
750- } ) ;
743+ async ( params ) => {
744+ suiteCompletion = await runQaSuiteCore ( { ...params , repoRoot, outputDir } ) ;
745+ return suiteCompletion . result ;
746+ } ,
747+ ( complete ) => {
748+ commandCompletion = complete ;
749+ } ,
750+ ) ,
751+ ) ;
751752 const profilePlan = qaProfileEvidencePlan . build ( {
752753 profile,
753754 membershipScenarios : taxonomyScenarios ,
754755 selectedScenarios : scenarios ,
755756 excludedScenarios : executionSelection . excludedScenarios ,
756- expectedCells,
757- observedCells,
757+ expectedCells : suiteResult ?. expectedCells ?? [ ] ,
758+ observedCells : suiteResult ?. observedCells ?? [ ] ,
758759 } ) ;
759- await attachQaProfileScorecardEvidenceToFile ( {
760- evidencePath : target . stagedPath ,
761- evidenceMode : opts . evidenceMode ,
762- profile,
763- profilePlan,
764- filters : {
765- surface : opts . surface ,
766- category : opts . category ,
760+ const completion = suiteCompletion ;
761+ const completeCommand = commandCompletion ;
762+ if ( ! completion || ! completeCommand ) {
763+ throw new Error ( "QA profile suite completed without deferred publication state" ) ;
764+ }
765+ return Object . freeze ( {
766+ evidence : completion . evidence ,
767+ result : undefined ,
768+ transformStagedEvidence : ( stagedPath ) =>
769+ attachQaProfileScorecardEvidenceToFile ( {
770+ evidencePath : stagedPath ,
771+ evidenceMode : opts . evidenceMode ,
772+ profile,
773+ profilePlan,
774+ filters : {
775+ surface : opts . surface ,
776+ category : opts . category ,
777+ } ,
778+ categories,
779+ } ) ,
780+ complete : async ( ) => {
781+ await completion . complete ( ) ;
782+ await completeCommand ( ) ;
783+ process . stdout . write ( `QA profile scorecard: ${ path . join ( outputDir , "qa-evidence.json" ) } \n` ) ;
767784 } ,
768- categories,
769785 } ) ;
770- return target . canonicalPath ;
771786 } ) ;
772- process . stdout . write ( `QA profile scorecard: ${ evidencePath } \n` ) ;
773787}
774788
775789function selectQaScenarioDefinitionsForChannelResolution ( params : {
@@ -863,6 +877,7 @@ async function runQaSuiteCommandCore(
863877 runSuite : (
864878 params : NonNullable < Parameters < typeof runQaSuite > [ 0 ] > ,
865879 ) => ReturnType < typeof runQaSuite > ,
880+ deferCompletion ?: ( complete : ( ) => Promise < void > ) => void ,
866881) {
867882 const repoRoot = path . resolve ( opts . repoRoot ?? process . cwd ( ) ) ;
868883 const transportId = normalizeQaTransportId ( opts . transportId ) ;
@@ -1086,58 +1101,38 @@ async function runQaSuiteCommandCore(
10861101 : { } ) ,
10871102 ...( runtimePair ? { runtimePair } : { } ) ,
10881103 } ) ;
1089- switch ( runtimeResult . executionKind ) {
1090- case "suite" : {
1091- const result = runtimeResult . result ;
1092- process . stdout . write ( `QA suite report: ${ result . reportPath } \n` ) ;
1093- process . stdout . write ( `QA suite evidence: ${ result . evidencePath } \n` ) ;
1094- process . stdout . write ( `QA suite summary: ${ result . summaryPath } \n` ) ;
1095- const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile (
1096- result . summaryPath ,
1097- {
1098- optionalScenarioNames : resolveQaReportOnlyOptionalScenarioNames ( {
1099- scenarioIds,
1100- explicitScenarioSelection : opts . explicitScenarioSelection ,
1101- } ) ,
1102- requireExecutedScenario : allowFailures ,
1103- } ,
1104- ) ;
1105- if ( ! allowFailures && blockingScenarioCount > 0 ) {
1106- process . exitCode = 1 ;
1107- }
1108- return {
1109- ...result ,
1110- expectedCells : runtimeResult . expectedCells ,
1111- observedCells : runtimeResult . observedCells ,
1112- } ;
1104+ const result = runtimeResult . result ;
1105+ const complete = async ( ) => {
1106+ if ( runtimeResult . executionKind === "flow" ) {
1107+ process . stdout . write ( `QA suite watch: ${ runtimeResult . result . watchUrl } \n` ) ;
11131108 }
1114- case "flow" : {
1115- const result = runtimeResult . result ;
1116- process . stdout . write ( `QA suite watch: ${ result . watchUrl } \n` ) ;
1117- process . stdout . write ( `QA suite report: ${ result . reportPath } \n` ) ;
1118- process . stdout . write ( `QA suite evidence: ${ result . evidencePath } \n` ) ;
1119- process . stdout . write ( `QA suite summary: ${ result . summaryPath } \n` ) ;
1120- const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile (
1121- result . summaryPath ,
1122- {
1123- optionalScenarioNames : resolveQaReportOnlyOptionalScenarioNames ( {
1124- scenarioIds,
1125- explicitScenarioSelection : opts . explicitScenarioSelection ,
1126- } ) ,
1127- requireExecutedScenario : allowFailures ,
1128- } ,
1129- ) ;
1130- if ( ! allowFailures && blockingScenarioCount > 0 ) {
1131- process . exitCode = 1 ;
1132- }
1133- return {
1134- ...result ,
1135- expectedCells : runtimeResult . expectedCells ,
1136- observedCells : runtimeResult . observedCells ,
1137- } ;
1109+ process . stdout . write ( `QA suite report: ${ result . reportPath } \n` ) ;
1110+ process . stdout . write ( `QA suite evidence: ${ result . evidencePath } \n` ) ;
1111+ process . stdout . write ( `QA suite summary: ${ result . summaryPath } \n` ) ;
1112+ const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile (
1113+ result . summaryPath ,
1114+ {
1115+ optionalScenarioNames : resolveQaReportOnlyOptionalScenarioNames ( {
1116+ scenarioIds,
1117+ explicitScenarioSelection : opts . explicitScenarioSelection ,
1118+ } ) ,
1119+ requireExecutedScenario : allowFailures ,
1120+ } ,
1121+ ) ;
1122+ if ( ! allowFailures && blockingScenarioCount > 0 ) {
1123+ process . exitCode = 1 ;
11381124 }
1125+ } ;
1126+ if ( deferCompletion ) {
1127+ deferCompletion ( complete ) ;
1128+ } else {
1129+ await complete ( ) ;
11391130 }
1140- return undefined ;
1131+ return {
1132+ ...result ,
1133+ expectedCells : runtimeResult . expectedCells ,
1134+ observedCells : runtimeResult . observedCells ,
1135+ } ;
11411136}
11421137
11431138export async function runQaSuiteCommand ( opts : QaSuiteCommandOptions ) {
0 commit comments