Skip to content

Commit 6308e36

Browse files
committed
Return release version from getProxyBinaryPath
1 parent aa80ca0 commit 6308e36

4 files changed

Lines changed: 34 additions & 11 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/start-proxy-action.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function run(action: ActionState<["Base", "Logger", "Env", "Actions"]>) {
106106
const actionWithFeatures = extendActionState(action, { features });
107107
const proxyBin = await getProxyBinaryPath(actionWithFeatures);
108108
const proxyInfo = await startProxy(
109-
proxyBin,
109+
proxyBin.path,
110110
proxyConfig,
111111
proxyLogFilePath,
112112
logger,

‎src/start-proxy.test.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,10 @@ test.serial(
886886

887887
t.assert(path);
888888
t.is(
889-
path,
889+
path.path,
890890
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
891891
);
892+
t.is(path.version, startProxyExports.UPDATEJOB_PROXY_VERSION);
892893
});
893894
},
894895
);
@@ -939,9 +940,10 @@ test.serial(
939940
t.assert(cacheDir.calledOnceWith(extractedPath));
940941
t.assert(path);
941942
t.is(
942-
path,
943+
path.path,
943944
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
944945
);
946+
t.is(path.version, defaults.cliVersion);
945947

946948
checkExpectedLogMessages(t, logger.messages, [
947949
`Found '${startProxyExports.getProxyPackage(getTestPlatform(state))}' in release '${defaults.bundleVersion}' at '${downloadUrl}'`,
@@ -954,7 +956,8 @@ test.serial(
954956
async (t) => {
955957
const logger = new RecordingLogger();
956958
const state = initAllState({ logger });
957-
const expectedTag = "codeql-bundle-v2.20.1";
959+
const expectedVersion = "2.20.1";
960+
const expectedTag = `codeql-bundle-v${expectedVersion}`;
958961
const expectedParams = {
959962
owner: "github",
960963
repo: "codeql-action",
@@ -1012,7 +1015,9 @@ test.serial(
10121015
const getDefaultCliVersion = sinon
10131016
.stub(features, "getEnabledDefaultCliVersions")
10141017
.resolves({
1015-
enabledVersions: [{ cliVersion: "2.20.1", tagName: expectedTag }],
1018+
enabledVersions: [
1019+
{ cliVersion: expectedVersion, tagName: expectedTag },
1020+
],
10161021
});
10171022
const path = await startProxyExports.getProxyBinaryPath({
10181023
...state,
@@ -1033,9 +1038,10 @@ test.serial(
10331038

10341039
t.assert(path);
10351040
t.is(
1036-
path,
1041+
path.path,
10371042
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
10381043
);
1044+
t.is(path.version, expectedVersion);
10391045
});
10401046

10411047
checkExpectedLogMessages(t, logger.messages, [

‎src/start-proxy.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,17 +428,27 @@ export function getProxyFilename() {
428428
: UPDATEJOB_PROXY;
429429
}
430430

431+
export type ProxyBinary = {
432+
/** The path to the proxy binary to run. */
433+
path: string;
434+
/**
435+
* The version associated with the proxy binary.
436+
* This usually corresponds to the CodeQL CLI release that the binary was obtained from.
437+
*/
438+
version: string;
439+
};
440+
431441
/**
432442
* Gets a path to the proxy binary. If possible, this function will find the proxy in the
433443
* runner's tool cache. Otherwise, it downloads and extracts the proxy binary,
434444
* and stores it in the tool cache.
435445
*
436446
* @param action The action state.
437-
* @returns The path to the proxy binary.
447+
* @returns The path to the proxy binary and its version.
438448
*/
439449
export async function getProxyBinaryPath(
440450
action: ActionState<["Base", "Logger", "FeatureFlags"]>,
441-
): Promise<string> {
451+
): Promise<ProxyBinary> {
442452
const logger = action.logger;
443453
const proxyFileName = getProxyFilename();
444454
const proxyInfo = await getDownloadUrl(action);
@@ -460,5 +470,9 @@ export async function getProxyBinaryPath(
460470
proxyInfo.version,
461471
);
462472
}
463-
return path.join(proxyBin, proxyFileName);
473+
474+
return {
475+
path: path.join(proxyBin, proxyFileName),
476+
version: proxyInfo.version,
477+
};
464478
}

0 commit comments

Comments
 (0)