Skip to content

Commit

Permalink
chore: fix the get-binary-release-data script to try and locate all p…
Browse files Browse the repository at this point in the history
…ossible references that might be pull requests for a given commit. Also added debug messaging in the case this script needs to be debugged without spamming the console. (#28692)
  • Loading branch information
AtofStryker authored Jan 12, 2024
1 parent 46c2080 commit f088ce6
Showing 1 changed file with 44 additions and 19 deletions.
63 changes: 44 additions & 19 deletions scripts/semantic-commits/get-binary-release-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ const Bluebird = require('bluebird')
const childProcess = require('child_process')
const _ = require('lodash')
const { Octokit } = require('@octokit/core')
const debugLib = require('debug')

const { getCurrentReleaseData } = require('./get-current-release-data')
const { getNextVersionForBinary } = require('../get-next-version')
const { getLinkedIssues } = require('./get-linked-issues')
const debug = debugLib('scripts:semantic-commits:get-binary-release-data')

const ensureAuth = () => {
if (!process.env.GH_TOKEN) {
Expand Down Expand Up @@ -80,8 +82,6 @@ const fetchPullRequest = async (octokit, pullNumber) => {

return pullRequest
} catch (err) {
console.log(`Error while fetching PR #${pullNumber}:`, err)

const { rateLimitHit, retryAfter } = parseRateLimit(err)

if (rateLimitHit) {
Expand Down Expand Up @@ -133,29 +133,54 @@ const getReleaseData = async (latestReleaseInfo) => {
return
}

const ref = references.find((r) => !r.raw.includes('revert #'))
const refs = references.filter((r) => !r.raw.includes('revert #'))

if (!ref) {
if (!refs.length) {
console.log('Commit does not have an associated pull request number...')

return
}

const pullRequest = await fetchPullRequest(octokit, ref.issue)
const associatedIssues = pullRequest.body ? getLinkedIssues(pullRequest.body) : []

commits.push({
commitMessage: semanticResult.header,
semanticType,
prNumber: ref.issue,
associatedIssues,
})

prsInRelease.push(`https://github.com/cypress-io/cypress/pull/${ref.issue}`)

associatedIssues.forEach((issueNumber) => {
issuesInRelease.push(`https://github.com/cypress-io/cypress/issues/${issueNumber}`)
})
for (const [idx, ref] of refs.entries()) {
let pullRequest

try {
pullRequest = await fetchPullRequest(octokit, ref.issue)
debug(`Pull request #${ref.issue} found!`)
} catch (err) {
debug(`Error while fetching PR #${ ref.issue}:`, err)
// If we have tried to fetch all other references and all of them failed,
// print the failure of the last reference and exit
if (idx === refs.length) {
debug(`all references exhausted and no PR could be found!`)
console.log(`Error while fetching PR #${ ref.issue}:`, err)
throw err
} else {
// otherwise, we still might be able to link a PR to the commit
debug(`Other references need to be tried. Continuing to see if we can find a corresponding pull request.`)
}

continue
}

const associatedIssues = pullRequest.body ? getLinkedIssues(pullRequest.body) : []

commits.push({
commitMessage: semanticResult.header,
semanticType,
prNumber: ref.issue,
associatedIssues,
})

prsInRelease.push(`https://github.com/cypress-io/cypress/pull/${ref.issue}`)

associatedIssues.forEach((issueNumber) => {
issuesInRelease.push(`https://github.com/cypress-io/cypress/issues/${issueNumber}`)
})

// since we found our pull request, we don't need to check the rest of the references
break
}
}))

console.log('Next release version is', nextVersion)
Expand Down

6 comments on commit f088ce6

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f088ce6 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/linux-x64/develop-f088ce6c4992a7201d10b6bc9e8758b071fd84a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f088ce6 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/linux-x64/develop-f088ce6c4992a7201d10b6bc9e8758b071fd84a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f088ce6 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/darwin-x64/develop-f088ce6c4992a7201d10b6bc9e8758b071fd84a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f088ce6 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/darwin-arm64/develop-f088ce6c4992a7201d10b6bc9e8758b071fd84a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f088ce6 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/win32-x64/develop-f088ce6c4992a7201d10b6bc9e8758b071fd84a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f088ce6 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/linux-arm64/develop-f088ce6c4992a7201d10b6bc9e8758b071fd84a1/cypress.tgz

Please sign in to comment.