Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .yarn/patches/@semantic-release-github-npm-12.0.8-46fbe69aa5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/lib/success.js b/lib/success.js
index 48246f29a2162ce0abc0d044112de94bab39becb..02d463e611104cb6b1fbd008a0de4fbaf5a2e3d8 100644
--- a/lib/success.js
+++ b/lib/success.js
@@ -76,7 +76,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
const shas = commits.map(({ hash }) => hash);

// Get associatedPRs
- const associatedPRs = await inChunks(shas, 100, async (chunk) => {
+ const associatedPRs = await inChunks(shas, 25, async (chunk) => {
const responsePRs = [];
const { repository } = await octokit.graphql(
buildAssociatedPRsQuery(chunk),
@@ -333,8 +333,8 @@ export default async function success(pluginConfig, context, { Octokit }) {
}

/**
- * In order to speed up a function call that handles a big array of items, we split up the
- * array in chunks and call the function for each chunk in parallel. At the end we combine the
+ * Split a big array of items in chunks and call the function for each chunk serially, so that
+ * large releases do not send many heavy GraphQL queries at once. At the end we combine the
* results again.
*
* @template TItem
@@ -345,11 +345,10 @@ export default async function success(pluginConfig, context, { Octokit }) {
* @returns TCallbackResult
*/
async function inChunks(items, chunkSize, callback) {
- const chunkCalls = [];
+ const results = [];
for (let i = 0; i < items.length; i += chunkSize) {
- chunkCalls.push(callback(items.slice(i, i + chunkSize)));
+ results.push(await callback(items.slice(i, i + chunkSize)));
}
- const results = await Promise.all(chunkCalls);

return results.flat();
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"postcss-selector-parser@npm:^6.0.11": "6.1.5",
"postcss-selector-parser@npm:^7.0.0": "7.1.6",
"postcss-selector-parser@npm:^7.1.0": "7.1.6",
"postcss-selector-parser@npm:^7.1.1": "7.1.6"
"postcss-selector-parser@npm:^7.1.1": "7.1.6",
"@semantic-release/github@npm:^12.0.0": "patch:@semantic-release/github@npm%3A12.0.8#~/.yarn/patches/@semantic-release-github-npm-12.0.8-46fbe69aa5.patch"
},
"engines": {
"node": ">=24.x",
Expand Down
4 changes: 2 additions & 2 deletions packages/dnb-eufemia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"test:e2e": "playwright test --config=./playwright.config.e2e.ts",
"test:e2e:ci": "PLAYWRIGHT_BASE_URL=http://localhost:8001 start-server-and-test 'yarn workspace dnb-design-system-portal serve:8001' http://localhost:8001 test:e2e",
"test:e2e:watch": "playwright test --config=./playwright.config.e2e.ts --ui",
"test:postbuild": "vitest run --config vitest.config.postbuild.ts scripts/postbuild/__tests__/postbuild.test.ts scripts/postbuild/__tests__/styleSideEffects.test.ts scripts/postbuild/__tests__/validatePackageContents.test.ts scripts/postbuild/__tests__/writeReleaseConfig.test.ts scripts/postbuild/__tests__/getNextReleaseVersion.test.ts scripts/postbuild/__tests__/verifyReleaseVersion.test.ts",
"test:postbuild": "vitest run --config vitest.config.postbuild.ts scripts/postbuild/__tests__/postbuild.test.ts scripts/postbuild/__tests__/styleSideEffects.test.ts scripts/postbuild/__tests__/validatePackageContents.test.ts scripts/postbuild/__tests__/writeReleaseConfig.test.ts scripts/postbuild/__tests__/getNextReleaseVersion.test.ts scripts/postbuild/__tests__/verifyReleaseVersion.test.ts scripts/postbuild/__tests__/semanticReleaseGithub.test.ts",
"test:postbuild:publish": "vitest run --config vitest.config.postbuild.ts scripts/postbuild/__tests__/prepareForRelease.test.ts",
"test:prepare": "yarn build:style-manifest",
"test:screenshots": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON --experimental-strip-types ./scripts/tools/vitest/runScreenshotVitest.ts",
Expand Down Expand Up @@ -181,7 +181,7 @@
"@semantic-release/changelog": "6.0.3",
"@semantic-release/commit-analyzer": "13.0.1",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "12.0.8",
"@semantic-release/github": "patch:@semantic-release/github@npm%3A12.0.8#~/.yarn/patches/@semantic-release-github-npm-12.0.8-46fbe69aa5.patch",
"@semantic-release/npm": "13.1.5",
"@semantic-release/release-notes-generator": "14.1.1",
"@svgr/core": "6.5.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* Test the patched success step of @semantic-release/github.
*
* GitHub stops a GraphQL request after 10 seconds, and asking about the pull
* requests of 100 commits at once took longer, so releases with that many
* commits failed after they were published. See .yarn/patches.
*/

import { success } from '@semantic-release/github'

describe('@semantic-release/github success step', () => {
it('asks GitHub about 25 commits per request, one request at a time', async () => {
const commitsPerRequest: Array<number> = []
let pendingRequests = 0
let maxPendingRequests = 0

class GitHubClient {
async request(route: string) {
if (route === 'GET /repos/{owner}/{repo}') {
return {
data: {
full_name: 'dnbexperience/eufemia',
clone_url: 'https://github.com/dnbexperience/eufemia.git',
permissions: { push: true },
},
}
}

throw new Error(`Unexpected request: ${route}`)
}

async graphql(query: string) {
if (query.includes('query getSRIssues(')) {
return { repository: { issues: { nodes: [] } } }
}

if (!query.includes('query getAssociatedPRs(')) {
throw new Error(`Unexpected query: ${query}`)
}

commitsPerRequest.push(query.match(/oid: "/g).length)

pendingRequests++
maxPendingRequests = Math.max(maxPendingRequests, pendingRequests)
await new Promise((resolve) => setTimeout(resolve, 1))
pendingRequests--

return { repository: {} }
}
}

await success(
{},
{
env: { GH_TOKEN: 'token' },
options: {
repositoryUrl: 'https://github.com/dnbexperience/eufemia.git',
},
commits: Array.from({ length: 105 }, (_, index) => ({
hash: String(index),
message: `fix: change ${index}`,
})),
nextRelease: { version: '11.16.1' },
releases: [],
logger: { log: vi.fn(), warn: vi.fn(), error: vi.fn() },
},
{ Octokit: GitHubClient }
)

expect(commitsPerRequest).toEqual([25, 25, 25, 25, 5])
expect(maxPendingRequests).toBe(1)
})
})
31 changes: 29 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2936,7 +2936,7 @@ __metadata:
"@semantic-release/changelog": "npm:6.0.3"
"@semantic-release/commit-analyzer": "npm:13.0.1"
"@semantic-release/git": "npm:10.0.1"
"@semantic-release/github": "npm:12.0.8"
"@semantic-release/github": "patch:@semantic-release/github@npm%3A12.0.8#~/.yarn/patches/@semantic-release-github-npm-12.0.8-46fbe69aa5.patch"
"@semantic-release/npm": "npm:13.1.5"
"@semantic-release/release-notes-generator": "npm:14.1.1"
"@svgr/core": "npm:6.5.1"
Expand Down Expand Up @@ -5486,7 +5486,7 @@ __metadata:
languageName: node
linkType: hard

"@semantic-release/github@npm:12.0.8, @semantic-release/github@npm:^12.0.0":
"@semantic-release/github@npm:12.0.8":
version: 12.0.8
resolution: "@semantic-release/github@npm:12.0.8"
dependencies:
Expand All @@ -5513,6 +5513,33 @@ __metadata:
languageName: node
linkType: hard

"@semantic-release/github@patch:@semantic-release/github@npm%3A12.0.8#~/.yarn/patches/@semantic-release-github-npm-12.0.8-46fbe69aa5.patch":
version: 12.0.8
resolution: "@semantic-release/github@patch:@semantic-release/github@npm%3A12.0.8#~/.yarn/patches/@semantic-release-github-npm-12.0.8-46fbe69aa5.patch::version=12.0.8&hash=640bda"
dependencies:
"@octokit/core": "npm:^7.0.0"
"@octokit/plugin-paginate-rest": "npm:^14.0.0"
"@octokit/plugin-retry": "npm:^8.0.0"
"@octokit/plugin-throttling": "npm:^11.0.0"
"@semantic-release/error": "npm:^4.0.0"
aggregate-error: "npm:^5.0.0"
debug: "npm:^4.3.4"
dir-glob: "npm:^3.0.1"
http-proxy-agent: "npm:^9.0.0"
https-proxy-agent: "npm:^9.0.0"
issue-parser: "npm:^7.0.0"
lodash-es: "npm:^4.17.21"
mime: "npm:^4.0.0"
p-filter: "npm:^4.0.0"
tinyglobby: "npm:^0.2.14"
undici: "npm:^7.0.0"
url-join: "npm:^5.0.0"
peerDependencies:
semantic-release: ">=24.1.0"
checksum: 10/0f23b06b465aa32db18e7a566aa1e8d5e02255f1c08f2e2c38d965e9282e48fc514f4de93ece8da7058fea5dc6662fce7454c0fbe9d81e06179ff2346d7859be
languageName: node
linkType: hard

"@semantic-release/npm@npm:13.1.5, @semantic-release/npm@npm:^13.1.1":
version: 13.1.5
resolution: "@semantic-release/npm@npm:13.1.5"
Expand Down
Loading