Skip to content

Commit 06a80fa

Browse files
committed
fix(ci): use managed temp dir in channel contracts
1 parent b891dbb commit 06a80fa

3 files changed

Lines changed: 35 additions & 15 deletions

File tree

src/channels/plugins/contracts/test-helpers/channel-catalog-contract.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from "node:fs";
2-
import os from "node:os";
32
import path from "node:path";
43
import { describe, expect, it } from "vitest";
4+
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
55
import { getChannelPluginCatalogEntry, listChannelPluginCatalogEntries } from "../../catalog.js";
66

77
type CatalogEntryMeta = {
@@ -44,7 +44,9 @@ export function describeBundledMetadataOnlyChannelCatalogContract(params: {
4444
}) {
4545
describe(`${params.pluginId} bundled metadata-only channel catalog contract`, () => {
4646
it("includes the bundled metadata-only channel entry when the runtime entrypoint is omitted", () => {
47-
const packageRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-bundled-catalog-"));
47+
const packageRoot = fs.mkdtempSync(
48+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-bundled-catalog-"),
49+
);
4850
const bundledDir = path.join(packageRoot, "dist", "extensions", params.pluginId);
4951
fs.mkdirSync(bundledDir, { recursive: true });
5052
fs.writeFileSync(
@@ -98,7 +100,9 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
98100
}) {
99101
describe(`${params.channelId} official fallback channel catalog contract`, () => {
100102
it("includes shipped official channel catalog entries when bundled metadata is omitted", () => {
101-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-official-catalog-"));
103+
const dir = fs.mkdtempSync(
104+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-official-catalog-"),
105+
);
102106
const catalogPath = path.join(dir, "channel-catalog.json");
103107
fs.writeFileSync(
104108
catalogPath,
@@ -131,7 +135,9 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
131135
});
132136

133137
it("lets external catalogs override shipped fallback channel metadata", () => {
134-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-fallback-catalog-"));
138+
const dir = fs.mkdtempSync(
139+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-fallback-catalog-"),
140+
);
135141
const bundledDir = path.join(dir, "dist", "extensions", params.pluginId);
136142
const officialCatalogPath = path.join(dir, "channel-catalog.json");
137143
const externalCatalogPath = path.join(dir, "catalog.json");
@@ -208,7 +214,9 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
208214
});
209215

210216
it("surfaces package-name drift in external channel catalog install metadata", () => {
211-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-drifted-catalog-"));
217+
const dir = fs.mkdtempSync(
218+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-drifted-catalog-"),
219+
);
212220
const catalogPath = path.join(dir, "catalog.json");
213221
fs.writeFileSync(
214222
catalogPath,

src/channels/plugins/contracts/test-helpers/channel-plugin-catalog-contract-suites.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from "node:fs";
2-
import os from "node:os";
32
import path from "node:path";
43
import { describe, expect, it } from "vitest";
4+
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
55
import { listChannelPluginCatalogEntries } from "../../catalog.js";
66

77
function createCatalogEntry(params: {
@@ -122,7 +122,9 @@ export function describeChannelPluginCatalogEntriesContract() {
122122
{
123123
name: "includes external catalog entries",
124124
setup: () => {
125-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-"));
125+
const dir = fs.mkdtempSync(
126+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-"),
127+
);
126128
const catalogPath = path.join(dir, "catalog.json");
127129
writeCatalogFile(
128130
catalogPath,
@@ -145,7 +147,7 @@ export function describeChannelPluginCatalogEntriesContract() {
145147
name: "preserves plugin ids when they differ from channel ids",
146148
setup: () => {
147149
const stateDir = fs.mkdtempSync(
148-
path.join(os.tmpdir(), "openclaw-channel-catalog-state-"),
150+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-channel-catalog-state-"),
149151
);
150152
writeDiscoveredChannelPlugin({
151153
stateDir,
@@ -168,7 +170,9 @@ export function describeChannelPluginCatalogEntriesContract() {
168170
{
169171
name: "keeps discovered plugins ahead of external catalog overrides",
170172
setup: () => {
171-
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-state-"));
173+
const stateDir = fs.mkdtempSync(
174+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-state-"),
175+
);
172176
const catalogPath = path.join(stateDir, "catalog.json");
173177
writeDiscoveredChannelPlugin({
174178
stateDir,
@@ -206,7 +210,9 @@ export function describeChannelPluginCatalogEntriesContract() {
206210
{
207211
name: "accepts rich external manifest entries with pinned npm metadata",
208212
setup: () => {
209-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-rich-"));
213+
const dir = fs.mkdtempSync(
214+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-rich-"),
215+
);
210216
const catalogPath = path.join(dir, "catalog.json");
211217
fs.writeFileSync(
212218
catalogPath,
@@ -284,7 +290,9 @@ export function describeChannelPluginCatalogEntriesContract() {
284290
{
285291
name: "accepts rich external manifest entries for yuanbao with pinned npm metadata",
286292
setup: () => {
287-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-yuanbao-"));
293+
const dir = fs.mkdtempSync(
294+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-yuanbao-"),
295+
);
288296
const catalogPath = path.join(dir, "catalog.json");
289297
fs.writeFileSync(
290298
catalogPath,
@@ -365,7 +373,9 @@ export function describeChannelPluginCatalogPathResolutionContract() {
365373
{
366374
name: "uses the provided env for external catalog path resolution",
367375
setup: () => {
368-
const home = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-home-"));
376+
const home = fs.mkdtempSync(
377+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-home-"),
378+
);
369379
const catalogPath = path.join(home, "catalog.json");
370380
writeCatalogFile(
371381
catalogPath,
@@ -391,7 +401,9 @@ export function describeChannelPluginCatalogPathResolutionContract() {
391401
{
392402
name: "uses the provided env for default catalog paths",
393403
setup: () => {
394-
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-catalog-state-"));
404+
const stateDir = fs.mkdtempSync(
405+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-catalog-state-"),
406+
);
395407
const catalogPath = path.join(stateDir, "plugins", "catalog.json");
396408
fs.mkdirSync(path.dirname(catalogPath), { recursive: true });
397409
writeCatalogFile(

src/channels/plugins/contracts/test-helpers/registry-session-binding.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import fs from "node:fs";
2-
import os from "node:os";
32
import path from "node:path";
43
import { expect } from "vitest";
54
import type { OpenClawConfig } from "../../../../config/config.js";
@@ -8,6 +7,7 @@ import {
87
type SessionBindingCapabilities,
98
type SessionBindingRecord,
109
} from "../../../../infra/outbound/session-binding-service.js";
10+
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
1111
import { setActivePluginRegistry } from "../../../../plugins/runtime.js";
1212
import { createTestRegistry } from "../../../../test-utils/channel-plugins.js";
1313
import { createChannelConversationBindingManager } from "../../conversation-bindings.js";
@@ -31,7 +31,7 @@ type SessionBindingContractEntry = {
3131
const contractApiPromises = new Map<string, Promise<Record<string, unknown>>>();
3232

3333
const matrixSessionBindingStateDir = fs.mkdtempSync(
34-
path.join(os.tmpdir(), "openclaw-matrix-session-binding-contract-"),
34+
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-matrix-session-binding-contract-"),
3535
);
3636
const matrixSessionBindingAuth = {
3737
accountId: "ops",

0 commit comments

Comments
 (0)