Skip to content

Commit 4664f39

Browse files
authored
Ensure that tools_download_duration_ms is int (#1513)
1 parent b2e1676 commit 4664f39

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

lib/codeql.test.js

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

lib/codeql.test.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/setup-codeql.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.

lib/setup-codeql.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/codeql.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ test("downloads and caches explicitly requested bundles that aren't in the toolc
208208
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
209209
t.is(result.toolsVersion, `0.0.0-${version}`);
210210
t.is(result.toolsSource, ToolsSource.Download);
211-
t.is(typeof result.toolsDownloadDurationMs, "number");
211+
t.assert(Number.isInteger(result.toolsDownloadDurationMs));
212212
}
213213

214214
t.is(toolcache.findAllVersions("CodeQL").length, 2);
@@ -241,7 +241,7 @@ test("downloads an explicitly requested bundle even if a different version is ca
241241
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
242242
t.deepEqual(result.toolsVersion, "0.0.0-20200610");
243243
t.is(result.toolsSource, ToolsSource.Download);
244-
t.not(result.toolsDownloadDurationMs, undefined);
244+
t.assert(Number.isInteger(result.toolsDownloadDurationMs));
245245
});
246246
});
247247

@@ -293,7 +293,7 @@ for (const {
293293
t.assert(toolcache.find("CodeQL", expectedToolcacheVersion));
294294
t.deepEqual(result.toolsVersion, cliVersion);
295295
t.is(result.toolsSource, ToolsSource.Download);
296-
t.not(result.toolsDownloadDurationMs, undefined);
296+
t.assert(Number.isInteger(result.toolsDownloadDurationMs));
297297
});
298298
});
299299
}
@@ -428,7 +428,7 @@ for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
428428
);
429429
t.deepEqual(result.toolsVersion, defaults.cliVersion);
430430
t.is(result.toolsSource, ToolsSource.Download);
431-
t.is(typeof result.toolsDownloadDurationMs, "number");
431+
t.assert(Number.isInteger(result.toolsDownloadDurationMs));
432432

433433
const cachedVersions = toolcache.findAllVersions("CodeQL");
434434
t.is(cachedVersions.length, 2);
@@ -461,7 +461,7 @@ test('downloads bundle if "latest" tools specified but not cached', async (t) =>
461461
);
462462
t.deepEqual(result.toolsVersion, defaults.cliVersion);
463463
t.is(result.toolsSource, ToolsSource.Download);
464-
t.is(typeof result.toolsDownloadDurationMs, "number");
464+
t.assert(Number.isInteger(result.toolsDownloadDurationMs));
465465

466466
const cachedVersions = toolcache.findAllVersions("CodeQL");
467467
t.is(cachedVersions.length, 2);
@@ -527,7 +527,7 @@ test("download codeql bundle from github ae endpoint", async (t) => {
527527
);
528528

529529
t.is(result.toolsSource, ToolsSource.Download);
530-
t.is(typeof result.toolsDownloadDurationMs, "number");
530+
t.assert(Number.isInteger(result.toolsDownloadDurationMs));
531531

532532
const cachedVersions = toolcache.findAllVersions("CodeQL");
533533
t.is(cachedVersions.length, 1);

src/setup-codeql.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,9 @@ export async function downloadCodeQL(
568568
undefined,
569569
finalHeaders
570570
);
571-
const toolsDownloadDurationMs = performance.now() - toolsDownloadStart;
571+
const toolsDownloadDurationMs = Math.round(
572+
performance.now() - toolsDownloadStart
573+
);
572574

573575
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
574576

0 commit comments

Comments
 (0)