Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { access, mkdir, rm, writeFile } from "node:fs/promises";
import { join } from "node:path";

import { afterEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

import { turnWorkflowReference, workflowEntryReference } from "#execution/workflow-runtime.js";
import { useTemporaryDirectories } from "#internal/testing/use-temporary-app-roots.js";
Expand Down Expand Up @@ -37,11 +37,16 @@ const QUEUE_PREFIX = deriveEveWorkflowQueuePrefix(AGENT_NAME);

const originalFetch = globalThis.fetch;

beforeEach(() => {
vi.stubEnv("WORKFLOW_LOCAL_DATA_DIR", "");
});

afterEach(() => {
globalThis.fetch = originalFetch;
delete process.env[DEVELOPMENT_WORKFLOW_SECRET_ENV];
delete process.env[DEVELOPMENT_WORKER_APP_ROOT_ENV];
delete process.env.WORKFLOW_LOCAL_BASE_URL;
vi.unstubAllEnvs();
});

describe("parent development Workflow World", () => {
Expand All @@ -62,6 +67,23 @@ describe("parent development Workflow World", () => {
}
});

it("honors the local Workflow data directory override", async () => {
const appRoot = await createScratchDirectory("eve-parent-workflow-app-");
const dataDirectory = await createScratchDirectory("eve-parent-workflow-data-");
vi.stubEnv("WORKFLOW_LOCAL_DATA_DIR", dataDirectory);
const world = createWorld({ activeGenerationId: () => "generation-a", appRoot });

try {
await world.start();
await expect(access(join(dataDirectory, "version.txt"))).resolves.toBeUndefined();
await expect(
access(join(appRoot, LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH)),
).rejects.toMatchObject({ code: "ENOENT" });
} finally {
await world.close();
}
});

it("pins a turn delivery to its recorded generation", async () => {
const appRoot = await createScratchDirectory("eve-parent-workflow-world-");
await seedGeneration(appRoot, "generation-a");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ import { join } from "node:path";
export const LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH = ".eve/.workflow-data";

export function resolveLocalWorkflowWorldDataDirectory(appRoot: string): string {
return join(appRoot, LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH);
return (
process.env.WORKFLOW_LOCAL_DATA_DIR ||
join(appRoot, LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH)
);
}
Loading