mirror of
https://github.com/github/codeql-action.git
synced 2026-10-31 01:49:43 +00:00
Check if Xcode version is unsupported
This commit is contained in:
126
lib/entry-points.js
generated
126
lib/entry-points.js
generated
@@ -186034,11 +186034,83 @@ async function getToolsInput(action, repositoryProperties) {
|
||||
|
||||
// src/languages/swift.ts
|
||||
var semver12 = __toESM(require_semver2());
|
||||
var XCODE_SELECT_LINK_PATH = "/private/var/db/xcode_select_link";
|
||||
var XCODE_APP_FILENAME_PATTERN = new RegExp(
|
||||
/(?<filename>Xcode_(?<majorMinor>\d+.\d+).app)/
|
||||
);
|
||||
var SWIFT_TRACED_UNSUPPORTED_MACOS = 27;
|
||||
var SWIFT_TRACED_UNSUPPORTED_XCODE = 27;
|
||||
function xcodeVersion(logger2, fs33) {
|
||||
try {
|
||||
const stats = fs33.statSync(XCODE_SELECT_LINK_PATH);
|
||||
if (!stats.isSymbolicLink()) {
|
||||
logger2.warning(
|
||||
`${XCODE_SELECT_LINK_PATH} exists, but is not a symbolic link.`
|
||||
);
|
||||
return void 0;
|
||||
}
|
||||
const xcodePath = fs33.readlinkSync(XCODE_SELECT_LINK_PATH);
|
||||
if (xcodePath === "") {
|
||||
logger2.warning(
|
||||
`Resolving ${XCODE_SELECT_LINK_PATH} unexpectedly returned nothing.`
|
||||
);
|
||||
return void 0;
|
||||
}
|
||||
const matchResult = xcodePath.match(XCODE_APP_FILENAME_PATTERN);
|
||||
if (matchResult?.groups === void 0) {
|
||||
logger2.warning(
|
||||
`Xcode path '${xcodePath}' does not contain expected pattern.`
|
||||
);
|
||||
return void 0;
|
||||
}
|
||||
const majorMinor = matchResult.groups["majorMinor"];
|
||||
const version = semver12.coerce(majorMinor);
|
||||
if (version === null) {
|
||||
logger2.warning(`Couldn't parse '${majorMinor}' as a semantic version.`);
|
||||
return void 0;
|
||||
}
|
||||
return version;
|
||||
} catch (err) {
|
||||
logger2.warning(
|
||||
`Unable to determine Xcode version: ${getErrorMessage(err)}`
|
||||
);
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
function handleUnsupportedVersion(logger2, config, skipUnsupportedTracedAnalysis, product, version) {
|
||||
const baseMessage = [
|
||||
`Traced Swift analysis is not supported on ${product} ${SWIFT_TRACED_UNSUPPORTED_MACOS} or above.`,
|
||||
`Configure your analysis to run on macOS ${SWIFT_TRACED_UNSUPPORTED_MACOS - 1} or below`,
|
||||
`and XCode ${SWIFT_TRACED_UNSUPPORTED_XCODE - 1} or below.`
|
||||
].join(" ");
|
||||
const attributeName = product === "macOS" ? "macOSVersion" : "xcodeVersion";
|
||||
addDiagnostic(
|
||||
config,
|
||||
"swift" /* swift */,
|
||||
makeDiagnostic(
|
||||
`codeql-action/unsupported-traced-swift-analysis-${product.toLowerCase()}`,
|
||||
`Traced Swift analysis is not supported on this version of ${product}`,
|
||||
{
|
||||
attributes: {
|
||||
languages: config.languages,
|
||||
[attributeName]: version.toString()
|
||||
},
|
||||
markdownMessage: baseMessage,
|
||||
severity: skipUnsupportedTracedAnalysis ? "error" : "warning",
|
||||
visibility: {
|
||||
cliSummaryTable: true,
|
||||
statusPage: true,
|
||||
telemetry: true
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
if (skipUnsupportedTracedAnalysis) {
|
||||
throw new ConfigurationError(baseMessage);
|
||||
} else {
|
||||
logger2.warning(baseMessage);
|
||||
}
|
||||
}
|
||||
async function isSwiftCompatible(action, config, codeql) {
|
||||
if (!config.languages.includes("swift" /* swift */)) {
|
||||
return;
|
||||
@@ -186052,47 +186124,31 @@ async function isSwiftCompatible(action, config, codeql) {
|
||||
`Swift analysis is only supported on macOS runner images. Please migrate to a macOS runner.`
|
||||
);
|
||||
}
|
||||
const skipUnsupportedTracedAnalysis = await action.features.getValue(
|
||||
"swift_skip_unsupported_traced_analysis" /* SwiftSkipUnsupportedTracedAnalysis */
|
||||
);
|
||||
if (typeof version === "string") {
|
||||
action.logger.warning(
|
||||
`Unable to determine version of macOS, got: ${version}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
const skipUnsupportedTracedAnalysis = await action.features.getValue(
|
||||
"swift_skip_unsupported_traced_analysis" /* SwiftSkipUnsupportedTracedAnalysis */
|
||||
);
|
||||
if (version.major >= SWIFT_TRACED_UNSUPPORTED_MACOS) {
|
||||
const baseMessage = [
|
||||
`Traced Swift analysis is not supported on macOS ${SWIFT_TRACED_UNSUPPORTED_MACOS} or above.`,
|
||||
`Configure your analysis to run on macOS ${SWIFT_TRACED_UNSUPPORTED_MACOS - 1} or below`,
|
||||
`and XCode ${SWIFT_TRACED_UNSUPPORTED_XCODE - 1} or below.`
|
||||
].join(" ");
|
||||
addDiagnostic(
|
||||
} else if (version.major >= SWIFT_TRACED_UNSUPPORTED_MACOS) {
|
||||
handleUnsupportedVersion(
|
||||
action.logger,
|
||||
config,
|
||||
"swift" /* swift */,
|
||||
makeDiagnostic(
|
||||
"codeql-action/unsupported-traced-swift-analysis-macos",
|
||||
"Traced Swift analysis is not supported on this version of macOS",
|
||||
{
|
||||
attributes: {
|
||||
languages: config.languages,
|
||||
macOSVersion: version.toString()
|
||||
},
|
||||
markdownMessage: baseMessage,
|
||||
severity: skipUnsupportedTracedAnalysis ? "error" : "warning",
|
||||
visibility: {
|
||||
cliSummaryTable: true,
|
||||
statusPage: true,
|
||||
telemetry: true
|
||||
}
|
||||
}
|
||||
)
|
||||
skipUnsupportedTracedAnalysis,
|
||||
"macOS",
|
||||
version
|
||||
);
|
||||
}
|
||||
const xcodeVer = xcodeVersion(action.logger, action.fs);
|
||||
if (xcodeVer !== void 0 && xcodeVer.major >= SWIFT_TRACED_UNSUPPORTED_XCODE) {
|
||||
handleUnsupportedVersion(
|
||||
action.logger,
|
||||
config,
|
||||
skipUnsupportedTracedAnalysis,
|
||||
"Xcode",
|
||||
xcodeVer
|
||||
);
|
||||
if (skipUnsupportedTracedAnalysis) {
|
||||
throw new ConfigurationError(baseMessage);
|
||||
} else {
|
||||
action.logger.warning(baseMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user