diff --git a/dist/index.js b/dist/index.js index cd6d22e..4e757fa 100644 --- a/dist/index.js +++ b/dist/index.js @@ -22002,10 +22002,12 @@ var core = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var import_auth = __toESM(require_auth()); var FLYCI_URL = "https://api.flyci.net"; +var WINGMAN_URL = "https://wingman.flyci.net"; var getFlyCIUrl = (path = "") => { const url = core.getInput("flyci-url") || FLYCI_URL; return `${url}${path}`; }; +var getWingmanUrl = () => core.getInput("wingman-url") || WINGMAN_URL; var getOidcToken = () => core.getIDToken(getFlyCIUrl()); var getAccessToken = async () => { const oidcToken = await getOidcToken(); @@ -22051,7 +22053,7 @@ var WingmanClient = class _WingmanClient { run = async () => { const env = { ...process.env, - LLM_SERVER_URL: getFlyCIUrl(), + LLM_SERVER_URL: getWingmanUrl(), LLM_API_KEY: this.accessToken, FLYCI_WINGMAN_OUTPUT_FILE: import_node_path.default.join(getTempDir(), "wingman.json") }; diff --git a/src/__tests__/wingman.test.ts b/src/__tests__/wingman.test.ts index 057b4bb..8515d71 100644 --- a/src/__tests__/wingman.test.ts +++ b/src/__tests__/wingman.test.ts @@ -4,10 +4,13 @@ import fs from "node:fs/promises"; import { downloadTool } from "@actions/tool-cache"; import { exec } from "@actions/exec"; +import { getInput } from "@actions/core"; import { WingmanClient } from "../wingman"; -import { getFlyCIUrl } from "../utils"; - +import { getFlyCIUrl, getWingmanUrl } from "../utils"; +jest.mock("@actions/core", () => ({ + getInput: jest.fn(), +})); jest.mock("@actions/tool-cache"); jest.mock("@actions/exec"); @@ -20,6 +23,7 @@ describe("WingmanClient", () => { const accessToken = "secret-access-token"; const mockDownloadTool = downloadTool as jest.Mock; const mockExec = exec as jest.Mock; + const mockGetInput = getInput as jest.Mock; const downloadWingman = async () => { mockDownloadTool.mockResolvedValueOnce(path); @@ -75,13 +79,30 @@ describe("WingmanClient", () => { expect(exec).toHaveBeenCalledExactlyOnceWith(path, [], { env: expect.objectContaining({ - LLM_SERVER_URL: getFlyCIUrl(), + LLM_SERVER_URL: getWingmanUrl(), LLM_API_KEY: accessToken, FLYCI_WINGMAN_OUTPUT_FILE: p.join(tmpPath, "wingman.json"), }), }); }); + it("when wingman url input is set should use it", async () => { + mockGetInput.mockReturnValue("mock-url"); + + mockExec.mockResolvedValueOnce(0); + + const wingman = await downloadWingman(); + + await wingman.run(); + + expect(mockGetInput).toHaveBeenNthCalledWith(2, "wingman-url"); + expect(exec).toHaveBeenCalledExactlyOnceWith(path, [], { + env: expect.objectContaining({ + LLM_SERVER_URL: "mock-url", + }), + }); + }); + it("when wingman execution exits with 0 exit code should return the output file path", async () => { mockExec.mockResolvedValueOnce(0); diff --git a/src/utils.ts b/src/utils.ts index 88eeb73..59562fa 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -5,6 +5,7 @@ import { HttpClient } from "@actions/http-client"; import { BearerCredentialHandler } from "@actions/http-client/lib/auth"; export const FLYCI_URL = "https://api.flyci.net"; +export const WINGMAN_URL = "https://wingman.flyci.net"; export const getFlyCIUrl = (path: string = "") => { const url = core.getInput("flyci-url") || FLYCI_URL; @@ -12,6 +13,8 @@ export const getFlyCIUrl = (path: string = "") => { return `${url}${path}`; }; +export const getWingmanUrl = () => core.getInput("wingman-url") || WINGMAN_URL; + const getOidcToken = () => core.getIDToken(getFlyCIUrl()); export const getAccessToken = async () => { diff --git a/src/wingman.ts b/src/wingman.ts index a8185b7..6b6fc25 100644 --- a/src/wingman.ts +++ b/src/wingman.ts @@ -6,7 +6,7 @@ import fs from "node:fs/promises"; import { exec } from "@actions/exec"; import { downloadTool } from "@actions/tool-cache"; -import { getFlyCIUrl, getTempDir } from "./utils"; +import { getFlyCIUrl, getTempDir, getWingmanUrl } from "./utils"; const getWingmanDestinationPath = (platform: string) => { return p.format({ @@ -43,7 +43,7 @@ export class WingmanClient { run = async () => { const env = { ...process.env, - LLM_SERVER_URL: getFlyCIUrl(), + LLM_SERVER_URL: getWingmanUrl(), LLM_API_KEY: this.accessToken, FLYCI_WINGMAN_OUTPUT_FILE: p.join(getTempDir(), "wingman.json"), };