Skip to content

Commit 41b32cf

Browse files
trop[bot]John Kleinschmidt
authored andcommitted
build: lengthen wait times and retries for CircleCI releases (electron#20893)
* build: lengthen wait times and retries for CircleCI releases * Review suggestions
1 parent 176f472 commit 41b32cf

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

script/release/ci-release-build.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ if (!process.env.CI) require('dotenv-safe').load()
22

33
const assert = require('assert')
44
const request = require('request')
5-
const buildAppVeyorURL = 'https://ci.appveyor.com/api/builds'
6-
const circleCIPipelineURL = 'https://circleci.com/api/v2/project/gh/electron/electron/pipeline'
7-
const vstsURL = 'https://github.visualstudio.com/electron/_apis/build'
5+
6+
const BUILD_APPVEYOR_URL = 'https://ci.appveyor.com/api/builds'
7+
const CIRCLECI_PIPELINE_URL = 'https://circleci.com/api/v2/project/gh/electron/electron/pipeline'
8+
const VSTS_URL = 'https://github.visualstudio.com/electron/_apis/build'
9+
const CIRCLECI_RETRY_LIMIT = 10
10+
const CIRCLECI_WAIT_TIME = 10000
811

912
const appVeyorJobs = {
1013
'electron-x64': 'electron-x64-release',
@@ -78,7 +81,7 @@ async function circleCIcall (targetBranch, job, options) {
7881
// If the workflows are changed in the CircleCI config.yml, this logic will
7982
// also need to be changed as well as possibly changing sudowoodo.
8083
try {
81-
const circleResponse = await circleCIRequest(circleCIPipelineURL, 'POST', buildRequest)
84+
const circleResponse = await circleCIRequest(CIRCLECI_PIPELINE_URL, 'POST', buildRequest)
8285
console.log(`CircleCI release build pipeline ${circleResponse.id} for ${job} triggered.`)
8386
const pipelineInfoUrl = `https://circleci.com/api/v2/pipeline/${circleResponse.id}`
8487
const workflowId = await getCircleCIWorkflowId(circleResponse.id)
@@ -99,7 +102,7 @@ async function circleCIcall (targetBranch, job, options) {
99102

100103
async function getCircleCIWorkflowId (pipelineId) {
101104
const pipelineInfoUrl = `https://circleci.com/api/v2/pipeline/${pipelineId}`
102-
for (let i = 0; i < 5; i++) {
105+
for (let i = 0; i < CIRCLECI_RETRY_LIMIT; i++) {
103106
const pipelineInfo = await circleCIRequest(pipelineInfoUrl, 'GET')
104107
switch (pipelineInfo.state) {
105108
case 'created': {
@@ -114,14 +117,15 @@ async function getCircleCIWorkflowId (pipelineId) {
114117
return -1
115118
}
116119
}
117-
await new Promise(resolve => setTimeout(resolve, 5000))
120+
await new Promise(resolve => setTimeout(resolve, CIRCLECI_WAIT_TIME))
118121
}
122+
console.log(`Error: could not get CircleCI WorkflowId for ${pipelineId} after ${CIRCLECI_RETRY_LIMIT} times.`)
119123
return -1
120124
}
121125

122126
async function getCircleCIJobNumber (workflowId) {
123127
const jobInfoUrl = `https://circleci.com/api/v2/workflow/${workflowId}/jobs`
124-
for (let i = 0; i < 5; i++) {
128+
for (let i = 0; i < CIRCLECI_RETRY_LIMIT; i++) {
125129
const jobInfo = await circleCIRequest(jobInfoUrl, 'GET')
126130
if (!jobInfo.items) {
127131
continue
@@ -145,8 +149,9 @@ async function getCircleCIJobNumber (workflowId) {
145149
return -1
146150
}
147151
}
148-
await new Promise(resolve => setTimeout(resolve, 5000))
152+
await new Promise(resolve => setTimeout(resolve, CIRCLECI_WAIT_TIME))
149153
}
154+
console.log(`Error: could not get CircleCI Job Number for ${workflowId} after ${CIRCLECI_RETRY_LIMIT} times.`)
150155
return -1
151156
}
152157

@@ -189,7 +194,7 @@ async function callAppVeyor (targetBranch, job, options) {
189194
}
190195

191196
const requestOpts = {
192-
url: buildAppVeyorURL,
197+
url: BUILD_APPVEYOR_URL,
193198
auth: {
194199
bearer: process.env.APPVEYOR_CLOUD_TOKEN
195200
},
@@ -244,7 +249,7 @@ async function buildVSTS (targetBranch, options) {
244249
}
245250

246251
const requestOpts = {
247-
url: `${vstsURL}/definitions?api-version=4.1`,
252+
url: `${VSTS_URL}/definitions?api-version=4.1`,
248253
auth: {
249254
user: '',
250255
password: process.env.VSTS_TOKEN
@@ -270,7 +275,7 @@ async function callVSTSBuild (build, targetBranch, environmentVariables) {
270275
buildBody.parameters = JSON.stringify(environmentVariables)
271276
}
272277
const requestOpts = {
273-
url: `${vstsURL}/builds?api-version=4.1`,
278+
url: `${VSTS_URL}/builds?api-version=4.1`,
274279
auth: {
275280
user: '',
276281
password: process.env.VSTS_TOKEN

0 commit comments

Comments
 (0)