From 97b90230e5548caa99fc7149ed756e3b4e71a1ca Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Wed, 28 Oct 2026 12:27:23 +0000 Subject: [PATCH] Clarify that we are looking at the Darwin version --- lib/entry-points.js | 18 +++++++++--------- src/languages/swift.ts | 8 ++++---- src/languages/traced.test.ts | 4 ++-- src/languages/traced.ts | 16 ++++++++-------- src/platform.test.ts | 14 +++++++------- src/platform.ts | 7 ++++--- 6 files changed, 34 insertions(+), 33 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 20469ed70..46736e51e 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -183429,7 +183429,7 @@ function getBundlePlatform(platform2 = process.platform, arch2 = process.arch) { return void 0; } } -function macOSVersion(action) { +function darwinVersion(action) { if (action.platform !== "darwin") { return void 0; } @@ -193906,14 +193906,14 @@ async function getToolsInput(action, repositoryProperties) { } // src/languages/swift.ts -async function checkSwiftCompatibility(config, codeql, macosVersion) { +async function checkSwiftCompatibility(config, codeql, darwinVersion2) { if (!config.languages.includes("swift" /* swift */)) { return; } if (await codeql.supportsFeature("swiftSupportsAllPlatforms" /* SwiftSupportsAllPlatforms */)) { return; } - if (macosVersion === void 0) { + if (darwinVersion2 === void 0) { throw new ConfigurationError( `Swift analysis is only supported on macOS runner images. Please migrate to a macOS runner.` ); @@ -193921,15 +193921,15 @@ async function checkSwiftCompatibility(config, codeql, macosVersion) { } // src/languages/traced.ts -var UNSUPPORTED_MACOS_FOR_TRACED = 27; +var UNSUPPORTED_DARWIN_FOR_TRACED = 27; var UNSUPPORTED_XCODE_FOR_TRACED = 27; function handleUnsupportedVersion(logger2, config, skipUnsupportedTracedAnalysis, product, version) { const baseMessage = [ - `Traced analysis is not supported on ${product} ${UNSUPPORTED_MACOS_FOR_TRACED} or above.`, - `Configure your analysis to run on macOS ${UNSUPPORTED_MACOS_FOR_TRACED - 1} or below`, + `Traced analysis is not supported on ${product} ${UNSUPPORTED_DARWIN_FOR_TRACED} or above.`, + `Configure your analysis to run on macOS ${UNSUPPORTED_DARWIN_FOR_TRACED - 1} or below`, `and XCode ${UNSUPPORTED_XCODE_FOR_TRACED - 1} or below.` ].join(" "); - const attributeName = product === "macOS" ? "macOSVersion" : "xcodeVersion"; + const attributeName = product === "macOS" ? "darwinVersion" : "xcodeVersion"; for (const language of config.languages) { addDiagnostic( config, @@ -193975,7 +193975,7 @@ async function hasTracedLanguages(config, codeql) { return false; } async function checkRunnerSupportsTracedAnalysis(action, config, codeql) { - const version = macOSVersion(action); + const version = darwinVersion(action); await checkSwiftCompatibility(config, codeql, version); if (config.buildMode !== void 0 && config.buildMode === "none") { return; @@ -193990,7 +193990,7 @@ async function checkRunnerSupportsTracedAnalysis(action, config, codeql) { action.logger.warning( `Unable to determine version of macOS, got: ${version}` ); - } else if (version !== void 0 && version.major >= UNSUPPORTED_MACOS_FOR_TRACED) { + } else if (version !== void 0 && version.major >= UNSUPPORTED_DARWIN_FOR_TRACED) { handleUnsupportedVersion( action.logger, config, diff --git a/src/languages/swift.ts b/src/languages/swift.ts index 45ca87416..e617684e0 100644 --- a/src/languages/swift.ts +++ b/src/languages/swift.ts @@ -12,14 +12,14 @@ import { BuiltInLanguage } from "."; * * @param config The Action configuration. * @param codeql The {@link CodeQL} CLI instance. - * @param macosVersion The version of macOS, if any. + * @param darwinVersion The version of the Darwin kernel on macOS, if any. * * @throws {ConfigurationError} If Swift analysis is not possible on the current runner. */ export async function checkSwiftCompatibility( config: ActionConfig<"languages">, codeql: CodeQL, - macosVersion: SemVer | string | undefined, + darwinVersion: SemVer | string | undefined, ) { // The checks are not relevant if we are not trying to analyse Swift. if (!config.languages.includes(BuiltInLanguage.swift)) { @@ -33,8 +33,8 @@ export async function checkSwiftCompatibility( return; } - // If `macosVersion` is undefined, then we are not on macOS and Swift analysis is unsupported. - if (macosVersion === undefined) { + // If `darwinVersion` is undefined, then we are not on macOS and Swift analysis is unsupported. + if (darwinVersion === undefined) { throw new ConfigurationError( `Swift analysis is only supported on macOS runner images. Please migrate to a macOS runner.`, ); diff --git a/src/languages/traced.test.ts b/src/languages/traced.test.ts index 777fdccc3..3b8a3b331 100644 --- a/src/languages/traced.test.ts +++ b/src/languages/traced.test.ts @@ -209,7 +209,7 @@ test.serial( { attributes: { languages: [BuiltInLanguage.swift], - macOSVersion: "27.0.0", + darwinVersion: "27.0.0", }, severity: "warning", source: { @@ -268,7 +268,7 @@ test.serial( { attributes: { languages: [BuiltInLanguage.swift], - macOSVersion: "27.0.0", + darwinVersion: "27.0.0", }, severity: "error", source: { diff --git a/src/languages/traced.ts b/src/languages/traced.ts index 0de35b589..605c99f2e 100644 --- a/src/languages/traced.ts +++ b/src/languages/traced.ts @@ -6,13 +6,13 @@ import type { ActionConfig } from "../config/action-config"; import { addDiagnostic, makeDiagnostic } from "../diagnostics"; import { DocUrl } from "../doc-url"; import { Feature } from "../feature-flags"; -import { macOSVersion, xcodeVersion } from "../platform"; +import { darwinVersion, xcodeVersion } from "../platform"; import { ConfigurationError } from "../util"; import { checkSwiftCompatibility } from "./swift"; /** macOS 27 and above do not support traced extraction. */ -export const UNSUPPORTED_MACOS_FOR_TRACED = 27; +export const UNSUPPORTED_DARWIN_FOR_TRACED = 27; /** Xcode 27 and above do not support traced extraction. */ export const UNSUPPORTED_XCODE_FOR_TRACED = 27; @@ -36,12 +36,12 @@ function handleUnsupportedVersion( version: semver.SemVer, ) { const baseMessage = [ - `Traced analysis is not supported on ${product} ${UNSUPPORTED_MACOS_FOR_TRACED} or above.`, - `Configure your analysis to run on macOS ${UNSUPPORTED_MACOS_FOR_TRACED - 1} or below`, + `Traced analysis is not supported on ${product} ${UNSUPPORTED_DARWIN_FOR_TRACED} or above.`, + `Configure your analysis to run on macOS ${UNSUPPORTED_DARWIN_FOR_TRACED - 1} or below`, `and XCode ${UNSUPPORTED_XCODE_FOR_TRACED - 1} or below.`, ].join(" "); - const attributeName = product === "macOS" ? "macOSVersion" : "xcodeVersion"; + const attributeName = product === "macOS" ? "darwinVersion" : "xcodeVersion"; // Create a diagnostic that will show up on the TSP. for (const language of config.languages) { @@ -115,8 +115,8 @@ export async function checkRunnerSupportsTracedAnalysis( config: ActionConfig<"languages" | "dbLocation" | "tempDir">, codeql: CodeQL, ) { - // Try to get the macOS version. - const version = macOSVersion(action); + // Try to get the Darwin version on macOS. + const version = darwinVersion(action); // Perform some initial, Swift-specific checks. await checkSwiftCompatibility(config, codeql, version); @@ -141,7 +141,7 @@ export async function checkRunnerSupportsTracedAnalysis( ); } else if ( version !== undefined && - version.major >= UNSUPPORTED_MACOS_FOR_TRACED + version.major >= UNSUPPORTED_DARWIN_FOR_TRACED ) { handleUnsupportedVersion( action.logger, diff --git a/src/platform.test.ts b/src/platform.test.ts index 6688f66af..e3a3b7783 100644 --- a/src/platform.test.ts +++ b/src/platform.test.ts @@ -6,7 +6,7 @@ import * as sinon from "sinon"; import { BundlePlatform, getBundlePlatform, - macOSVersion, + darwinVersion, XCODE_SELECT_LINK_PATH, xcodeVersion, } from "./platform"; @@ -36,25 +36,25 @@ for (const [platform, arch, expected] of [ const platforms: NodeJS.Platform[] = ["linux", "win32", "freebsd"]; for (const platform of platforms) { - test(`macOSVersion returns undefined on ${platform}`, (t) => { - t.is(macOSVersion(initAllState({ platform })), undefined); + test(`darwinVersion returns undefined on ${platform}`, (t) => { + t.is(darwinVersion(initAllState({ platform })), undefined); }); } -test("macOSVersion returns raw string if semver parsing fails", (t) => { +test("darwinVersion returns raw string if semver parsing fails", (t) => { const invalidSemVer = "sealOS-2026"; t.is( - macOSVersion( + darwinVersion( initAllState({ platform: "darwin", osRelease: invalidSemVer }), ), invalidSemVer, ); }); -test("macOSVersion returns semver if parsing succeeds", (t) => { +test("darwinVersion returns semver if parsing succeeds", (t) => { const validSemVer = "27.0.1"; - const version = macOSVersion( + const version = darwinVersion( initAllState({ platform: "darwin", osRelease: validSemVer }), ); diff --git a/src/platform.ts b/src/platform.ts index 9492dff19..22df77c1a 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -33,13 +33,14 @@ export function getBundlePlatform( } /** - * Tries to determine the version of macOS. + * Tries to determine the version of the kernel on macOS. We approximate this based on the + * Darwin kernel version so that we don't have to launch an external process. * * @returns * The version as either a semantic version object, the raw version string * if it is not a semantic version, or `undefined` if we are not on macOS. */ -export function macOSVersion( +export function darwinVersion( action: ActionState<["Base"]>, ): semver.SemVer | string | undefined { // Skip if we are not running on macOS. @@ -47,7 +48,7 @@ export function macOSVersion( return undefined; } - // Try to parse the OS version string. + // Try to parse the kernel version string. const version = semver.parse(action.osRelease); if (version === null) {