@@ -143,6 +143,22 @@ class Job {
143143 . replace ( / \/ / g, '-' )
144144 . replace ( / - $ / , '' ) ;
145145 }
146+
147+ async parseConsoleText ( ) {
148+ const text = await this . getConsoleText ( ) ;
149+ const parser = new CIFailureParser ( this , text ) ;
150+ const results = parser . parse ( ) ;
151+
152+ if ( results ) {
153+ this . failures = results ;
154+ return results ;
155+ }
156+
157+ this . failures = [
158+ new CIResult ( { url : this . jobUrl , builtOn : this . builtOn } , 'Unknown' )
159+ ] ;
160+ return this . failures ;
161+ }
146162}
147163
148164const jobCache = new Cache ( ) ;
@@ -353,10 +369,16 @@ class CommitBuild extends TestBuild {
353369 }
354370
355371 const { result, builds } = this . getBuilds ( data ) ;
356- if ( result === SUCCESS || ! builds . failed . length ) {
372+
373+ if ( result !== FAILURE ) {
357374 return { result, builds, failures : [ ] } ;
358375 }
359376
377+ if ( ! builds . failed . length ) {
378+ const failures = await this . parseConsoleText ( ) ;
379+ return { result, builds, failures } ;
380+ }
381+
360382 cli . startSpinner ( `Querying failures of ${ path } ` ) ;
361383 const promises = builds . failed . map ( ( { jobName, buildNumber, url} ) => {
362384 if ( jobName . includes ( 'fanned' ) ) {
@@ -496,7 +518,13 @@ class FannedBuild extends Job {
496518 ] ;
497519 return this . failures ;
498520 }
521+
499522 const failedPhase = data . subBuilds . find ( build => build . result === FAILURE ) ;
523+
524+ if ( ! failedPhase ) {
525+ return this . parseConsoleText ( ) ;
526+ }
527+
500528 if ( failedPhase . phaseName !== TEST_PHASE &&
501529 ! failedPhase . phaseName . toLowerCase ( ) . includes ( 'compilation' ) ) {
502530 this . failures = [
@@ -528,20 +556,8 @@ class LinterBuild extends Job {
528556
529557 async getResults ( ) {
530558 const data = await this . getAPIData ( ) ;
531- const builtOn = this . builtOn = data . builtOn ;
532- const text = await this . getConsoleText ( ) ;
533- const parser = new CIFailureParser ( this , text ) ;
534- const results = parser . parse ( ) ;
535- // TODO: add linter failure type
536- if ( results ) {
537- this . failures = results ;
538- return results ;
539- }
540-
541- this . failures = [
542- new CIResult ( { url : this . jobUrl , builtOn } , 'Unknown' )
543- ] ;
544- return this . failures ;
559+ this . builtOn = data . builtOn ;
560+ return this . parseConsoleText ( ) ;
545561 }
546562}
547563
@@ -565,7 +581,7 @@ class NormalBuild extends Job {
565581 return this . failures ;
566582 }
567583
568- if ( result === FAILURE && ! ( runs . length ) ) {
584+ if ( ! runs . length ) {
569585 this . failures = [
570586 new BuildFailure (
571587 { url : this . jobUrl , builtOn } , 'Failed to trigger runs'
@@ -575,6 +591,11 @@ class NormalBuild extends Job {
575591 }
576592
577593 const failed = runs . filter ( run => run . result === FAILURE ) ;
594+
595+ if ( ! failed . length ) {
596+ return this . parseConsoleText ( ) ;
597+ }
598+
578599 const tests = failed . map ( ( { url } ) => new TestRun ( cli , request , url ) ) ;
579600
580601 // Skip runs that are not actually triggered by this job
@@ -618,18 +639,7 @@ class TestRun extends Job {
618639 }
619640
620641 async getResults ( ) {
621- const text = await this . getConsoleText ( ) ;
622- const parser = new CIFailureParser ( this , text ) ;
623- const results = parser . parse ( ) ;
624- if ( results ) {
625- this . failures = results ;
626- return results ;
627- }
628-
629- this . failures = [
630- new CIResult ( { url : this . jobUrl , builtOn : this . builtOn } , 'Unknown' )
631- ] ;
632- return this . failures ;
642+ return this . parseConsoleText ( ) ;
633643 }
634644}
635645
0 commit comments