Skip to content
Merged
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
2 changes: 1 addition & 1 deletion scripts/agent-evals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "tsc",
"test": "npm run build && mocha 'lib/**/*.spec.js' --reporter spec",
"test:dev": "SKIP_REBUILD=true npm run test"
"test:dev": "SKIP_REBUILD=true COPY_FIREBASE_CLI_CONFIG=true npm run test"
},
"keywords": [],
"author": "",
Expand Down
33 changes: 32 additions & 1 deletion scripts/agent-evals/src/runner/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "node:path";
import os from "node:os";
import { randomBytes } from "node:crypto";
import { mkdirSync } from "node:fs";
import { mkdirSync, copyFileSync } from "node:fs";
import { AgentTestRunner } from "./agent-test-runner.js";
import { GeminiCliRunner } from "./gemini-cli-runner.js";
import { buildFirebaseCli } from "./setup.js";
Expand All @@ -13,7 +14,11 @@

const dateName = new Date().toISOString().replace("T", "_").replace(/:/g, "-").replace(".", "-");

const FIREBASE_CONFIG_FILENAME = "firebase-tools.json";
const CONFIGSTORE_DIR = ".config/configstore";
const HOME_CONFIGSTORE_DIR = path.resolve(path.join(os.homedir(), CONFIGSTORE_DIR));

export async function setupEnvironment(): Promise<void> {

Check warning on line 21 in scripts/agent-evals/src/runner/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
await buildFirebaseCli();
await buildTemplates();
}
Expand All @@ -27,7 +32,7 @@
toolMocks?: ToolMockName[];
}

export async function startAgentTest(

Check warning on line 35 in scripts/agent-evals/src/runner/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
mocha: Mocha.Context,
options?: AgentTestOptions,
): Promise<AgentTestRunner> {
Expand All @@ -40,6 +45,13 @@
if (options?.templateName) {
copyTemplate(options.templateName, dirs.runDir);
}
if (process.env.COPY_FIREBASE_CLI_CONFIG) {
const toDir = path.resolve(dirs.userDir, CONFIGSTORE_DIR);
console.log(
`Copying Firebase CLI configs from ${HOME_CONFIGSTORE_DIR} to \n${toDir} so the test can use your auth credentials`,
);
copyFirebaseCliConfigstore(HOME_CONFIGSTORE_DIR, toDir);
}

const run = new GeminiCliRunner(testName, dirs, options?.toolMocks || []);
await run.waitForReadyPrompt();
Expand All @@ -65,3 +77,22 @@

return { testDir, runDir, userDir };
}

function copyFirebaseCliConfigstore(fromDir: string, toDir: string) {

Check warning on line 81 in scripts/agent-evals/src/runner/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
mkdirSync(toDir, { recursive: true });
try {
copyFileSync(
path.join(fromDir, FIREBASE_CONFIG_FILENAME),
path.join(toDir, FIREBASE_CONFIG_FILENAME),
);
} catch (e: any) {

Check warning on line 88 in scripts/agent-evals/src/runner/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (e.code === "ENOENT") {

Check warning on line 89 in scripts/agent-evals/src/runner/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .code on an `any` value
const sourceFile = path.join(fromDir, FIREBASE_CONFIG_FILENAME);
console.warn(
`Firebase CLI config file not found at ${sourceFile}. Skipping copy. If you want to use your local Firebase login, please log in with the Firebase CLI.`,
);
} else {
throw e;
}
}
}
Loading