File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ const runJobs = async () => {
74
74
75
75
// Find jobs that can be started, because their needed jobs have finished
76
76
for ( const job of jobs ) {
77
- if ( job . isRunning ( ) || job . isFinished ( ) || job . needs . length === 0 ) {
77
+ if ( job . isRunning ( ) || job . isFinished ( ) || job . needs === null ) {
78
78
continue ;
79
79
}
80
80
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ if (process.env.EXEPATH) {
17
17
18
18
export class Job {
19
19
public readonly name : string ;
20
- public readonly needs : string [ ] ;
20
+ public readonly needs : string [ ] | null ;
21
21
public readonly stage : string ;
22
22
23
23
private readonly afterScripts : string [ ] = [ ] ;
@@ -72,11 +72,7 @@ export class Job {
72
72
this . afterScripts = [ ] . concat ( jobData . after_script || ciDefault . after_script || globals . after_script || [ ] ) ;
73
73
this . allowFailure = jobData . allow_failure || false ;
74
74
this . variables = jobData . variables || { } ;
75
- if ( this . needs && this . needs . length === 0 ) {
76
- console . error ( `${ jobNameStr } ${ c . red ( "'needs' cannot be empty array" ) } ` ) ;
77
- process . exit ( 1 ) ;
78
- }
79
- this . needs = jobData . needs || [ ] ;
75
+ this . needs = jobData . needs || null ;
80
76
}
81
77
82
78
public getJobNameString ( ) {
Original file line number Diff line number Diff line change @@ -102,6 +102,8 @@ export class Parser {
102
102
103
103
this . jobs . set ( key , job ) ;
104
104
}
105
+
106
+ this . validateNeedsTags ( ) ;
105
107
}
106
108
107
109
public getJobs ( ) : ReadonlyMap < string , Job > {
@@ -111,4 +113,18 @@ export class Parser {
111
113
public getStages ( ) : ReadonlyMap < string , Stage > {
112
114
return this . stages ;
113
115
}
116
+
117
+ private validateNeedsTags ( ) {
118
+ const jobNames = Array . from ( this . jobs . values ( ) ) . map ( ( j ) => j . name ) ;
119
+ for ( const job of this . jobs . values ( ) ) {
120
+ if ( job . needs === null || job . needs . length === 0 ) {
121
+ continue ;
122
+ }
123
+
124
+ if ( job . needs . filter ( ( v ) => ( jobNames . indexOf ( v ) >= 0 ) ) . length !== job . needs . length ) {
125
+ console . error ( `${ c . blueBright ( `${ job . name } ` ) } needs list contains unspecified jobs.` ) ;
126
+ process . exit ( 1 ) ;
127
+ }
128
+ }
129
+ }
114
130
}
Original file line number Diff line number Diff line change 5
5
],
6
6
"jsRules" : {},
7
7
"rules" : {
8
+ "no-null-keyword" : false ,
8
9
"no-magic-numbers" : false ,
9
10
"strict-boolean-expressions" : false ,
10
11
"newline-per-chained-call" : false ,
You can’t perform that action at this time.
0 commit comments