Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: lengthen wait times and retries for CircleCI releases #20893

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 16 additions & 11 deletions script/release/ci-release-build.js
Expand Up @@ -2,9 +2,12 @@ if (!process.env.CI) require('dotenv-safe').load()

const assert = require('assert')
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 vstsURL = 'https://github.visualstudio.com/electron/_apis/build'

const BUILD_APPVEYOR_URL = 'https://ci.appveyor.com/api/builds'
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 = {
'electron-x64': 'electron-x64-release',
Expand Down Expand Up @@ -78,7 +81,7 @@ async function circleCIcall (targetBranch, job, options) {
// If the workflows are changed in the CircleCI config.yml, this logic will
// also need to be changed as well as possibly changing sudowoodo.
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.`)
const pipelineInfoUrl = `https://circleci.com/api/v2/pipeline/${circleResponse.id}`
const workflowId = await getCircleCIWorkflowId(circleResponse.id)
Expand All @@ -99,7 +102,7 @@ async function circleCIcall (targetBranch, job, options) {

async function getCircleCIWorkflowId (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')
switch (pipelineInfo.state) {
case 'created': {
Expand All @@ -114,14 +117,15 @@ async function getCircleCIWorkflowId (pipelineId) {
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
}

async function getCircleCIJobNumber (workflowId) {
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')
if (!jobInfo.items) {
continue
Expand All @@ -145,8 +149,9 @@ async function getCircleCIJobNumber (workflowId) {
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
}

Expand Down Expand Up @@ -189,7 +194,7 @@ async function callAppVeyor (targetBranch, job, options) {
}

const requestOpts = {
url: buildAppVeyorURL,
url: BUILD_APPVEYOR_URL,
auth: {
bearer: process.env.APPVEYOR_CLOUD_TOKEN
},
Expand Down Expand Up @@ -244,7 +249,7 @@ async function buildVSTS (targetBranch, options) {
}

const requestOpts = {
url: `${vstsURL}/definitions?api-version=4.1`,
url: `${VSTS_URL}/definitions?api-version=4.1`,
auth: {
user: '',
password: process.env.VSTS_TOKEN
Expand All @@ -270,7 +275,7 @@ async function callVSTSBuild (build, targetBranch, environmentVariables) {
buildBody.parameters = JSON.stringify(environmentVariables)
}
const requestOpts = {
url: `${vstsURL}/builds?api-version=4.1`,
url: `${VSTS_URL}/builds?api-version=4.1`,
auth: {
user: '',
password: process.env.VSTS_TOKEN
Expand Down