Use macOSVersion in isSwiftCompatible

This commit is contained in:
Michael B. Gale
2026-10-09 11:35:54 +01:00
parent 570e438ccc
commit e0220172c9
3 changed files with 120 additions and 73 deletions

157
lib/entry-points.js generated
View File

@@ -34664,7 +34664,7 @@ var require_parse2 = __commonJS({
"node_modules/semver/functions/parse.js"(exports2, module2) {
"use strict";
var SemVer = require_semver();
var parse3 = (version, options, throwErrors = false) => {
var parse4 = (version, options, throwErrors = false) => {
if (version instanceof SemVer) {
return version;
}
@@ -34677,7 +34677,7 @@ var require_parse2 = __commonJS({
throw er;
}
};
module2.exports = parse3;
module2.exports = parse4;
}
});
@@ -34685,9 +34685,9 @@ var require_parse2 = __commonJS({
var require_valid = __commonJS({
"node_modules/semver/functions/valid.js"(exports2, module2) {
"use strict";
var parse3 = require_parse2();
var parse4 = require_parse2();
var valid4 = (version, options) => {
const v = parse3(version, options);
const v = parse4(version, options);
return v ? v.version : null;
};
module2.exports = valid4;
@@ -34698,9 +34698,9 @@ var require_valid = __commonJS({
var require_clean = __commonJS({
"node_modules/semver/functions/clean.js"(exports2, module2) {
"use strict";
var parse3 = require_parse2();
var parse4 = require_parse2();
var clean3 = (version, options) => {
const s = parse3(version.trim().replace(/^[=v]+/, ""), options);
const s = parse4(version.trim().replace(/^[=v]+/, ""), options);
return s ? s.version : null;
};
module2.exports = clean3;
@@ -34735,10 +34735,10 @@ var require_inc = __commonJS({
var require_diff = __commonJS({
"node_modules/semver/functions/diff.js"(exports2, module2) {
"use strict";
var parse3 = require_parse2();
var parse4 = require_parse2();
var diff = (version1, version2) => {
const v1 = parse3(version1, null, true);
const v2 = parse3(version2, null, true);
const v1 = parse4(version1, null, true);
const v2 = parse4(version2, null, true);
const comparison = v1.compare(v2);
if (comparison === 0) {
return null;
@@ -34809,9 +34809,9 @@ var require_patch = __commonJS({
var require_prerelease = __commonJS({
"node_modules/semver/functions/prerelease.js"(exports2, module2) {
"use strict";
var parse3 = require_parse2();
var parse4 = require_parse2();
var prerelease = (version, options) => {
const parsed = parse3(version, options);
const parsed = parse4(version, options);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
};
module2.exports = prerelease;
@@ -34997,7 +34997,7 @@ var require_coerce = __commonJS({
"node_modules/semver/functions/coerce.js"(exports2, module2) {
"use strict";
var SemVer = require_semver();
var parse3 = require_parse2();
var parse4 = require_parse2();
var { safeRe: re, t } = require_re();
var coerce3 = (version, options) => {
if (version instanceof SemVer) {
@@ -35032,7 +35032,7 @@ var require_coerce = __commonJS({
const patch = match2[4] || "0";
const prerelease = options.includePrerelease && match2[5] ? `-${match2[5]}` : "";
const build2 = options.includePrerelease && match2[6] ? `+${match2[6]}` : "";
return parse3(`${major}.${minor}.${patch}${prerelease}${build2}`, options);
return parse4(`${major}.${minor}.${patch}${prerelease}${build2}`, options);
};
module2.exports = coerce3;
}
@@ -35042,7 +35042,7 @@ var require_coerce = __commonJS({
var require_truncate = __commonJS({
"node_modules/semver/functions/truncate.js"(exports2, module2) {
"use strict";
var parse3 = require_parse2();
var parse4 = require_parse2();
var constants = require_constants6();
var SemVer = require_semver();
var truncate = (version, truncation, options) => {
@@ -35054,7 +35054,7 @@ var require_truncate = __commonJS({
};
var cloneInputVersion = (version, options) => {
const versionStringToParse = version instanceof SemVer ? version.version : version;
return parse3(versionStringToParse, options);
return parse4(versionStringToParse, options);
};
var doTruncation = (version, truncation) => {
if (isPrerelease(truncation)) {
@@ -36098,7 +36098,7 @@ var require_semver2 = __commonJS({
var constants = require_constants6();
var SemVer = require_semver();
var identifiers = require_identifiers();
var parse3 = require_parse2();
var parse4 = require_parse2();
var valid4 = require_valid();
var clean3 = require_clean();
var inc = require_inc();
@@ -36137,7 +36137,7 @@ var require_semver2 = __commonJS({
var simplifyRange = require_simplify();
var subset = require_subset();
module2.exports = {
parse: parse3,
parse: parse4,
valid: valid4,
clean: clean3,
inc,
@@ -39820,9 +39820,9 @@ var require_minimatch = __commonJS({
throw new TypeError("pattern is too long");
}
};
Minimatch2.prototype.parse = parse3;
Minimatch2.prototype.parse = parse4;
var SUBPARSE = {};
function parse3(pattern, isSub) {
function parse4(pattern, isSub) {
assertValidPattern2(pattern);
var options = this.options;
if (pattern === "**") {
@@ -41272,8 +41272,8 @@ var require_semver3 = __commonJS({
}
}
var i;
exports2.parse = parse3;
function parse3(version, options) {
exports2.parse = parse4;
function parse4(version, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
@@ -41301,12 +41301,12 @@ var require_semver3 = __commonJS({
}
exports2.valid = valid4;
function valid4(version, options) {
var v = parse3(version, options);
var v = parse4(version, options);
return v ? v.version : null;
}
exports2.clean = clean3;
function clean3(version, options) {
var s = parse3(version.trim().replace(/^[=v]+/, ""), options);
var s = parse4(version.trim().replace(/^[=v]+/, ""), options);
return s ? s.version : null;
}
exports2.SemVer = SemVer;
@@ -41542,8 +41542,8 @@ var require_semver3 = __commonJS({
if (eq(version1, version2)) {
return null;
} else {
var v1 = parse3(version1);
var v2 = parse3(version2);
var v1 = parse4(version1);
var v2 = parse4(version2);
var prefix = "";
if (v1.prerelease.length || v2.prerelease.length) {
prefix = "pre";
@@ -42249,7 +42249,7 @@ var require_semver3 = __commonJS({
}
exports2.prerelease = prerelease;
function prerelease(version, options) {
var parsed = parse3(version, options);
var parsed = parse4(version, options);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
}
exports2.intersects = intersects;
@@ -42286,7 +42286,7 @@ var require_semver3 = __commonJS({
if (match2 === null) {
return null;
}
return parse3(match2[2] + "." + (match2[3] || "0") + "." + (match2[4] || "0"), options);
return parse4(match2[2] + "." + (match2[3] || "0") + "." + (match2[4] || "0"), options);
}
}
});
@@ -42430,7 +42430,7 @@ var require_cacheUtils = __commonJS({
var crypto3 = __importStar2(require("crypto"));
var fs33 = __importStar2(require("fs"));
var path30 = __importStar2(require("path"));
var semver11 = __importStar2(require_semver3());
var semver12 = __importStar2(require_semver3());
var util4 = __importStar2(require("util"));
var constants_1 = require_constants7();
var versionSalt = "1.0";
@@ -42523,7 +42523,7 @@ var require_cacheUtils = __commonJS({
function getCompressionMethod() {
return __awaiter2(this, void 0, void 0, function* () {
const versionOutput = yield getVersion("zstd", ["--quiet"]);
const version = semver11.clean(versionOutput);
const version = semver12.clean(versionOutput);
core29.debug(`zstd version: ${version}`);
if (versionOutput === "") {
return constants_1.CompressionMethod.Gzip;
@@ -45201,7 +45201,7 @@ var require_ms = __commonJS({
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse3(val);
return parse4(val);
} else if (type === "number" && isFinite(val)) {
return options.long ? fmtLong(val) : fmtShort(val);
}
@@ -45209,7 +45209,7 @@ var require_ms = __commonJS({
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
);
};
function parse3(str) {
function parse4(str) {
str = String(str);
if (str.length > 100) {
return;
@@ -53110,7 +53110,7 @@ var require_deserializationPolicy = __commonJS({
return result;
}
async function deserializeResponseBody(jsonContentTypes, xmlContentTypes, response, options, parseXML) {
const parsedResponse = await parse3(jsonContentTypes, xmlContentTypes, response, options, parseXML);
const parsedResponse = await parse4(jsonContentTypes, xmlContentTypes, response, options, parseXML);
if (!shouldDeserializeResponse(parsedResponse)) {
return parsedResponse;
}
@@ -53211,7 +53211,7 @@ var require_deserializationPolicy = __commonJS({
}
return { error: error3, shouldReturnResponse: false };
}
async function parse3(jsonContentTypes, xmlContentTypes, operationResponse, opts, parseXML) {
async function parse4(jsonContentTypes, xmlContentTypes, operationResponse, opts, parseXML) {
if (!operationResponse.request.streamResponseStatusCodes?.has(operationResponse.status) && operationResponse.bodyAsText) {
const text = operationResponse.bodyAsText;
const contentType = operationResponse.headers.get("Content-Type") || "";
@@ -114072,7 +114072,7 @@ var require_manifest = __commonJS({
exports2._findMatch = _findMatch;
exports2._getOsVersion = _getOsVersion;
exports2._readLinuxVersionFile = _readLinuxVersionFile;
var semver11 = __importStar2(require_semver2());
var semver12 = __importStar2(require_semver2());
var core_1 = require_core();
var os8 = require("os");
var cp = require("child_process");
@@ -114086,7 +114086,7 @@ var require_manifest = __commonJS({
for (const candidate of candidates) {
const version = candidate.version;
(0, core_1.debug)(`check ${version} satisfies ${versionSpec}`);
if (semver11.satisfies(version, versionSpec) && (!stable || candidate.stable === stable)) {
if (semver12.satisfies(version, versionSpec) && (!stable || candidate.stable === stable)) {
file = candidate.files.find((item) => {
(0, core_1.debug)(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`);
let chk = item.arch === archFilter && item.platform === platFilter;
@@ -114095,7 +114095,7 @@ var require_manifest = __commonJS({
if (osVersion === item.platform_version) {
chk = true;
} else {
chk = semver11.satisfies(osVersion, item.platform_version);
chk = semver12.satisfies(osVersion, item.platform_version);
}
}
return chk;
@@ -114355,7 +114355,7 @@ var require_tool_cache = __commonJS({
var os8 = __importStar2(require("os"));
var path30 = __importStar2(require("path"));
var httpm = __importStar2(require_lib());
var semver11 = __importStar2(require_semver2());
var semver12 = __importStar2(require_semver2());
var stream2 = __importStar2(require("stream"));
var util4 = __importStar2(require("util"));
var assert_1 = require("assert");
@@ -114628,7 +114628,7 @@ var require_tool_cache = __commonJS({
}
function cacheDir2(sourceDir, tool, version, arch2) {
return __awaiter2(this, void 0, void 0, function* () {
version = semver11.clean(version) || version;
version = semver12.clean(version) || version;
arch2 = arch2 || os8.arch();
core29.debug(`Caching tool ${tool} ${version} ${arch2}`);
core29.debug(`source dir: ${sourceDir}`);
@@ -114646,7 +114646,7 @@ var require_tool_cache = __commonJS({
}
function cacheFile(sourceFile, targetFile, tool, version, arch2) {
return __awaiter2(this, void 0, void 0, function* () {
version = semver11.clean(version) || version;
version = semver12.clean(version) || version;
arch2 = arch2 || os8.arch();
core29.debug(`Caching tool ${tool} ${version} ${arch2}`);
core29.debug(`source file: ${sourceFile}`);
@@ -114676,7 +114676,7 @@ var require_tool_cache = __commonJS({
}
let toolPath = "";
if (versionSpec) {
versionSpec = semver11.clean(versionSpec) || "";
versionSpec = semver12.clean(versionSpec) || "";
const cachePath = path30.join(_getCacheDirectory(), toolName, versionSpec, arch2);
core29.debug(`checking cache: ${cachePath}`);
if (fs33.existsSync(cachePath) && fs33.existsSync(`${cachePath}.complete`)) {
@@ -114756,7 +114756,7 @@ var require_tool_cache = __commonJS({
}
function _createToolPath(tool, version, arch2) {
return __awaiter2(this, void 0, void 0, function* () {
const folderPath = path30.join(_getCacheDirectory(), tool, semver11.clean(version) || version, arch2 || "");
const folderPath = path30.join(_getCacheDirectory(), tool, semver12.clean(version) || version, arch2 || "");
core29.debug(`destination ${folderPath}`);
const markerPath = `${folderPath}.complete`;
yield io9.rmRF(folderPath);
@@ -114766,15 +114766,15 @@ var require_tool_cache = __commonJS({
});
}
function _completeToolPath(tool, version, arch2) {
const folderPath = path30.join(_getCacheDirectory(), tool, semver11.clean(version) || version, arch2 || "");
const folderPath = path30.join(_getCacheDirectory(), tool, semver12.clean(version) || version, arch2 || "");
const markerPath = `${folderPath}.complete`;
fs33.writeFileSync(markerPath, "");
core29.debug("finished caching tool");
}
function isExplicitVersion(versionSpec) {
const c = semver11.clean(versionSpec) || "";
const c = semver12.clean(versionSpec) || "";
core29.debug(`isExplicit: ${c}`);
const valid4 = semver11.valid(c) != null;
const valid4 = semver12.valid(c) != null;
core29.debug(`explicit? ${valid4}`);
return valid4;
}
@@ -114782,14 +114782,14 @@ var require_tool_cache = __commonJS({
let version = "";
core29.debug(`evaluating ${versions.length} versions`);
versions = versions.sort((a, b) => {
if (semver11.gt(a, b)) {
if (semver12.gt(a, b)) {
return 1;
}
return -1;
});
for (let i = versions.length - 1; i >= 0; i--) {
const potential = versions[i];
const satisfied = semver11.satisfies(potential, versionSpec);
const satisfied = semver12.satisfies(potential, versionSpec);
if (satisfied) {
version = potential;
break;
@@ -144290,7 +144290,7 @@ var require_dist_node2 = __commonJS({
return template.replace(/\/$/, "");
}
}
function parse3(options) {
function parse4(options) {
let method = options.method.toUpperCase();
let url2 = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
let headers = Object.assign({}, options.headers);
@@ -144354,7 +144354,7 @@ var require_dist_node2 = __commonJS({
);
}
function endpointWithDefaults2(defaults3, route, options) {
return parse3(merge2(defaults3, route, options));
return parse4(merge2(defaults3, route, options));
}
function withDefaults4(oldDefaults, newDefaults) {
const DEFAULTS22 = merge2(oldDefaults, newDefaults);
@@ -144363,7 +144363,7 @@ var require_dist_node2 = __commonJS({
DEFAULTS: DEFAULTS22,
defaults: withDefaults4.bind(null, DEFAULTS22),
merge: merge2.bind(null, DEFAULTS22),
parse: parse3
parse: parse4
});
}
var endpoint2 = withDefaults4(null, DEFAULTS2);
@@ -148595,7 +148595,7 @@ var require_binary = __commonJS({
});
return stream2;
};
exports2.parse = function parse3(buffer) {
exports2.parse = function parse4(buffer) {
var self2 = words(function(bytes, cb) {
return function(name) {
if (offset + bytes <= buffer.length) {
@@ -183078,7 +183078,7 @@ var fs15 = __toESM(require("fs"));
var path13 = __toESM(require("path"));
var import_perf_hooks4 = require("perf_hooks");
var toolcache3 = __toESM(require_tool_cache());
var semver9 = __toESM(require_semver2());
var semver10 = __toESM(require_semver2());
// src/codeql-bundle.ts
function getCodeQLBundleName(compressionMethod, platform2, language) {
@@ -183407,9 +183407,10 @@ async function getCodeQlVersionsForOverlayBaseDatabases(rawLanguages, logger2) {
}
// src/per-language-bundles.ts
var semver6 = __toESM(require_semver2());
var semver7 = __toESM(require_semver2());
// src/platform.ts
var semver6 = __toESM(require_semver2());
function getBundlePlatform(platform2 = process.platform, arch2 = process.arch) {
switch (platform2) {
case "win32":
@@ -183422,6 +183423,16 @@ function getBundlePlatform(platform2 = process.platform, arch2 = process.arch) {
return void 0;
}
}
function macOSVersion(action) {
if (action.platform !== "darwin") {
return void 0;
}
const version = semver6.parse(action.osRelease);
if (version === null) {
return action.osRelease;
}
return version;
}
// src/per-language-bundles.ts
var MIN_PER_LANGUAGE_BUNDLE_CLI_VERSION = "2.27.1";
@@ -183509,7 +183520,7 @@ function getPerLanguageBundleLanguage(action, options) {
if (cliVersion2 === void 0) {
return explain("the requested CLI version is unknown");
}
if (!semver6.gte(cliVersion2, MIN_PER_LANGUAGE_BUNDLE_CLI_VERSION)) {
if (!semver7.gte(cliVersion2, MIN_PER_LANGUAGE_BUNDLE_CLI_VERSION)) {
return explain(
`the requested CodeQL version ${cliVersion2} is older than ${MIN_PER_LANGUAGE_BUNDLE_CLI_VERSION}, which is the first version for which per-language bundles are published`
);
@@ -183607,7 +183618,7 @@ var stream = __toESM(require("stream"));
var import_toolrunner = __toESM(require_toolrunner());
var io4 = __toESM(require_io());
var toolcache = __toESM(require_tool_cache());
var semver7 = __toESM(require_semver2());
var semver8 = __toESM(require_semver2());
var MIN_REQUIRED_BSD_TAR_VERSION = "3.4.3";
var MIN_REQUIRED_GNU_TAR_VERSION = "1.31";
async function getTarVersion() {
@@ -183649,9 +183660,9 @@ async function isZstdAvailable(logger2) {
case "gnu":
return {
available: foundZstdBinary && // GNU tar only uses major and minor version numbers
semver7.gte(
semver7.coerce(version),
semver7.coerce(MIN_REQUIRED_GNU_TAR_VERSION)
semver8.gte(
semver8.coerce(version),
semver8.coerce(MIN_REQUIRED_GNU_TAR_VERSION)
),
foundZstdBinary,
version: tarVersion
@@ -183660,7 +183671,7 @@ async function isZstdAvailable(logger2) {
return {
available: foundZstdBinary && // Do a loose comparison since these version numbers don't contain
// a patch version number.
semver7.gte(version, MIN_REQUIRED_BSD_TAR_VERSION),
semver8.gte(version, MIN_REQUIRED_BSD_TAR_VERSION),
foundZstdBinary,
version: tarVersion
};
@@ -183769,7 +183780,7 @@ var core11 = __toESM(require_core());
var import_http_client = __toESM(require_lib());
var toolcache2 = __toESM(require_tool_cache());
var import_follow_redirects = __toESM(require_follow_redirects());
var semver8 = __toESM(require_semver2());
var semver9 = __toESM(require_semver2());
var STREAMING_HIGH_WATERMARK_BYTES = 4 * 1024 * 1024;
var STREAMING_STALL_TIMEOUT_MS = 5 * 60 * 1e3;
var TOOLCACHE_TOOL_NAME = "CodeQL";
@@ -183895,7 +183906,7 @@ function getToolcacheToolDirectory(env) {
);
}
function getToolcacheVersionDirectoryName(version) {
return semver8.clean(version) || version;
return semver9.clean(version) || version;
}
function getToolcacheDirectory(version) {
return path12.join(
@@ -184022,13 +184033,13 @@ function tryGetTagNameFromUrl(url2, logger2) {
return match2[1];
}
function convertToSemVer(version, logger2) {
if (!semver9.valid(version)) {
if (!semver10.valid(version)) {
logger2.debug(
`Bundle version ${version} is not in SemVer format. Will treat it as pre-release 0.0.0-${version}.`
);
version = `0.0.0-${version}`;
}
const s = semver9.clean(version);
const s = semver10.clean(version);
if (!s) {
throw new Error(`Bundle version ${version} is not in SemVer format.`);
}
@@ -184208,7 +184219,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, othe
url2 = toolsInput;
if (tagName) {
const bundleVersion3 = tryGetBundleVersionFromTagName(tagName, logger2);
if (bundleVersion3 !== void 0 && semver9.valid(bundleVersion3)) {
if (bundleVersion3 !== void 0 && semver10.valid(bundleVersion3)) {
cliVersion2 = convertToSemVer(bundleVersion3, logger2);
}
}
@@ -184586,7 +184597,7 @@ async function downloadCodeQLBundle(action, source, apiDetails, tarVersion, temp
async function useZstdBundle(cliVersion2, tarSupportsZstd) {
return (
// In testing, gzip performs better than zstd on Windows.
process.platform !== "win32" && tarSupportsZstd && semver9.gte(cliVersion2, CODEQL_VERSION_ZSTD_BUNDLE)
process.platform !== "win32" && tarSupportsZstd && semver10.gte(cliVersion2, CODEQL_VERSION_ZSTD_BUNDLE)
);
}
function getTempExtractionDir(tempDir) {
@@ -184640,7 +184651,7 @@ async function getLatestNightlyBundle(action, rawLanguages, otherLanguagePacksRe
}
}
function getLatestToolcacheVersion(logger2) {
const allVersions = toolcache3.findAllVersions("CodeQL").sort((a, b) => semver9.compare(b, a));
const allVersions = toolcache3.findAllVersions("CodeQL").sort((a, b) => semver10.compare(b, a));
logger2.debug(
`Found the following versions of the CodeQL tools in the toolcache: ${JSON.stringify(
allVersions
@@ -193803,7 +193814,7 @@ var fs30 = __toESM(require("fs"));
var path25 = __toESM(require("path"));
var core19 = __toESM(require_core());
var io7 = __toESM(require_io());
var semver10 = __toESM(require_semver2());
var semver11 = __toESM(require_semver2());
// src/config/inputs.ts
async function getToolsInput(action, repositoryProperties) {
@@ -193841,11 +193852,21 @@ async function getToolsInput(action, repositoryProperties) {
// src/languages/swift.ts
function checkSwiftCompatibility(action, config) {
if (config.languages.includes("swift" /* swift */) && action.platform !== "darwin") {
if (!config.languages.includes("swift" /* swift */)) {
return;
}
const version = macOSVersion(action);
if (version === void 0) {
throw new ConfigurationError(
`Swift analysis is only supported on macOS runner images. Please migrate to a macOS runner.`
);
}
if (typeof version === "string") {
action.logger.warning(
`Unable to determine version of macOS, got: ${version}`
);
return;
}
}
// src/status-report/tools-download.ts
@@ -194322,7 +194343,7 @@ async function run3(actionState) {
) {
const publicPreview = "2.22.1";
const actualVer = (await codeql.getVersion()).version;
if (semver10.lt(actualVer, publicPreview)) {
if (semver11.lt(actualVer, publicPreview)) {
actionState.env.export("CODEQL_ENABLE_EXPERIMENTAL_FEATURES" /* EXPERIMENTAL_FEATURES */, "true");
logger2.info("Experimental Rust analysis enabled");
}

View File

@@ -3,6 +3,7 @@ import sinon from "sinon";
import { ActionsEnvVars } from "../environment";
import {
checkExpectedLogMessages,
createTestConfig,
getCodeQLForTesting,
getTestEnv,
@@ -68,3 +69,14 @@ for (const nonDarwinPlatform of nonDarwinPlatforms) {
);
});
}
test("checkSwiftCompatibility warns if version string is not a semver", (t) => {
const logger = new RecordingLogger();
checkSwiftCompatibility(
initAllState({ logger, platform: "darwin", osRelease: "unexpected" }),
createTestConfig({ languages: [BuiltInLanguage.swift] }),
);
checkExpectedLogMessages(t, logger.messages, [
"Unable to determine version of macOS, got: unexpected",
]);
});

View File

@@ -1,5 +1,6 @@
import { ActionState } from "../action-common";
import { Config } from "../config-utils";
import { macOSVersion } from "../platform";
import { ConfigurationError } from "../util";
import { BuiltInLanguage } from ".";
@@ -13,15 +14,28 @@ import { BuiltInLanguage } from ".";
* @throws {ConfigurationError} If Swift analysis is not possible on the current runner.
*/
export function checkSwiftCompatibility(
action: ActionState<["Base"]>,
action: ActionState<["Base", "Logger"]>,
config: Config,
) {
if (
config.languages.includes(BuiltInLanguage.swift) &&
action.platform !== "darwin"
) {
// The checks are not relevant if we are not trying to analyse Swift.
if (!config.languages.includes(BuiltInLanguage.swift)) {
return;
}
// Try to get the macOS version.
const version = macOSVersion(action);
// If `version` is undefined, then we are not on macOS.
if (version === undefined) {
throw new ConfigurationError(
`Swift analysis is only supported on macOS runner images. Please migrate to a macOS runner.`,
);
}
// If we got a string, we are on macOS but couldn't parse the version string.
if (typeof version === "string") {
action.logger.warning(
`Unable to determine version of macOS, got: ${version}`,
);
return;
}
}