Return release version from getProxyBinaryPath

This commit is contained in:
Michael B. Gale
2026-10-13 19:06:14 +01:00
parent aa80ca0686
commit 6308e366c9
4 changed files with 34 additions and 11 deletions

7
lib/entry-points.js generated
View File

@@ -187870,7 +187870,10 @@ async function getProxyBinaryPath(action) {
proxyInfo.version
);
}
return path27.join(proxyBin, proxyFileName);
return {
path: path27.join(proxyBin, proxyFileName),
version: proxyInfo.version
};
}
// src/start-proxy/ca.ts
@@ -188235,7 +188238,7 @@ async function run7(action) {
const actionWithFeatures = extendActionState(action, { features });
const proxyBin = await getProxyBinaryPath(actionWithFeatures);
const proxyInfo = await startProxy(
proxyBin,
proxyBin.path,
proxyConfig,
proxyLogFilePath,
logger2

View File

@@ -106,7 +106,7 @@ async function run(action: ActionState<["Base", "Logger", "Env", "Actions"]>) {
const actionWithFeatures = extendActionState(action, { features });
const proxyBin = await getProxyBinaryPath(actionWithFeatures);
const proxyInfo = await startProxy(
proxyBin,
proxyBin.path,
proxyConfig,
proxyLogFilePath,
logger,

View File

@@ -886,9 +886,10 @@ test.serial(
t.assert(path);
t.is(
path,
path.path,
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
);
t.is(path.version, startProxyExports.UPDATEJOB_PROXY_VERSION);
});
},
);
@@ -939,9 +940,10 @@ test.serial(
t.assert(cacheDir.calledOnceWith(extractedPath));
t.assert(path);
t.is(
path,
path.path,
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
);
t.is(path.version, defaults.cliVersion);
checkExpectedLogMessages(t, logger.messages, [
`Found '${startProxyExports.getProxyPackage(getTestPlatform(state))}' in release '${defaults.bundleVersion}' at '${downloadUrl}'`,
@@ -954,7 +956,8 @@ test.serial(
async (t) => {
const logger = new RecordingLogger();
const state = initAllState({ logger });
const expectedTag = "codeql-bundle-v2.20.1";
const expectedVersion = "2.20.1";
const expectedTag = `codeql-bundle-v${expectedVersion}`;
const expectedParams = {
owner: "github",
repo: "codeql-action",
@@ -1012,7 +1015,9 @@ test.serial(
const getDefaultCliVersion = sinon
.stub(features, "getEnabledDefaultCliVersions")
.resolves({
enabledVersions: [{ cliVersion: "2.20.1", tagName: expectedTag }],
enabledVersions: [
{ cliVersion: expectedVersion, tagName: expectedTag },
],
});
const path = await startProxyExports.getProxyBinaryPath({
...state,
@@ -1033,9 +1038,10 @@ test.serial(
t.assert(path);
t.is(
path,
path.path,
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
);
t.is(path.version, expectedVersion);
});
checkExpectedLogMessages(t, logger.messages, [

View File

@@ -428,17 +428,27 @@ export function getProxyFilename() {
: UPDATEJOB_PROXY;
}
export type ProxyBinary = {
/** The path to the proxy binary to run. */
path: string;
/**
* The version associated with the proxy binary.
* This usually corresponds to the CodeQL CLI release that the binary was obtained from.
*/
version: string;
};
/**
* Gets a path to the proxy binary. If possible, this function will find the proxy in the
* runner's tool cache. Otherwise, it downloads and extracts the proxy binary,
* and stores it in the tool cache.
*
* @param action The action state.
* @returns The path to the proxy binary.
* @returns The path to the proxy binary and its version.
*/
export async function getProxyBinaryPath(
action: ActionState<["Base", "Logger", "FeatureFlags"]>,
): Promise<string> {
): Promise<ProxyBinary> {
const logger = action.logger;
const proxyFileName = getProxyFilename();
const proxyInfo = await getDownloadUrl(action);
@@ -460,5 +470,9 @@ export async function getProxyBinaryPath(
proxyInfo.version,
);
}
return path.join(proxyBin, proxyFileName);
return {
path: path.join(proxyBin, proxyFileName),
version: proxyInfo.version,
};
}