1313const fs = require ( "fs" ) ;
1414
1515const { findSingleMatchingFile } = require ( "./shared/fs-utils" ) ;
16- const {
17- parseGinkgoOutput,
18- parseGinkgoReport,
19- } = require ( "./shared/ginkgo-report-utils" ) ;
16+ const { parseGinkgoOutput, parseGinkgoReport } = require ( "./shared/ginkgo-report-utils" ) ;
2017const {
2118 archivedReportPattern,
2219 buildClusterStatus,
@@ -69,11 +66,11 @@ const {
6966 */
7067
7168const workflowStages = [
72- { name : "bootstrap" , displayName : "Bootstrap cluster" , needsJobId : "bootstrap" } ,
73- { name : "configure-sdn" , displayName : "Configure SDN" , needsJobId : "configure-sdn" } ,
74- { name : "storage-setup" , displayName : "Configure storage" , needsJobId : "configure-storage" } ,
69+ { name : "bootstrap" , displayName : "Bootstrap cluster" , needsJobId : "bootstrap" } ,
70+ { name : "configure-sdn" , displayName : "Configure SDN" , needsJobId : "configure-sdn" } ,
71+ { name : "storage-setup" , displayName : "Configure storage" , needsJobId : "configure-storage" } ,
7572 { name : "virtualization-setup" , displayName : "Configure Virtualization" , needsJobId : "configure-virtualization" } ,
76- { name : "e2e-test" , displayName : "E2E test" , needsJobId : "e2e-test" } ,
73+ { name : "e2e-test" , displayName : "E2E test" , needsJobId : "e2e-test" } ,
7774] ;
7875
7976function readClusterReportConfigFromEnv ( env = process . env ) {
@@ -238,11 +235,7 @@ const ginkgoOutputSource = {
238235 * @returns {string|null } Path to the source file, or null when none exists.
239236 */
240237function findGinkgoSource ( config , source ) {
241- return findSingleMatchingFile (
242- config . reportsDir ,
243- source . pattern ( config . storageType ) ,
244- source . label
245- ) ;
238+ return findSingleMatchingFile ( config . reportsDir , source . pattern ( config . storageType ) , source . label ) ;
246239}
247240
248241/**
@@ -276,38 +269,21 @@ function parseGinkgoFile(filePath, core, source) {
276269 source : source . okSource ,
277270 } ;
278271 } catch ( error ) {
279- core . warning (
280- `Unable to parse ${ source . label } ${ filePath } : ${ error . message } `
281- ) ;
272+ core . warning ( `Unable to parse ${ source . label } ${ filePath } : ${ error . message } ` ) ;
282273 return emptyParsedReport ( source . invalidSource ) ;
283274 }
284275}
285276
286- function buildReportPayload ( {
287- config,
288- context,
289- fallbackWorkflowRunUrl,
290- branchName,
291- parsedReport,
292- sourcePath,
293- } ) {
277+ function buildReportPayload ( { config, context, fallbackWorkflowRunUrl, branchName, parsedReport, sourcePath } ) {
294278 const clusterStatus = buildClusterStatus ( config . stageResults ) ;
295279 const testStatus = buildTestStatus (
296280 config . stageResults [ "e2e-test" ] ,
297281 parsedReport . source ,
298282 clusterStatus ,
299283 parsedReport . metrics
300284 ) ;
301- const reportSummary = buildReportSummary (
302- config . storageType ,
303- clusterStatus ,
304- testStatus
305- ) ;
306- const workflowRunUrl = getReportJobUrl (
307- reportSummary ,
308- config . stageJobUrls ,
309- fallbackWorkflowRunUrl
310- ) ;
285+ const reportSummary = buildReportSummary ( config . storageType , clusterStatus , testStatus ) ;
286+ const workflowRunUrl = getReportJobUrl ( reportSummary , config . stageJobUrls , fallbackWorkflowRunUrl ) ;
311287
312288 return {
313289 schemaVersion : 1 ,
@@ -335,11 +311,7 @@ function buildReportPayload({
335311 } ;
336312}
337313
338- function getReportJobUrl (
339- reportSummary ,
340- stageJobUrls = { } ,
341- fallbackWorkflowRunUrl
342- ) {
314+ function getReportJobUrl ( reportSummary , stageJobUrls = { } , fallbackWorkflowRunUrl ) {
343315 if ( reportSummary . failedStage && stageJobUrls [ reportSummary . failedStage ] ) {
344316 return stageJobUrls [ reportSummary . failedStage ] ;
345317 }
@@ -377,29 +349,20 @@ function setReportOutputs(report, reportFile, core) {
377349 * @throws {Error } If config is incomplete or the report file cannot be written.
378350 */
379351async function buildClusterReport ( { core, context, github, config } = { } ) {
380- const resolvedConfig = requireClusterReportConfig (
381- config || readClusterReportConfigFromEnv ( )
382- ) ;
352+ const resolvedConfig = requireClusterReportConfig ( config || readClusterReportConfigFromEnv ( ) ) ;
383353
384354 if ( ! resolvedConfig . stageResults ) {
385355 resolvedConfig . stageResults = readStageResultsFromEnv ( ) ;
386356 }
387357
388358 if ( ! resolvedConfig . stageJobUrls && github ) {
389- resolvedConfig . stageJobUrls = await readStageJobUrlsFromApi (
390- github ,
391- context ,
392- resolvedConfig ,
393- core
394- ) ;
359+ resolvedConfig . stageJobUrls = await readStageJobUrlsFromApi ( github , context , resolvedConfig , core ) ;
395360 }
396361
397362 const fallbackWorkflowRunUrl = getWorkflowRunUrl ( context ) ;
398363 const branchName = getBranchName ( context ) ;
399364 const rawReportPath = findGinkgoSource ( resolvedConfig , ginkgoJsonSource ) ;
400- const outputPath = rawReportPath
401- ? null
402- : findGinkgoSource ( resolvedConfig , ginkgoOutputSource ) ;
365+ const outputPath = rawReportPath ? null : findGinkgoSource ( resolvedConfig , ginkgoOutputSource ) ;
403366 const sourcePath = rawReportPath || outputPath ;
404367 const sourceDescriptor = rawReportPath ? ginkgoJsonSource : ginkgoOutputSource ;
405368
@@ -420,14 +383,9 @@ async function buildClusterReport({ core, context, github, config } = {}) {
420383 } ) ;
421384
422385 try {
423- fs . writeFileSync (
424- resolvedConfig . reportFile ,
425- `${ JSON . stringify ( report , null , 2 ) } \n`
426- ) ;
386+ fs . writeFileSync ( resolvedConfig . reportFile , `${ JSON . stringify ( report , null , 2 ) } \n` ) ;
427387 } catch ( error ) {
428- throw new Error (
429- `Unable to write cluster report file ${ resolvedConfig . reportFile } : ${ error . message } `
430- ) ;
388+ throw new Error ( `Unable to write cluster report file ${ resolvedConfig . reportFile } : ${ error . message } ` ) ;
431389 }
432390
433391 setReportOutputs ( report , resolvedConfig . reportFile , core ) ;
0 commit comments