Skip to content

Commit

Permalink
chore: Prevent npm-release failures in one package from stopping othe…
Browse files Browse the repository at this point in the history
…r releases (#24017)
  • Loading branch information
chrisbreiding authored Sep 28, 2022
1 parent 5f00718 commit d2a7de1
Show file tree
Hide file tree
Showing 2 changed files with 248 additions and 77 deletions.
49 changes: 38 additions & 11 deletions scripts/npm-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,44 @@ const injectVersions = (packagesToRelease, versions, packages) => {
const releasePackages = async (packages) => {
console.log(`\nReleasing packages`)

let failures = []

// it would make sense to run each release simultaneously with something like Promise.all()
// however this can cause a race condition within git (git lock throws an error)
// so we run them one by one to avoid this
for (const name of packages) {
console.log(`\nReleasing ${name}...`)
// semantic-release v19 upgraded to npm v8 which supports workspaces. When running semantic-release, npm thinks that our lerna workspace
// is an npm workspace. When npm executes commands that modify the workspace, it will check the validity of the workspace.
// We don't want this to happen since we don't use npm and our links/peerDependencies make npm unhappy.
// We disable the workspace update via the NPM_CONFIG_WORKSPACES_UDPATE=false env variable.
const { stdout } = await execa('npx', ['lerna', 'exec', '--scope', name, '--', 'npx', '--no-install', 'semantic-release'], { env: { NPM_CONFIG_WORKSPACES_UPDATE: false } })

console.log(`Released ${name} successfully:`)
console.log(stdout)
// semantic-release v19 upgraded to npm v8 which supports workspaces. When
// running semantic-release, npm thinks that our lerna workspace is an npm
// workspace. When npm executes commands that modify the workspace, it will
// check the validity of the workspace. We don't want this to happen since
// since we don't use npm and our links/peerDependencies make npm unhappy.
// We disable the workspace update via the NPM_CONFIG_WORKSPACES_UDPATE=false
// env variable.
try {
const { stdout } = await execa(
'npx',
['lerna', 'exec', '--scope', name, '--', 'npx', '--no-install', 'semantic-release'],
{ env: { NPM_CONFIG_WORKSPACES_UPDATE: false } },
)

console.log(`Released ${name} successfully:`)
console.log(stdout)
} catch (err) {
failures.push(name)

console.log(`Releasing ${name} failed:`)
console.log(err.stack)
}
}

console.log(`\nAll packages released successfully`)
if (failures.length) {
console.log(`\nThe following packages failed to release:\n- ${failures.join('\n- ')}`)
} else {
console.log(`\nAll packages released successfully`)
}

return failures.length
}

const getLernaPackages = async () => {
Expand Down Expand Up @@ -195,9 +217,13 @@ const main = async () => {
return console.log(`Release process cannot be run on a PR`)
}

await releasePackages(packagesToRelease)
const numFailures = await releasePackages(packagesToRelease)

console.log(`\n\nRelease process completed successfully!`)
if (numFailures) {
process.exit(numFailures)
} else {
console.log(`\n\nRelease process completed successfully!`)
}
}

// execute main function if called from command line
Expand All @@ -208,4 +234,5 @@ if (require.main === module) {
module.exports = {
parseSemanticReleaseOutput,
readPackageJson,
releasePackages,
}
Loading

5 comments on commit d2a7de1

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d2a7de1 Sep 28, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/linux-x64/develop-d2a7de1d6d09053f5d40cff268599b9e2ab1a807/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d2a7de1 Sep 28, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/linux-arm64/develop-d2a7de1d6d09053f5d40cff268599b9e2ab1a807/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d2a7de1 Sep 28, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/darwin-x64/develop-d2a7de1d6d09053f5d40cff268599b9e2ab1a807/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d2a7de1 Sep 28, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/darwin-arm64/develop-d2a7de1d6d09053f5d40cff268599b9e2ab1a807/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d2a7de1 Sep 28, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/win32-x64/develop-d2a7de1d6d09053f5d40cff268599b9e2ab1a807/cypress.tgz

Please sign in to comment.