From c0a05ff31e4817491a728dba312bed13d3d076f8 Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:46:59 +0800 Subject: [PATCH] ci: rebuild the benchmark native addon when the restored one does not load node-24-build can run on the self-hosted pool while the benchmarks stay on hosted Linux; the phase jobs now load the restored Node-API addon and rebuild it on their runner if it fails. The report spec cleans its directories with onTestFinished, which also removes a clone the duplication gate reported. --- .github/workflows/ci.yml | 14 ++++++++++++++ scripts/ci-workflow.spec.ts | 7 ++++++- scripts/render-benchmark-report.spec.ts | 10 +++------- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cb64bc1e2..c3c7cc71e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -490,6 +490,20 @@ jobs: zstd -dc -T0 "$archive" | tar -xmf - test -f apps/cli/lib/bin.js && test -f apps/web/dist/index.html && test -f .dsh-build/client-build-environment.json + # node-24-build can run on another pool (vm-backup under self-hosted + # failover) while the benchmarks stay on hosted Linux, so the restored + # Node-API addon is loaded here and rebuilt on this runner if it fails. + - name: Rebuild the native addon if the restored one does not load + run: | + addon=native/system/packages/linux-x64/bin/glibc/system.node + if node -e 'process.dlopen({ exports: {} }, process.argv[1])' "$addon"; then + echo "Restored native addon loads on this runner." + else + echo "::notice::Restored native addon does not load on this runner; rebuilding it." + pnpm run build:native-system + node -e 'process.dlopen({ exports: {} }, process.argv[1])' "$addon" + fi + - name: Install benchmark browser and hosted dependencies run: pnpm --filter @deepseek-ai/dsh-benchmarks exec playwright install --with-deps chromium diff --git a/scripts/ci-workflow.spec.ts b/scripts/ci-workflow.spec.ts index 5c9cae1b98..2af2c236be 100644 --- a/scripts/ci-workflow.spec.ts +++ b/scripts/ci-workflow.spec.ts @@ -866,7 +866,12 @@ describe('CI workflow', () => { expect(steps[index('Download build output')]).toMatchObject({ uses: 'actions/download-artifact@v8.0.1', with: { name: 'build-output' } }) expect(index('Download build output')).toBeGreaterThan(index('Install (immutable)')) expect(index('Unpack build output')).toBeGreaterThan(index('Download build output')) - expect(index('Run performance benchmarks')).toBeGreaterThan(index('Unpack build output')) + // A restored addon from another runner pool that does not load is rebuilt here. + const addon = index('Rebuild the native addon if the restored one does not load') + expect(addon).toBeGreaterThan(index('Unpack build output')) + expect(index('Run performance benchmarks')).toBeGreaterThan(addon) + expect(String(steps[addon]?.run)).toContain('process.dlopen({ exports: {} }, process.argv[1])') + expect(String(steps[addon]?.run)).toContain('pnpm run build:native-system') expect(String(steps[index('Unpack build output')]?.run)).toContain('tar -xmf -') }) diff --git a/scripts/render-benchmark-report.spec.ts b/scripts/render-benchmark-report.spec.ts index 767b8559fa..c589471be1 100644 --- a/scripts/render-benchmark-report.spec.ts +++ b/scripts/render-benchmark-report.spec.ts @@ -1,17 +1,13 @@ import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' -import { afterEach, describe, expect, it } from 'vitest' +import { describe, expect, it, onTestFinished } from 'vitest' import { mergeReportDirectories, renderMergedReport } from '../benchmarks/support/scaling-report.ts' -const roots: string[] = [] -afterEach(async () => { - for (const root of roots.splice(0)) await rm(root, { recursive: true, force: true }) -}) - +/** A private directory removed when the current test finishes. */ async function temporaryRoot(): Promise { const root = await mkdtemp(join(tmpdir(), 'dsh-benchmark-report-')) - roots.push(root) + onTestFinished(() => rm(root, { recursive: true, force: true })) return root }