Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use separate API for wingman #6

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/__tests__/wingman.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { downloadTool } from "@actions/tool-cache";
import { exec } from "@actions/exec";

import { WingmanClient } from "../wingman";
import { getFlyCIUrl } from "../utils";
import { getFlyCIUrl, getWingmanUrl } from "../utils";

jest.mock("@actions/tool-cache");
jest.mock("@actions/exec");
Expand Down Expand Up @@ -75,7 +75,7 @@ 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"),
}),
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ 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;

return `${url}${path}`;
};

export const getWingmanUrl = () => core.getInput("wingman-url") || WINGMAN_URL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a unit test for the scenario when the URL is passed as input?


const getOidcToken = () => core.getIDToken(getFlyCIUrl());

export const getAccessToken = async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/wingman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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"),
};
Expand Down