mirror of
https://github.com/github/codeql-action.git
synced 2026-11-05 04:29:40 +00:00
Distinguish between Xcode and SDK version in messages
This commit is contained in:
31
lib/entry-points.js
generated
31
lib/entry-points.js
generated
@@ -194018,15 +194018,29 @@ async function checkSwiftCompatibility(config, codeql, darwinVersion2) {
|
||||
// src/languages/traced.ts
|
||||
var UNSUPPORTED_DARWIN_FOR_TRACED = 27;
|
||||
var UNSUPPORTED_XCODE_FOR_TRACED = 27;
|
||||
function diagnosticAttributeName(product) {
|
||||
switch (product) {
|
||||
case "macOS":
|
||||
return "darwinVersion";
|
||||
case "Xcode":
|
||||
return "xcodeVersion";
|
||||
case "Xcode SDK":
|
||||
return "xcodeSdkVersion";
|
||||
}
|
||||
}
|
||||
function handleUnsupportedVersion(logger2, config, tracedLanguages, abortUnsupportedTracedAnalysis, productVersion) {
|
||||
const { product, version } = productVersion;
|
||||
const unsupportedVersion = product === "macOS" ? UNSUPPORTED_DARWIN_FOR_TRACED : UNSUPPORTED_XCODE_FOR_TRACED;
|
||||
const unsupportedVersion = product === "macOS" ? UNSUPPORTED_DARWIN_FOR_TRACED : (
|
||||
// We use the same constant for both Xcode and the Xcode SDK since we treat them
|
||||
// as equivalent indicators for whether traced analysis is unsupported.
|
||||
UNSUPPORTED_XCODE_FOR_TRACED
|
||||
);
|
||||
const baseMessage = [
|
||||
`Traced analysis is not supported on ${product} ${unsupportedVersion} 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" ? "darwinVersion" : "xcodeVersion";
|
||||
const attributeName = diagnosticAttributeName(product);
|
||||
for (const language of tracedLanguages) {
|
||||
addDiagnostic(
|
||||
config,
|
||||
@@ -194117,14 +194131,21 @@ async function checkRunnerSupportsTracedAnalysis(action, config, codeql) {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const xcodeVer = xcodeVersionFromLink(action.logger) ?? await xcodeVersionFromXcodeBuild(action.logger) ?? await xcodeSdkVersion(action.logger);
|
||||
if (xcodeVer !== void 0 && xcodeVer.major >= UNSUPPORTED_XCODE_FOR_TRACED) {
|
||||
const xcodeVer = xcodeVersionFromLink(action.logger) ?? await xcodeVersionFromXcodeBuild(action.logger);
|
||||
let xcodeProduct = void 0;
|
||||
if (xcodeVer !== void 0) {
|
||||
xcodeProduct = { product: "Xcode", version: xcodeVer };
|
||||
} else {
|
||||
const xcodeSdkVer = await xcodeSdkVersion(action.logger);
|
||||
xcodeProduct = xcodeSdkVer !== void 0 ? { product: "Xcode SDK", version: xcodeSdkVer } : void 0;
|
||||
}
|
||||
if (xcodeProduct !== void 0 && xcodeProduct.version.major >= UNSUPPORTED_XCODE_FOR_TRACED) {
|
||||
handleUnsupportedVersion(
|
||||
action.logger,
|
||||
config,
|
||||
tracedLanguages,
|
||||
abortUnsupportedTracedAnalysis,
|
||||
{ product: "Xcode", version: xcodeVer }
|
||||
xcodeProduct
|
||||
);
|
||||
} else if (xcodeVer === void 0) {
|
||||
action.logger.info(
|
||||
|
||||
@@ -22,12 +22,27 @@ export const UNSUPPORTED_DARWIN_FOR_TRACED = 27;
|
||||
/** Xcode 27 and above do not support traced extraction. */
|
||||
export const UNSUPPORTED_XCODE_FOR_TRACED = 27;
|
||||
|
||||
/** Names of products that we check the versions of here. */
|
||||
type ProductName = "macOS" | "Xcode" | "Xcode SDK";
|
||||
|
||||
/** A version along with the product it relates to. */
|
||||
type ProductVersion = {
|
||||
product: "macOS" | "Xcode";
|
||||
product: ProductName;
|
||||
version: semver.SemVer;
|
||||
};
|
||||
|
||||
/** Gets the appropriate attribute name for the diagnostic based on {@link product}. */
|
||||
function diagnosticAttributeName(product: ProductName): string {
|
||||
switch (product) {
|
||||
case "macOS":
|
||||
return "darwinVersion";
|
||||
case "Xcode":
|
||||
return "xcodeVersion";
|
||||
case "Xcode SDK":
|
||||
return "xcodeSdkVersion";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a diagnostic indicating that `version` of `product` is unsupported for traced analysis.
|
||||
* Depending on `skipUnsupportedTracedAnalysis`, this function then either throws a {@link ConfigurationError}
|
||||
@@ -50,14 +65,17 @@ function handleUnsupportedVersion(
|
||||
const unsupportedVersion =
|
||||
product === "macOS"
|
||||
? UNSUPPORTED_DARWIN_FOR_TRACED
|
||||
: UNSUPPORTED_XCODE_FOR_TRACED;
|
||||
: // We use the same constant for both Xcode and the Xcode SDK since we treat them
|
||||
// as equivalent indicators for whether traced analysis is unsupported.
|
||||
UNSUPPORTED_XCODE_FOR_TRACED;
|
||||
|
||||
const baseMessage = [
|
||||
`Traced analysis is not supported on ${product} ${unsupportedVersion} 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" ? "darwinVersion" : "xcodeVersion";
|
||||
const attributeName = diagnosticAttributeName(product);
|
||||
|
||||
// Create a diagnostic that will show up on the TSP.
|
||||
for (const language of tracedLanguages) {
|
||||
@@ -201,19 +219,30 @@ export async function checkRunnerSupportsTracedAnalysis(
|
||||
// incompatible, either is fine as we only check the major version below.
|
||||
const xcodeVer =
|
||||
xcodeVersionFromLink(action.logger) ??
|
||||
(await xcodeVersionFromXcodeBuild(action.logger)) ??
|
||||
(await xcodeSdkVersion(action.logger));
|
||||
(await xcodeVersionFromXcodeBuild(action.logger));
|
||||
let xcodeProduct: ProductVersion | undefined = undefined;
|
||||
|
||||
if (xcodeVer !== undefined) {
|
||||
xcodeProduct = { product: "Xcode", version: xcodeVer };
|
||||
} else {
|
||||
// Fallback to checking the SDK version, which may be available even if a full Xcode installation is not.
|
||||
const xcodeSdkVer = await xcodeSdkVersion(action.logger);
|
||||
xcodeProduct =
|
||||
xcodeSdkVer !== undefined
|
||||
? { product: "Xcode SDK", version: xcodeSdkVer }
|
||||
: undefined;
|
||||
}
|
||||
|
||||
if (
|
||||
xcodeVer !== undefined &&
|
||||
xcodeVer.major >= UNSUPPORTED_XCODE_FOR_TRACED
|
||||
xcodeProduct !== undefined &&
|
||||
xcodeProduct.version.major >= UNSUPPORTED_XCODE_FOR_TRACED
|
||||
) {
|
||||
handleUnsupportedVersion(
|
||||
action.logger,
|
||||
config,
|
||||
tracedLanguages,
|
||||
abortUnsupportedTracedAnalysis,
|
||||
{ product: "Xcode", version: xcodeVer },
|
||||
xcodeProduct,
|
||||
);
|
||||
} else if (xcodeVer === undefined) {
|
||||
action.logger.info(
|
||||
|
||||
Reference in New Issue
Block a user