diff --git a/lib/entry-points.js b/lib/entry-points.js index f3d3022b0..00309ef50 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -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 diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index bc3351da5..9f96e1503 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -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, diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index 86bb99348..66edd0c62 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -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, [ diff --git a/src/start-proxy.ts b/src/start-proxy.ts index 84ed5fb17..e22346d3a 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -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 { +): Promise { 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, + }; }