@@ -7,7 +7,8 @@ const vstsURL = 'https://github.visualstudio.com/electron/_apis/build'
77
88const appVeyorJobs = {
99 'electron-x64' : 'electron-x64-release' ,
10- 'electron-ia32' : 'electron-ia32-release'
10+ 'electron-ia32' : 'electron-ia32-release' ,
11+ 'electron-woa' : 'electron-woa-release'
1112}
1213
1314const circleCIJobs = [
@@ -25,6 +26,9 @@ const vstsArmJobs = [
2526 'electron-woa-testing'
2627]
2728
29+ let jobRequestedCount = 0
30+ let jobSuccessfulCount = 0
31+
2832async function makeRequest ( requestOptions , parseResponse ) {
2933 return new Promise ( ( resolve , reject ) => {
3034 request ( requestOptions , ( err , res , body ) => {
@@ -63,7 +67,7 @@ async function circleCIcall (buildUrl, targetBranch, job, options) {
6367 if ( ! options . ghRelease ) {
6468 buildRequest . build_parameters . UPLOAD_TO_S3 = 1
6569 }
66-
70+ jobRequestedCount ++
6771 const circleResponse = await makeRequest ( {
6872 method : 'POST' ,
6973 url : buildUrl ,
@@ -75,16 +79,19 @@ async function circleCIcall (buildUrl, targetBranch, job, options) {
7579 } , true ) . catch ( err => {
7680 console . log ( 'Error calling CircleCI:' , err )
7781 } )
82+ jobSuccessfulCount ++
7883 console . log ( `CircleCI release build request for ${ job } successful. Check ${ circleResponse . build_url } for status.` )
7984}
8085
81- function buildAppVeyor ( targetBranch , options ) {
86+ async function buildAppVeyor ( targetBranch , options ) {
8287 const validJobs = Object . keys ( appVeyorJobs )
8388 if ( options . job ) {
8489 assert ( validJobs . includes ( options . job ) , `Unknown AppVeyor CI job name: ${ options . job } . Valid values are: ${ validJobs } .` )
85- callAppVeyor ( targetBranch , options . job , options )
90+ await callAppVeyor ( targetBranch , options . job , options )
8691 } else {
87- validJobs . forEach ( ( job ) => callAppVeyor ( targetBranch , job , options ) )
92+ const appVeyorCalls = [ ]
93+ validJobs . forEach ( ( job ) => appVeyorCalls . push ( callAppVeyor ( targetBranch , job , options ) ) )
94+ await Promise . all ( appVeyorCalls )
8895 }
8996}
9097
@@ -114,20 +121,24 @@ async function callAppVeyor (targetBranch, job, options) {
114121 } ) ,
115122 method : 'POST'
116123 }
124+ jobRequestedCount ++
117125 const appVeyorResponse = await makeRequest ( requestOpts , true ) . catch ( err => {
118126 console . log ( 'Error calling AppVeyor:' , err )
119127 } )
128+ jobSuccessfulCount ++
120129 const buildUrl = `https://ci.appveyor.com/project/electron-bot/${ appVeyorJobs [ job ] } /build/${ appVeyorResponse . version } `
121130 console . log ( `AppVeyor release build request for ${ job } successful. Check build status at ${ buildUrl } ` )
122131}
123132
124- function buildCircleCI ( targetBranch , options ) {
133+ async function buildCircleCI ( targetBranch , options ) {
125134 const circleBuildUrl = `https://circleci.com/api/v1.1/project/github/electron/electron/tree/${ targetBranch } ?circle-token=${ process . env . CIRCLE_TOKEN } `
126135 if ( options . job ) {
127136 assert ( circleCIJobs . includes ( options . job ) , `Unknown CircleCI job name: ${ options . job } . Valid values are: ${ circleCIJobs } .` )
128- circleCIcall ( circleBuildUrl , targetBranch , options . job , options )
137+ await circleCIcall ( circleBuildUrl , targetBranch , options . job , options )
129138 } else {
130- circleCIJobs . forEach ( ( job ) => circleCIcall ( circleBuildUrl , targetBranch , job , options ) )
139+ const circleCalls = [ ]
140+ circleCIJobs . forEach ( ( job ) => circleCalls . push ( circleCIcall ( circleBuildUrl , targetBranch , job , options ) ) )
141+ await Promise . all ( circleCalls )
131142 }
132143}
133144
@@ -167,7 +178,9 @@ async function buildVSTS (targetBranch, options) {
167178 console . log ( 'Error calling VSTS to get build definitions:' , err )
168179 } )
169180 const buildsToRun = vstsResponse . value . filter ( build => build . name === options . job )
170- buildsToRun . forEach ( ( build ) => callVSTSBuild ( build , targetBranch , environmentVariables ) )
181+ const vstsJobs = [ ]
182+ buildsToRun . forEach ( ( build ) => vstsJobs . push ( callVSTSBuild ( build , targetBranch , environmentVariables ) ) )
183+ await Promise . all ( vstsJobs )
171184}
172185
173186async function callVSTSBuild ( build , targetBranch , environmentVariables ) {
@@ -191,25 +204,27 @@ async function callVSTSBuild (build, targetBranch, environmentVariables) {
191204 body : JSON . stringify ( buildBody ) ,
192205 method : 'POST'
193206 }
207+ jobRequestedCount ++
194208 const vstsResponse = await makeRequest ( requestOpts , true ) . catch ( err => {
195209 console . log ( `Error calling VSTS for job ${ build . name } ` , err )
196210 } )
211+ jobSuccessfulCount ++
197212 console . log ( `VSTS release build request for ${ build . name } successful. Check ${ vstsResponse . _links . web . href } for status.` )
198213}
199214
200- function runRelease ( targetBranch , options ) {
215+ async function runRelease ( targetBranch , options ) {
201216 if ( options . ci ) {
202217 switch ( options . ci ) {
203218 case 'CircleCI' : {
204- buildCircleCI ( targetBranch , options )
219+ await buildCircleCI ( targetBranch , options )
205220 break
206221 }
207222 case 'AppVeyor' : {
208- buildAppVeyor ( targetBranch , options )
223+ await buildAppVeyor ( targetBranch , options )
209224 break
210225 }
211226 case 'VSTS' : {
212- buildVSTS ( targetBranch , options )
227+ await buildVSTS ( targetBranch , options )
213228 break
214229 }
215230 default : {
@@ -218,10 +233,13 @@ function runRelease (targetBranch, options) {
218233 }
219234 }
220235 } else {
221- buildCircleCI ( targetBranch , options )
222- buildAppVeyor ( targetBranch , options )
223- buildVSTS ( targetBranch , options )
236+ const jobQueue = [ ]
237+ jobQueue . push ( buildCircleCI ( targetBranch , options ) )
238+ jobQueue . push ( buildAppVeyor ( targetBranch , options ) )
239+ jobQueue . push ( buildVSTS ( targetBranch , options ) )
240+ await Promise . all ( jobQueue )
224241 }
242+ console . log ( `${ jobRequestedCount } jobs were requested. ${ jobSuccessfulCount } succeeded.` )
225243}
226244
227245module . exports = runRelease
0 commit comments