fix(ci): pin gradle and normalize gemini cli test paths

This commit is contained in:
Peter Steinberger
2026-01-25 15:26:52 +00:00
parent 4f82de3dcc
commit c8063bdcd8
2 changed files with 95 additions and 16 deletions

View File

@@ -628,6 +628,8 @@ jobs:
- name: Setup Gradle - name: Setup Gradle
uses: gradle/actions/setup-gradle@v4 uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.11.1
- name: Install Android SDK packages - name: Install Android SDK packages
run: | run: |

View File

@@ -1,5 +1,5 @@
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
import { join } from "node:path"; import { join, parse } from "node:path";
// Mock fs module before importing the module under test // Mock fs module before importing the module under test
const mockExistsSync = vi.fn(); const mockExistsSync = vi.fn();
@@ -19,7 +19,9 @@ vi.mock("node:fs", async (importOriginal) => {
}); });
describe("extractGeminiCliCredentials", () => { describe("extractGeminiCliCredentials", () => {
const normalizePath = (value: string) => value.replace(/\\/g, "/"); const normalizePath = (value: string) =>
value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
const rootDir = parse(process.cwd()).root || "/";
const FAKE_CLIENT_ID = "123456789-abcdef.apps.googleusercontent.com"; const FAKE_CLIENT_ID = "123456789-abcdef.apps.googleusercontent.com";
const FAKE_CLIENT_SECRET = "GOCSPX-FakeSecretValue123"; const FAKE_CLIENT_SECRET = "GOCSPX-FakeSecretValue123";
const FAKE_OAUTH2_CONTENT = ` const FAKE_OAUTH2_CONTENT = `
@@ -49,11 +51,33 @@ describe("extractGeminiCliCredentials", () => {
}); });
it("extracts credentials from oauth2.js in known path", async () => { it("extracts credentials from oauth2.js in known path", async () => {
const fakeBinDir = "/fake/bin"; const fakeBinDir = join(rootDir, "fake", "bin");
const fakeGeminiPath = join(fakeBinDir, "gemini"); const fakeGeminiPath = join(fakeBinDir, "gemini");
const fakeResolvedPath = "/fake/lib/node_modules/@google/gemini-cli/dist/index.js"; const fakeResolvedPath = join(
const fakeOauth2Path = rootDir,
"/fake/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/oauth2.js"; "fake",
"lib",
"node_modules",
"@google",
"gemini-cli",
"dist",
"index.js",
);
const fakeOauth2Path = join(
rootDir,
"fake",
"lib",
"node_modules",
"@google",
"gemini-cli",
"node_modules",
"@google",
"gemini-cli-core",
"dist",
"src",
"code_assist",
"oauth2.js",
);
process.env.PATH = fakeBinDir; process.env.PATH = fakeBinDir;
@@ -77,9 +101,18 @@ describe("extractGeminiCliCredentials", () => {
}); });
it("returns null when oauth2.js cannot be found", async () => { it("returns null when oauth2.js cannot be found", async () => {
const fakeBinDir = "/fake/bin"; const fakeBinDir = join(rootDir, "fake", "bin");
const fakeGeminiPath = join(fakeBinDir, "gemini"); const fakeGeminiPath = join(fakeBinDir, "gemini");
const fakeResolvedPath = "/fake/lib/node_modules/@google/gemini-cli/dist/index.js"; const fakeResolvedPath = join(
rootDir,
"fake",
"lib",
"node_modules",
"@google",
"gemini-cli",
"dist",
"index.js",
);
process.env.PATH = fakeBinDir; process.env.PATH = fakeBinDir;
@@ -95,11 +128,33 @@ describe("extractGeminiCliCredentials", () => {
}); });
it("returns null when oauth2.js lacks credentials", async () => { it("returns null when oauth2.js lacks credentials", async () => {
const fakeBinDir = "/fake/bin"; const fakeBinDir = join(rootDir, "fake", "bin");
const fakeGeminiPath = join(fakeBinDir, "gemini"); const fakeGeminiPath = join(fakeBinDir, "gemini");
const fakeResolvedPath = "/fake/lib/node_modules/@google/gemini-cli/dist/index.js"; const fakeResolvedPath = join(
const fakeOauth2Path = rootDir,
"/fake/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/oauth2.js"; "fake",
"lib",
"node_modules",
"@google",
"gemini-cli",
"dist",
"index.js",
);
const fakeOauth2Path = join(
rootDir,
"fake",
"lib",
"node_modules",
"@google",
"gemini-cli",
"node_modules",
"@google",
"gemini-cli-core",
"dist",
"src",
"code_assist",
"oauth2.js",
);
process.env.PATH = fakeBinDir; process.env.PATH = fakeBinDir;
@@ -118,11 +173,33 @@ describe("extractGeminiCliCredentials", () => {
}); });
it("caches credentials after first extraction", async () => { it("caches credentials after first extraction", async () => {
const fakeBinDir = "/fake/bin"; const fakeBinDir = join(rootDir, "fake", "bin");
const fakeGeminiPath = join(fakeBinDir, "gemini"); const fakeGeminiPath = join(fakeBinDir, "gemini");
const fakeResolvedPath = "/fake/lib/node_modules/@google/gemini-cli/dist/index.js"; const fakeResolvedPath = join(
const fakeOauth2Path = rootDir,
"/fake/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/oauth2.js"; "fake",
"lib",
"node_modules",
"@google",
"gemini-cli",
"dist",
"index.js",
);
const fakeOauth2Path = join(
rootDir,
"fake",
"lib",
"node_modules",
"@google",
"gemini-cli",
"node_modules",
"@google",
"gemini-cli-core",
"dist",
"src",
"code_assist",
"oauth2.js",
);
process.env.PATH = fakeBinDir; process.env.PATH = fakeBinDir;