From 0a670a058db2c604f884a73da8e31e3696116b41 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 22 Apr 2026 06:30:59 +0100 Subject: [PATCH] perf(ci): unblock node compat and trim runtime compat test --- .github/workflows/ci.yml | 104 +++++++++++++----- .../plugins/setup-promotion-helpers.test.ts | 19 ++++ .../plugins/setup-promotion-helpers.ts | 8 ++ src/config/io.compat.test.ts | 48 ++++---- 4 files changed, 127 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 942bd37d969..ec0ac7ef09d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -244,17 +244,6 @@ jobs: runNode ? [ { check_name: "checks-node-channels", runtime: "node", task: "channels" }, - ...(isPush - ? [ - { - check_name: "checks-node-compat-node22", - runtime: "node", - task: "compat-node22", - node_version: "22.18.0", - cache_key_suffix: "node22", - }, - ] - : []), ] : [], ), @@ -914,12 +903,7 @@ jobs: fail-fast: false matrix: ${{ fromJson(needs.preflight.outputs.checks_matrix) }} steps: - - name: Skip compatibility lanes on pull requests - if: github.event_name == 'pull_request' && matrix.task == 'compat-node22' - run: echo "Skipping push-only lane on pull requests." - - name: Checkout - if: github.event_name != 'pull_request' || matrix.task != 'compat-node22' shell: bash env: CHECKOUT_REPO: ${{ github.repository }} @@ -968,7 +952,6 @@ jobs: exit 1 - name: Setup Node environment - if: github.event_name != 'pull_request' || matrix.task != 'compat-node22' uses: ./.github/actions/setup-node-env with: node-version: "${{ matrix.node_version || '24.x' }}" @@ -976,7 +959,7 @@ jobs: install-bun: "false" - name: Configure Node test resources - if: (github.event_name != 'pull_request' || matrix.task != 'compat-node22') && matrix.runtime == 'node' && (matrix.task == 'test' || matrix.task == 'channels' || matrix.task == 'compat-node22') + if: matrix.runtime == 'node' && (matrix.task == 'test' || matrix.task == 'channels') env: TASK: ${{ matrix.task }} run: | @@ -1004,7 +987,6 @@ jobs: path: src/canvas-host/a2ui/ - name: Run ${{ matrix.task }} (${{ matrix.runtime }}) - if: github.event_name != 'pull_request' || matrix.task != 'compat-node22' env: TASK: ${{ matrix.task }} NODE_OPTIONS: --max-old-space-size=6144 @@ -1018,19 +1000,89 @@ jobs: channels) pnpm test:channels ;; - compat-node22) - pnpm build - pnpm ui:build - node openclaw.mjs --help - node openclaw.mjs status --json --timeout 1 - pnpm test:build:singleton - ;; *) echo "Unsupported checks task: $TASK" >&2 exit 1 ;; esac + checks-node-compat: + permissions: + contents: read + name: checks-node-compat-node22 + needs: [preflight] + if: needs.preflight.outputs.run_node == 'true' && github.event_name == 'push' + runs-on: ${{ github.repository == 'openclaw/openclaw' && 'blacksmith-16vcpu-ubuntu-2404' || 'ubuntu-24.04' }} + timeout-minutes: 60 + steps: + - name: Checkout + shell: bash + env: + CHECKOUT_REPO: ${{ github.repository }} + CHECKOUT_SHA: ${{ github.sha }} + CHECKOUT_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + + workdir="$GITHUB_WORKSPACE" + auth_header="$(printf 'x-access-token:%s' "$CHECKOUT_TOKEN" | base64 | tr -d '\n')" + + reset_checkout_dir() { + mkdir -p "$workdir" + find "$workdir" -mindepth 1 -maxdepth 1 -exec rm -rf {} + + } + + checkout_attempt() { + local attempt="$1" + + reset_checkout_dir + git init "$workdir" >/dev/null + git config --global --add safe.directory "$workdir" + git -C "$workdir" remote add origin "https://github.com/${CHECKOUT_REPO}" + git -C "$workdir" config gc.auto 0 + + timeout --signal=TERM 30s git -C "$workdir" \ + -c protocol.version=2 \ + -c "http.https://github.com/.extraheader=AUTHORIZATION: basic ${auth_header}" \ + fetch --no-tags --prune --no-recurse-submodules --depth=1 origin \ + "+${CHECKOUT_SHA}:refs/remotes/origin/ci-target" || return 1 + + git -C "$workdir" checkout --force --detach "$CHECKOUT_SHA" || return 1 + test -f "$workdir/.github/actions/setup-node-env/action.yml" || return 1 + echo "checkout attempt ${attempt}/2 succeeded" + } + + for attempt in 1 2; do + if checkout_attempt "$attempt"; then + exit 0 + fi + echo "checkout attempt ${attempt}/2 failed" + sleep $((attempt * 5)) + done + + echo "checkout failed after 2 attempts" >&2 + exit 1 + + - name: Setup Node environment + uses: ./.github/actions/setup-node-env + with: + node-version: "22.18.0" + cache-key-suffix: "node22" + install-bun: "false" + + - name: Configure Node test resources + run: echo "OPENCLAW_VITEST_MAX_WORKERS=2" >> "$GITHUB_ENV" + + - name: Run Node 22 compatibility + env: + NODE_OPTIONS: --max-old-space-size=6144 + run: | + pnpm build + pnpm ui:build + node openclaw.mjs --help + node openclaw.mjs status --json --timeout 1 + pnpm test:build:singleton + checks-node-core-test-nondist-shard: permissions: contents: read diff --git a/src/channels/plugins/setup-promotion-helpers.test.ts b/src/channels/plugins/setup-promotion-helpers.test.ts index 40809e2c31f..048442932a7 100644 --- a/src/channels/plugins/setup-promotion-helpers.test.ts +++ b/src/channels/plugins/setup-promotion-helpers.test.ts @@ -38,6 +38,25 @@ describe("setup promotion helpers", () => { expect(getBundledChannelPluginMock).not.toHaveBeenCalled(); }); + it("keeps WhatsApp static promotion cheap even when named accounts already exist", () => { + const keys = resolveSingleAccountKeysToMove({ + channelKey: "whatsapp", + channel: { + accounts: { + work: { enabled: true }, + }, + dmPolicy: "allowlist", + allowFrom: ["+15551234567"], + groupPolicy: "allowlist", + groupAllowFrom: ["group-123"], + }, + }); + + expect(keys).toEqual(["dmPolicy", "allowFrom", "groupPolicy", "groupAllowFrom"]); + expect(getLoadedChannelPluginMock).toHaveBeenCalledWith("whatsapp"); + expect(getBundledChannelPluginMock).not.toHaveBeenCalled(); + }); + it("loads bundled setup only for non-static migration keys", () => { getBundledChannelPluginMock.mockReturnValue({ setup: { diff --git a/src/channels/plugins/setup-promotion-helpers.ts b/src/channels/plugins/setup-promotion-helpers.ts index 6e837923c71..428371af66d 100644 --- a/src/channels/plugins/setup-promotion-helpers.ts +++ b/src/channels/plugins/setup-promotion-helpers.ts @@ -49,10 +49,18 @@ type ChannelSetupPromotionSurface = { }) => string | undefined; }; +const BUNDLED_CHANNELS_WITHOUT_SETUP_PROMOTION_SURFACE = new Set(["whatsapp"]); + function getChannelSetupPromotionSurface( channelKey: string, opts?: { loadBundledFallback?: boolean }, ): ChannelSetupPromotionSurface | null { + if ( + opts?.loadBundledFallback && + BUNDLED_CHANNELS_WITHOUT_SETUP_PROMOTION_SURFACE.has(channelKey) + ) { + return getLoadedChannelPlugin(channelKey)?.setup ?? null; + } const setup = getLoadedChannelPlugin(channelKey)?.setup ?? (opts?.loadBundledFallback ? getBundledChannelPlugin(channelKey)?.setup : undefined); diff --git a/src/config/io.compat.test.ts b/src/config/io.compat.test.ts index 3d249c7d4a2..e92acb6a0b1 100644 --- a/src/config/io.compat.test.ts +++ b/src/config/io.compat.test.ts @@ -2,10 +2,10 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; -import { loadConfig } from "./config.js"; +import { applyRuntimeLegacyConfigMigrations } from "../commands/doctor/shared/runtime-compat-api.js"; import { createConfigIO } from "./io.js"; import { normalizeExecSafeBinProfilesInConfig } from "./normalize-exec-safe-bin.js"; -import { withTempHomeConfig } from "./test-helpers.js"; +import type { OpenClawConfig } from "./types.openclaw.js"; async function withTempHome(run: (home: string) => Promise): Promise { const home = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-config-")); @@ -115,34 +115,30 @@ describe("config io paths", () => { expect(cfg.agents?.list?.[0]?.tools?.exec?.safeBinTrustedDirs).toEqual(["/ops/bin"]); }); - it("moves WhatsApp shared access defaults into accounts.default during loadConfig() runtime compat", async () => { - await withTempHomeConfig( - { - channels: { - whatsapp: { - enabled: true, - dmPolicy: "allowlist", - allowFrom: ["+15550001111"], - groupPolicy: "open", - groupAllowFrom: [], - accounts: { - work: { - enabled: true, - authDir: "/tmp/wa-work", - }, - }, - }, - }, - }, - async () => { - const loaded = loadConfig(); - expect(loaded.channels?.whatsapp?.accounts?.default).toMatchObject({ + it("moves WhatsApp shared access defaults into accounts.default during runtime compat", () => { + const migrated = applyRuntimeLegacyConfigMigrations({ + channels: { + whatsapp: { + enabled: true, dmPolicy: "allowlist", allowFrom: ["+15550001111"], groupPolicy: "open", groupAllowFrom: [], - }); + accounts: { + work: { + enabled: true, + authDir: "/tmp/wa-work", + }, + }, + }, }, - ); + }); + const next = migrated.next as OpenClawConfig | null; + expect(next?.channels?.whatsapp?.accounts?.default).toMatchObject({ + dmPolicy: "allowlist", + allowFrom: ["+15550001111"], + groupPolicy: "open", + groupAllowFrom: [], + }); }); });