@@ -7,7 +7,8 @@ const vstsURL = 'https://github.visualstudio.com/electron/_apis/build'
7
7
8
8
const appVeyorJobs = {
9
9
'electron-x64' : 'electron-x64-release' ,
10
- 'electron-ia32' : 'electron-ia32-release'
10
+ 'electron-ia32' : 'electron-ia32-release' ,
11
+ 'electron-woa' : 'electron-woa-release'
11
12
}
12
13
13
14
const circleCIJobs = [
@@ -25,6 +26,9 @@ const vstsArmJobs = [
25
26
'electron-woa-testing'
26
27
]
27
28
29
+ let jobRequestedCount = 0
30
+ let jobSuccessfulCount = 0
31
+
28
32
async function makeRequest ( requestOptions , parseResponse ) {
29
33
return new Promise ( ( resolve , reject ) => {
30
34
request ( requestOptions , ( err , res , body ) => {
@@ -63,7 +67,7 @@ async function circleCIcall (buildUrl, targetBranch, job, options) {
63
67
if ( ! options . ghRelease ) {
64
68
buildRequest . build_parameters . UPLOAD_TO_S3 = 1
65
69
}
66
-
70
+ jobRequestedCount ++
67
71
const circleResponse = await makeRequest ( {
68
72
method : 'POST' ,
69
73
url : buildUrl ,
@@ -75,16 +79,19 @@ async function circleCIcall (buildUrl, targetBranch, job, options) {
75
79
} , true ) . catch ( err => {
76
80
console . log ( 'Error calling CircleCI:' , err )
77
81
} )
82
+ jobSuccessfulCount ++
78
83
console . log ( `CircleCI release build request for ${ job } successful. Check ${ circleResponse . build_url } for status.` )
79
84
}
80
85
81
- function buildAppVeyor ( targetBranch , options ) {
86
+ async function buildAppVeyor ( targetBranch , options ) {
82
87
const validJobs = Object . keys ( appVeyorJobs )
83
88
if ( options . job ) {
84
89
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 )
86
91
} 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 )
88
95
}
89
96
}
90
97
@@ -114,20 +121,24 @@ async function callAppVeyor (targetBranch, job, options) {
114
121
} ) ,
115
122
method : 'POST'
116
123
}
124
+ jobRequestedCount ++
117
125
const appVeyorResponse = await makeRequest ( requestOpts , true ) . catch ( err => {
118
126
console . log ( 'Error calling AppVeyor:' , err )
119
127
} )
128
+ jobSuccessfulCount ++
120
129
const buildUrl = `https://ci.appveyor.com/project/electron-bot/${ appVeyorJobs [ job ] } /build/${ appVeyorResponse . version } `
121
130
console . log ( `AppVeyor release build request for ${ job } successful. Check build status at ${ buildUrl } ` )
122
131
}
123
132
124
- function buildCircleCI ( targetBranch , options ) {
133
+ async function buildCircleCI ( targetBranch , options ) {
125
134
const circleBuildUrl = `https://circleci.com/api/v1.1/project/github/electron/electron/tree/${ targetBranch } ?circle-token=${ process . env . CIRCLE_TOKEN } `
126
135
if ( options . job ) {
127
136
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 )
129
138
} 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 )
131
142
}
132
143
}
133
144
@@ -167,7 +178,9 @@ async function buildVSTS (targetBranch, options) {
167
178
console . log ( 'Error calling VSTS to get build definitions:' , err )
168
179
} )
169
180
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 )
171
184
}
172
185
173
186
async function callVSTSBuild ( build , targetBranch , environmentVariables ) {
@@ -191,25 +204,27 @@ async function callVSTSBuild (build, targetBranch, environmentVariables) {
191
204
body : JSON . stringify ( buildBody ) ,
192
205
method : 'POST'
193
206
}
207
+ jobRequestedCount ++
194
208
const vstsResponse = await makeRequest ( requestOpts , true ) . catch ( err => {
195
209
console . log ( `Error calling VSTS for job ${ build . name } ` , err )
196
210
} )
211
+ jobSuccessfulCount ++
197
212
console . log ( `VSTS release build request for ${ build . name } successful. Check ${ vstsResponse . _links . web . href } for status.` )
198
213
}
199
214
200
- function runRelease ( targetBranch , options ) {
215
+ async function runRelease ( targetBranch , options ) {
201
216
if ( options . ci ) {
202
217
switch ( options . ci ) {
203
218
case 'CircleCI' : {
204
- buildCircleCI ( targetBranch , options )
219
+ await buildCircleCI ( targetBranch , options )
205
220
break
206
221
}
207
222
case 'AppVeyor' : {
208
- buildAppVeyor ( targetBranch , options )
223
+ await buildAppVeyor ( targetBranch , options )
209
224
break
210
225
}
211
226
case 'VSTS' : {
212
- buildVSTS ( targetBranch , options )
227
+ await buildVSTS ( targetBranch , options )
213
228
break
214
229
}
215
230
default : {
@@ -218,10 +233,13 @@ function runRelease (targetBranch, options) {
218
233
}
219
234
}
220
235
} 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 )
224
241
}
242
+ console . log ( `${ jobRequestedCount } jobs were requested. ${ jobSuccessfulCount } succeeded.` )
225
243
}
226
244
227
245
module . exports = runRelease
0 commit comments