@@ -77,7 +77,7 @@ export class CdkCliIntegTestsWorkflow extends Component {
77
77
super ( repo ) ;
78
78
79
79
const buildWorkflow = repo . buildWorkflow ;
80
- const runTestsWorkflow = repo . github ?. addWorkflow ( 'build-and- integ' ) ;
80
+ const runTestsWorkflow = repo . github ?. addWorkflow ( 'integ' ) ;
81
81
if ( ! buildWorkflow || ! runTestsWorkflow ) {
82
82
throw new Error ( 'Expected build and run tests workflow' ) ;
83
83
}
@@ -98,7 +98,7 @@ export class CdkCliIntegTestsWorkflow extends Component {
98
98
// - The build job is only one job, versus the tests which are a matrix build.
99
99
// If the matrix test job needs approval, the Pull Request timeline gets spammed
100
100
// with an approval request for every individual run.
101
- runTestsWorkflow . addJob ( 'build ' , {
101
+ runTestsWorkflow . addJob ( 'prepare ' , {
102
102
environment : props . approvalEnvironment ,
103
103
runsOn : [ props . buildRunsOn ] ,
104
104
permissions : {
@@ -178,10 +178,13 @@ export class CdkCliIntegTestsWorkflow extends Component {
178
178
proxy : 'npmjs' ,
179
179
} ;
180
180
181
- runTestsWorkflow . addJob ( 'integ' , {
181
+ // We create a matrix job for the test.
182
+ // This job will run all the different test suites in parallel.
183
+ const JOB_INTEG_MATRIX = 'integ_matrix' ;
184
+ runTestsWorkflow . addJob ( JOB_INTEG_MATRIX , {
182
185
environment : props . testEnvironment ,
183
186
runsOn : [ props . testRunsOn ] ,
184
- needs : [ 'build ' ] ,
187
+ needs : [ 'prepare ' ] ,
185
188
permissions : {
186
189
contents : github . workflows . JobPermission . READ ,
187
190
idToken : github . workflows . JobPermission . WRITE ,
@@ -331,5 +334,27 @@ export class CdkCliIntegTestsWorkflow extends Component {
331
334
} ,
332
335
] ,
333
336
} ) ;
337
+
338
+ // Add a job that collates all matrix jobs into a single status
339
+ // This is required so that we can setup required status checks
340
+ // and if we ever change the test matrix, we don't need to update
341
+ // the status check configuration.
342
+ runTestsWorkflow . addJob ( 'integ' , {
343
+ permissions : { } ,
344
+ runsOn : [ props . testRunsOn ] ,
345
+ needs : [ JOB_INTEG_MATRIX ] ,
346
+ if : 'always()' ,
347
+ steps : [
348
+ {
349
+ name : 'Integ test result' ,
350
+ run : `echo \${{ needs.${ JOB_INTEG_MATRIX } .result }}` ,
351
+ } ,
352
+ {
353
+ if : `\${{ needs.${ JOB_INTEG_MATRIX } .result != 'success' }}` ,
354
+ name : 'Set status based on matrix job' ,
355
+ run : 'exit 1' ,
356
+ } ,
357
+ ] ,
358
+ } ) ;
334
359
}
335
360
}
0 commit comments