From 0d1c025aa72795f1516d8e8417439fc2f9a2952d Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 13 Jan 2026 11:46:35 +0100 Subject: [PATCH 1/2] test: add a retry for the merge queue --- .github/workflows/run-tests.yml | 3 ++- package.json | 2 +- scripts/test.mjs | 38 +++++++++++++++++++++++++++------ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bc99aa5c6..08cb39fff 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -59,7 +59,8 @@ jobs: - name: Run tests shell: bash - run: npm run test:no-build + # Try tests if they fail in the merge queue. + run: npm run test:no-build -- ${{ github.event_name == 'merge_group' && '--retry' || '' }} # Gating job for branch protection. test-success: diff --git a/package.json b/package.json index 630fb103c..0f40672d0 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "docs:generate": "node --experimental-strip-types scripts/generate-docs.ts", "start": "npm run build && node build/src/index.js", "start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js", - "test": "npm run build && npm run test:no-build", + "test": "npm run build && node scripts/test.mjs", "test:no-build": "node scripts/test.mjs", "test:only": "npm run build && node scripts/test.mjs --test-only", "test:update-snapshots": "npm run build && node scripts/test.mjs --test-update-snapshots", diff --git a/scripts/test.mjs b/scripts/test.mjs index 5e061537b..796c13ad9 100644 --- a/scripts/test.mjs +++ b/scripts/test.mjs @@ -17,6 +17,13 @@ const flags = args.filter(arg => arg.startsWith('-')); const files = []; +let shouldRetry = false; +const retryIndex = flags.indexOf('--retry'); +if (retryIndex !== -1) { + shouldRetry = true; + flags.splice(retryIndex, 1); +} + if (userArgs.length > 0) { for (const arg of userArgs) { // Map .ts files to build/ .js files @@ -50,10 +57,29 @@ const nodeArgs = [ ...files, ]; -const child = spawn('node', nodeArgs, { - stdio: 'inherit', -}); +async function runTests(attempt) { + if (attempt > 1) { + console.log(`\nRun attempt ${attempt}...\n`); + } + return new Promise(resolve => { + const child = spawn('node', nodeArgs, { + stdio: 'inherit', + }); + + child.on('close', code => { + resolve(code); + }); + }); +} + +const maxAttempts = shouldRetry ? 3 : 1; +let exitCode = 1; + +for (let i = 1; i <= maxAttempts; i++) { + exitCode = await runTests(i); + if (exitCode === 0) { + break; + } +} -child.on('close', code => { - process.exit(code ?? 1); -}); +process.exit(exitCode ?? 1); From cdb906be1a334fd1a7ef21c1d4ed8d8546f7f03b Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 13 Jan 2026 11:53:19 +0100 Subject: [PATCH 2/2] Apply suggestion from @OrKoN --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 08cb39fff..98d3f6b95 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -59,7 +59,7 @@ jobs: - name: Run tests shell: bash - # Try tests if they fail in the merge queue. + # Retry tests if they fail in the merge queue. run: npm run test:no-build -- ${{ github.event_name == 'merge_group' && '--retry' || '' }} # Gating job for branch protection.