diff --git a/lib/entry-points.js b/lib/entry-points.js index d7de1c833..afb99c091 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -193985,12 +193985,6 @@ async function checkRunnerSupportsTracedAnalysis(action, config, codeql) { ); return; } - if (isSelfHostedRunner(action.env)) { - action.logger.debug( - "Skipping traced analysis compatibility checks because we are on a self-hosted runner." - ); - return; - } if (config.buildMode !== void 0 && config.buildMode === "none") { action.logger.debug( "Skipping traced analysis compatibility checks because the build mode is 'none'." @@ -194028,6 +194022,12 @@ async function checkRunnerSupportsTracedAnalysis(action, config, codeql) { ); return; } + if (isSelfHostedRunner(action.env)) { + action.logger.debug( + "Skipping traced analysis compatibility check for Xcode because we are on a self-hosted runner." + ); + return; + } const xcodeVer = xcodeVersion(action.logger); if (xcodeVer !== void 0 && xcodeVer.major >= UNSUPPORTED_XCODE_FOR_TRACED) { handleUnsupportedVersion( diff --git a/src/languages/traced.test.ts b/src/languages/traced.test.ts index d37a742f6..d5b377b9c 100644 --- a/src/languages/traced.test.ts +++ b/src/languages/traced.test.ts @@ -170,38 +170,6 @@ test("checkRunnerSupportsTracedAnalysis doesn't perform checks if FF is not enab ]); })); -test("checkRunnerSupportsTracedAnalysis doesn't perform checks on self-hosted runners", async (t) => - withTmpDir(async (tmpDir) => { - const logger = new RecordingLogger(); - const env = getTestEnv(); - env.set(ActionsEnvVars.RUNNER_TEMP, tmpDir); - env.set(ActionsEnvVars.RUNNER_ENVIRONMENT, "self-hosted"); - const features = createFeatures([Feature.CheckUnsupportedTracedAnalysis]); - - const codeql = await getCodeQLWithTracedStub( - "codeql-for-testing", - logger, - env, - ); - sinon.stub(codeql, "getVersion").resolves(makeVersionInfo("2.27.0")); - - await checkRunnerSupportsTracedAnalysis( - initAllState({ - logger, - platform: "darwin", - osRelease: "unexpected", - env, - features, - }), - createTestConfig({ languages: [BuiltInLanguage.go] }), - codeql, - ); - - checkUnexpectedLogMessages(t, logger.messages, [ - "Unable to parse Darwin kernel version, got: unexpected", - ]); - })); - test("checkRunnerSupportsTracedAnalysis warns if version string is not a semver", async (t) => withTmpDir(async (tmpDir) => { const logger = new RecordingLogger(); @@ -355,6 +323,38 @@ test.serial( }), ); +test("checkRunnerSupportsTracedAnalysis doesn't perform Xcode check on self-hosted runners", async (t) => + withTmpDir(async (tmpDir) => { + const logger = new RecordingLogger(); + const env = getTestEnv(); + env.set(ActionsEnvVars.RUNNER_TEMP, tmpDir); + env.set(ActionsEnvVars.RUNNER_ENVIRONMENT, "self-hosted"); + const features = createFeatures([Feature.CheckUnsupportedTracedAnalysis]); + + const codeql = await getCodeQLWithTracedStub( + "codeql-for-testing", + logger, + env, + ); + sinon.stub(codeql, "getVersion").resolves(makeVersionInfo("2.27.0")); + + await checkRunnerSupportsTracedAnalysis( + initAllState({ + logger, + platform: "darwin", + osRelease: "27.0.0", + env, + features, + }), + createTestConfig({ languages: [BuiltInLanguage.go] }), + codeql, + ); + + checkUnexpectedLogMessages(t, logger.messages, [ + "Skipping traced analysis compatibility check for Xcode because we are on a self-hosted runner.", + ]); + })); + // `addDiagnostic` changes global state and we must stub it, so this test must be serial. test.serial( "checkRunnerSupportsTracedAnalysis doesn't add a diagnostic if Xcode version is supported", diff --git a/src/languages/traced.ts b/src/languages/traced.ts index 816ff2f80..7d73595cf 100644 --- a/src/languages/traced.ts +++ b/src/languages/traced.ts @@ -134,15 +134,6 @@ export async function checkRunnerSupportsTracedAnalysis( return; } - // Skip if we are on a self-hosted runner since the current Xcode version detection - // is only validated on hosted runners. - if (isSelfHostedRunner(action.env)) { - action.logger.debug( - "Skipping traced analysis compatibility checks because we are on a self-hosted runner.", - ); - return; - } - // `build-mode: none` doesn't use the tracer, so it is always supported. if (config.buildMode !== undefined && config.buildMode === "none") { action.logger.debug( @@ -191,6 +182,15 @@ export async function checkRunnerSupportsTracedAnalysis( return; } + // Skip if we are on a self-hosted runner since the current Xcode version detection + // is only validated on hosted runners. + if (isSelfHostedRunner(action.env)) { + action.logger.debug( + "Skipping traced analysis compatibility check for Xcode because we are on a self-hosted runner.", + ); + return; + } + // Determining whether the Xcode version is supported only makes sense on macOS, so we only do it // after determining that we are running on macOS. const xcodeVer = xcodeVersion(action.logger);