Skip to content

Commit 120993f

Browse files
committed
Convert diagnostic ID to kebab case
1 parent f1396bd commit 120993f

3 files changed

Lines changed: 101 additions & 2 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/languages/traced.test.ts‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "fs";
22

3+
import type { ExecOptions } from "@actions/exec";
34
import * as toolrunner from "@actions/exec/lib/toolrunner";
45
import * as io from "@actions/io";
56
import test from "ava";
@@ -546,6 +547,104 @@ test.serial(
546547
}),
547548
);
548549

550+
// `addDiagnostic` changes global state and we must stub it, so this test must be serial.
551+
test.serial(
552+
"checkRunnerSupportsTracedAnalysis logs and adds diagnostic if Xcode SDK version is unsupported",
553+
async (t) =>
554+
withTmpDir(async (tmpDir) => {
555+
const logger = new RecordingLogger();
556+
const env = getTestEnv();
557+
env.set(ActionsEnvVars.RUNNER_TEMP, tmpDir);
558+
const features = createFeatures([Feature.CheckUnsupportedTracedAnalysis]);
559+
560+
const readlinkSync = sinon
561+
.stub(fs, "readlinkSync")
562+
.throws(new Error("Not found"));
563+
const which = sinon.stub(io, "which").resolves("/path/to/xcrun");
564+
565+
let stdoutListener: ((data: Buffer) => void) | undefined = undefined;
566+
const exec = sinon.stub<[], Promise<number>>().callsFake(async () => {
567+
if (stdoutListener !== undefined) {
568+
stdoutListener(Buffer.from("Xcode 27.5"));
569+
stdoutListener(Buffer.from("Build version 27F9"));
570+
return 0;
571+
} else {
572+
throw new Error("Error to force next fallback");
573+
}
574+
});
575+
const runner = sinon.createStubInstance(toolrunner.ToolRunner, {
576+
exec,
577+
});
578+
const toolrunnerStub = sinon
579+
.stub(toolrunner, "ToolRunner")
580+
.callsFake((_cmd, args: string[], opts: ExecOptions) => {
581+
if (args[0] !== "xcodebuild") {
582+
stdoutListener = opts.listeners?.stdout;
583+
}
584+
return runner;
585+
});
586+
587+
const codeql = await getCodeQLWithTracedStub(
588+
"codeql-for-testing",
589+
logger,
590+
env,
591+
);
592+
sinon.stub(codeql, "getVersion").resolves(makeVersionInfo("2.27.0"));
593+
594+
const addDiagnostic = sinon.stub(diagnostics, "addDiagnostic");
595+
596+
const config = createTestConfig({
597+
tempDir: tmpDir,
598+
languages: [BuiltInLanguage.swift],
599+
});
600+
await checkRunnerSupportsTracedAnalysis(
601+
initAllState({
602+
logger,
603+
platform: "darwin",
604+
osRelease: "26.0.0",
605+
env,
606+
features,
607+
}),
608+
config,
609+
codeql,
610+
);
611+
612+
t.is(readlinkSync.callCount, 1);
613+
t.deepEqual(readlinkSync.args[0], [XCODE_SELECT_LINK_PATH]);
614+
615+
t.is(which.callCount, 2);
616+
t.is(toolrunnerStub.callCount, 2);
617+
t.is(exec.callCount, 2);
618+
619+
checkExpectedLogMessages(t, logger.messages, [
620+
"Unable to determine Xcode version from xcodebuild",
621+
"Traced analysis is not supported on Xcode SDK 27",
622+
]);
623+
624+
t.is(addDiagnostic.callCount, 1);
625+
t.like(addDiagnostic.args[0], [
626+
config,
627+
BuiltInLanguage.swift,
628+
{
629+
attributes: {
630+
languages: [BuiltInLanguage.swift],
631+
xcodeSdkVersion: "27.5.0",
632+
},
633+
severity: "warning",
634+
source: {
635+
id: "codeql-action/unsupported-traced-analysis-xcode-sdk",
636+
name: "Traced analysis is not supported on this version of Xcode SDK",
637+
},
638+
visibility: {
639+
cliSummaryTable: true,
640+
statusPage: true,
641+
telemetry: true,
642+
},
643+
} satisfies Partial<diagnostics.DiagnosticMessage>,
644+
]);
645+
}),
646+
);
647+
549648
// `addDiagnostic` changes global state and we must stub it, so this test must be serial.
550649
test.serial(
551650
"checkRunnerSupportsTracedAnalysis throws if Xcode version is unsupported and FF is enabled",

‎src/languages/traced.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function handleUnsupportedVersion(
8383
config,
8484
language,
8585
makeDiagnostic(
86-
`codeql-action/unsupported-traced-analysis-${product.toLowerCase()}`,
86+
`codeql-action/unsupported-traced-analysis-${product.toLowerCase().replaceAll(" ", "-")}`,
8787
`Traced analysis is not supported on this version of ${product}`,
8888
{
8989
attributes: {

0 commit comments

Comments
 (0)