fix(ci): use managed temp dir in channel contracts

This commit is contained in:
Peter Steinberger
2026-04-28 02:19:58 +01:00
parent b891dbb133
commit 06a80fa813
3 changed files with 35 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
import { getChannelPluginCatalogEntry, listChannelPluginCatalogEntries } from "../../catalog.js";
type CatalogEntryMeta = {
@@ -44,7 +44,9 @@ export function describeBundledMetadataOnlyChannelCatalogContract(params: {
}) {
describe(`${params.pluginId} bundled metadata-only channel catalog contract`, () => {
it("includes the bundled metadata-only channel entry when the runtime entrypoint is omitted", () => {
const packageRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-bundled-catalog-"));
const packageRoot = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-bundled-catalog-"),
);
const bundledDir = path.join(packageRoot, "dist", "extensions", params.pluginId);
fs.mkdirSync(bundledDir, { recursive: true });
fs.writeFileSync(
@@ -98,7 +100,9 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
}) {
describe(`${params.channelId} official fallback channel catalog contract`, () => {
it("includes shipped official channel catalog entries when bundled metadata is omitted", () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-official-catalog-"));
const dir = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-official-catalog-"),
);
const catalogPath = path.join(dir, "channel-catalog.json");
fs.writeFileSync(
catalogPath,
@@ -131,7 +135,9 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
});
it("lets external catalogs override shipped fallback channel metadata", () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-fallback-catalog-"));
const dir = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-fallback-catalog-"),
);
const bundledDir = path.join(dir, "dist", "extensions", params.pluginId);
const officialCatalogPath = path.join(dir, "channel-catalog.json");
const externalCatalogPath = path.join(dir, "catalog.json");
@@ -208,7 +214,9 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
});
it("surfaces package-name drift in external channel catalog install metadata", () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-drifted-catalog-"));
const dir = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-drifted-catalog-"),
);
const catalogPath = path.join(dir, "catalog.json");
fs.writeFileSync(
catalogPath,

View File

@@ -1,7 +1,7 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
import { listChannelPluginCatalogEntries } from "../../catalog.js";
function createCatalogEntry(params: {
@@ -122,7 +122,9 @@ export function describeChannelPluginCatalogEntriesContract() {
{
name: "includes external catalog entries",
setup: () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-"));
const dir = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-"),
);
const catalogPath = path.join(dir, "catalog.json");
writeCatalogFile(
catalogPath,
@@ -145,7 +147,7 @@ export function describeChannelPluginCatalogEntriesContract() {
name: "preserves plugin ids when they differ from channel ids",
setup: () => {
const stateDir = fs.mkdtempSync(
path.join(os.tmpdir(), "openclaw-channel-catalog-state-"),
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-channel-catalog-state-"),
);
writeDiscoveredChannelPlugin({
stateDir,
@@ -168,7 +170,9 @@ export function describeChannelPluginCatalogEntriesContract() {
{
name: "keeps discovered plugins ahead of external catalog overrides",
setup: () => {
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-state-"));
const stateDir = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-state-"),
);
const catalogPath = path.join(stateDir, "catalog.json");
writeDiscoveredChannelPlugin({
stateDir,
@@ -206,7 +210,9 @@ export function describeChannelPluginCatalogEntriesContract() {
{
name: "accepts rich external manifest entries with pinned npm metadata",
setup: () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-rich-"));
const dir = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-rich-"),
);
const catalogPath = path.join(dir, "catalog.json");
fs.writeFileSync(
catalogPath,
@@ -284,7 +290,9 @@ export function describeChannelPluginCatalogEntriesContract() {
{
name: "accepts rich external manifest entries for yuanbao with pinned npm metadata",
setup: () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-yuanbao-"));
const dir = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-yuanbao-"),
);
const catalogPath = path.join(dir, "catalog.json");
fs.writeFileSync(
catalogPath,
@@ -365,7 +373,9 @@ export function describeChannelPluginCatalogPathResolutionContract() {
{
name: "uses the provided env for external catalog path resolution",
setup: () => {
const home = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-home-"));
const home = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-home-"),
);
const catalogPath = path.join(home, "catalog.json");
writeCatalogFile(
catalogPath,
@@ -391,7 +401,9 @@ export function describeChannelPluginCatalogPathResolutionContract() {
{
name: "uses the provided env for default catalog paths",
setup: () => {
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-state-"));
const stateDir = fs.mkdtempSync(
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-state-"),
);
const catalogPath = path.join(stateDir, "plugins", "catalog.json");
fs.mkdirSync(path.dirname(catalogPath), { recursive: true });
writeCatalogFile(

View File

@@ -1,5 +1,4 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { expect } from "vitest";
import type { OpenClawConfig } from "../../../../config/config.js";
@@ -8,6 +7,7 @@ import {
type SessionBindingCapabilities,
type SessionBindingRecord,
} from "../../../../infra/outbound/session-binding-service.js";
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
import { setActivePluginRegistry } from "../../../../plugins/runtime.js";
import { createTestRegistry } from "../../../../test-utils/channel-plugins.js";
import { createChannelConversationBindingManager } from "../../conversation-bindings.js";
@@ -31,7 +31,7 @@ type SessionBindingContractEntry = {
const contractApiPromises = new Map<string, Promise<Record<string, unknown>>>();
const matrixSessionBindingStateDir = fs.mkdtempSync(
path.join(os.tmpdir(), "openclaw-matrix-session-binding-contract-"),
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-matrix-session-binding-contract-"),
);
const matrixSessionBindingAuth = {
accountId: "ops",