build: lengthen wait times and retries for CircleCI releases (#20889)
* build: lengthen wait times and retries for CircleCI releases * Review suggestions
This commit is contained in:
parent
b060cbf4ec
commit
23ca7e3733
1 changed files with 16 additions and 11 deletions
|
@ -2,9 +2,12 @@ if (!process.env.CI) require('dotenv-safe').load()
|
||||||
|
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const request = require('request')
|
const request = require('request')
|
||||||
const buildAppVeyorURL = 'https://ci.appveyor.com/api/builds'
|
|
||||||
const circleCIPipelineURL = 'https://circleci.com/api/v2/project/gh/electron/electron/pipeline'
|
const BUILD_APPVEYOR_URL = 'https://ci.appveyor.com/api/builds'
|
||||||
const vstsURL = 'https://github.visualstudio.com/electron/_apis/build'
|
const CIRCLECI_PIPELINE_URL = 'https://circleci.com/api/v2/project/gh/electron/electron/pipeline'
|
||||||
|
const VSTS_URL = 'https://github.visualstudio.com/electron/_apis/build'
|
||||||
|
const CIRCLECI_RETRY_LIMIT = 10
|
||||||
|
const CIRCLECI_WAIT_TIME = 10000
|
||||||
|
|
||||||
const appVeyorJobs = {
|
const appVeyorJobs = {
|
||||||
'electron-x64': 'electron-x64-release',
|
'electron-x64': 'electron-x64-release',
|
||||||
|
@ -78,7 +81,7 @@ async function circleCIcall (targetBranch, job, options) {
|
||||||
// If the workflows are changed in the CircleCI config.yml, this logic will
|
// If the workflows are changed in the CircleCI config.yml, this logic will
|
||||||
// also need to be changed as well as possibly changing sudowoodo.
|
// also need to be changed as well as possibly changing sudowoodo.
|
||||||
try {
|
try {
|
||||||
const circleResponse = await circleCIRequest(circleCIPipelineURL, 'POST', buildRequest)
|
const circleResponse = await circleCIRequest(CIRCLECI_PIPELINE_URL, 'POST', buildRequest)
|
||||||
console.log(`CircleCI release build pipeline ${circleResponse.id} for ${job} triggered.`)
|
console.log(`CircleCI release build pipeline ${circleResponse.id} for ${job} triggered.`)
|
||||||
const pipelineInfoUrl = `https://circleci.com/api/v2/pipeline/${circleResponse.id}`
|
const pipelineInfoUrl = `https://circleci.com/api/v2/pipeline/${circleResponse.id}`
|
||||||
const workflowId = await getCircleCIWorkflowId(circleResponse.id)
|
const workflowId = await getCircleCIWorkflowId(circleResponse.id)
|
||||||
|
@ -99,7 +102,7 @@ async function circleCIcall (targetBranch, job, options) {
|
||||||
|
|
||||||
async function getCircleCIWorkflowId (pipelineId) {
|
async function getCircleCIWorkflowId (pipelineId) {
|
||||||
const pipelineInfoUrl = `https://circleci.com/api/v2/pipeline/${pipelineId}`
|
const pipelineInfoUrl = `https://circleci.com/api/v2/pipeline/${pipelineId}`
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < CIRCLECI_RETRY_LIMIT; i++) {
|
||||||
const pipelineInfo = await circleCIRequest(pipelineInfoUrl, 'GET')
|
const pipelineInfo = await circleCIRequest(pipelineInfoUrl, 'GET')
|
||||||
switch (pipelineInfo.state) {
|
switch (pipelineInfo.state) {
|
||||||
case 'created': {
|
case 'created': {
|
||||||
|
@ -114,14 +117,15 @@ async function getCircleCIWorkflowId (pipelineId) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000))
|
await new Promise(resolve => setTimeout(resolve, CIRCLECI_WAIT_TIME))
|
||||||
}
|
}
|
||||||
|
console.log(`Error: could not get CircleCI WorkflowId for ${pipelineId} after ${CIRCLECI_RETRY_LIMIT} times.`)
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCircleCIJobNumber (workflowId) {
|
async function getCircleCIJobNumber (workflowId) {
|
||||||
const jobInfoUrl = `https://circleci.com/api/v2/workflow/${workflowId}/jobs`
|
const jobInfoUrl = `https://circleci.com/api/v2/workflow/${workflowId}/jobs`
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < CIRCLECI_RETRY_LIMIT; i++) {
|
||||||
const jobInfo = await circleCIRequest(jobInfoUrl, 'GET')
|
const jobInfo = await circleCIRequest(jobInfoUrl, 'GET')
|
||||||
if (!jobInfo.items) {
|
if (!jobInfo.items) {
|
||||||
continue
|
continue
|
||||||
|
@ -145,8 +149,9 @@ async function getCircleCIJobNumber (workflowId) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000))
|
await new Promise(resolve => setTimeout(resolve, CIRCLECI_WAIT_TIME))
|
||||||
}
|
}
|
||||||
|
console.log(`Error: could not get CircleCI Job Number for ${workflowId} after ${CIRCLECI_RETRY_LIMIT} times.`)
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +194,7 @@ async function callAppVeyor (targetBranch, job, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestOpts = {
|
const requestOpts = {
|
||||||
url: buildAppVeyorURL,
|
url: BUILD_APPVEYOR_URL,
|
||||||
auth: {
|
auth: {
|
||||||
bearer: process.env.APPVEYOR_CLOUD_TOKEN
|
bearer: process.env.APPVEYOR_CLOUD_TOKEN
|
||||||
},
|
},
|
||||||
|
@ -244,7 +249,7 @@ async function buildVSTS (targetBranch, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestOpts = {
|
const requestOpts = {
|
||||||
url: `${vstsURL}/definitions?api-version=4.1`,
|
url: `${VSTS_URL}/definitions?api-version=4.1`,
|
||||||
auth: {
|
auth: {
|
||||||
user: '',
|
user: '',
|
||||||
password: process.env.VSTS_TOKEN
|
password: process.env.VSTS_TOKEN
|
||||||
|
@ -270,7 +275,7 @@ async function callVSTSBuild (build, targetBranch, environmentVariables) {
|
||||||
buildBody.parameters = JSON.stringify(environmentVariables)
|
buildBody.parameters = JSON.stringify(environmentVariables)
|
||||||
}
|
}
|
||||||
const requestOpts = {
|
const requestOpts = {
|
||||||
url: `${vstsURL}/builds?api-version=4.1`,
|
url: `${VSTS_URL}/builds?api-version=4.1`,
|
||||||
auth: {
|
auth: {
|
||||||
user: '',
|
user: '',
|
||||||
password: process.env.VSTS_TOKEN
|
password: process.env.VSTS_TOKEN
|
||||||
|
|
Loading…
Add table
Reference in a new issue