Skip to content

Commit 335044a

Browse files
committed
Add detected tar version to telemetry
1 parent ffa1b05 commit 335044a

File tree

6 files changed

+71
-12
lines changed

6 files changed

+71
-12
lines changed

lib/init-action.js

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

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

lib/tar.js

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tar.js.map

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/init-action.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
getActionsStatus,
4343
sendStatusReport,
4444
} from "./status-report";
45+
import { isZstdAvailable } from "./tar";
4546
import { ToolsFeature } from "./tools-features";
4647
import { getTotalCacheSize } from "./trap-caching";
4748
import {
@@ -375,6 +376,8 @@ async function run() {
375376
try {
376377
cleanupDatabaseClusterDirectory(config, logger);
377378

379+
await logZstdAvailability(config, logger);
380+
378381
// Log CodeQL download telemetry, if appropriate
379382
if (toolsDownloadStatusReport) {
380383
addDiagnostic(
@@ -670,6 +673,29 @@ function getTrapCachingEnabled(): boolean {
670673
return true;
671674
}
672675

676+
async function logZstdAvailability(config: configUtils.Config, logger: Logger) {
677+
// Log zstd availability
678+
const zstdAvailableResult = await isZstdAvailable(logger);
679+
addDiagnostic(
680+
config,
681+
// Arbitrarily choose the first language. We could also choose all languages, but that
682+
// increases the risk of misinterpreting the data.
683+
config.languages[0],
684+
makeDiagnostic(
685+
"codeql-action/zstd-availability",
686+
"Zstandard availability",
687+
{
688+
attributes: zstdAvailableResult,
689+
visibility: {
690+
cliSummaryTable: false,
691+
statusPage: false,
692+
telemetry: true,
693+
},
694+
},
695+
),
696+
);
697+
}
698+
673699
async function runWrapper() {
674700
try {
675701
await run();

src/tar.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { assertNever } from "./util";
88
const MIN_REQUIRED_BSD_TAR_VERSION = "3.4.3";
99
const MIN_REQUIRED_GNU_TAR_VERSION = "1.31";
1010

11-
type TarVersion = {
11+
export type TarVersion = {
1212
type: "gnu" | "bsd";
1313
version: string;
1414
};
@@ -46,15 +46,24 @@ async function getTarVersion(): Promise<TarVersion> {
4646
}
4747
}
4848

49-
export async function isZstdAvailable(logger: Logger): Promise<boolean> {
49+
export async function isZstdAvailable(
50+
logger: Logger,
51+
): Promise<{ available: boolean; version?: TarVersion }> {
5052
try {
51-
const { type, version } = await getTarVersion();
53+
const tarVersion = await getTarVersion();
54+
const { type, version } = tarVersion;
5255
logger.info(`Found ${type} tar version ${version}.`);
5356
switch (type) {
5457
case "gnu":
55-
return version >= MIN_REQUIRED_GNU_TAR_VERSION;
58+
return {
59+
available: version >= MIN_REQUIRED_GNU_TAR_VERSION,
60+
version: tarVersion,
61+
};
5662
case "bsd":
57-
return version >= MIN_REQUIRED_BSD_TAR_VERSION;
63+
return {
64+
available: version >= MIN_REQUIRED_BSD_TAR_VERSION,
65+
version: tarVersion,
66+
};
5867
default:
5968
assertNever(type);
6069
}
@@ -63,7 +72,7 @@ export async function isZstdAvailable(logger: Logger): Promise<boolean> {
6372
"Failed to determine tar version, therefore will assume zstd may not be available. " +
6473
`The underlying error was: ${e}`,
6574
);
66-
return false;
75+
return { available: false };
6776
}
6877
}
6978

0 commit comments

Comments
 (0)