Skip to content

Commit

Permalink
Ensure that tools_download_duration_ms is int (#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelapwen authored Jan 27, 2023
1 parent b2e1676 commit 4664f39
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions lib/codeql.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.test.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/setup-codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/setup-codeql.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ test("downloads and caches explicitly requested bundles that aren't in the toolc
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
t.is(result.toolsVersion, `0.0.0-${version}`);
t.is(result.toolsSource, ToolsSource.Download);
t.is(typeof result.toolsDownloadDurationMs, "number");
t.assert(Number.isInteger(result.toolsDownloadDurationMs));
}

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

Expand Down Expand Up @@ -293,7 +293,7 @@ for (const {
t.assert(toolcache.find("CodeQL", expectedToolcacheVersion));
t.deepEqual(result.toolsVersion, cliVersion);
t.is(result.toolsSource, ToolsSource.Download);
t.not(result.toolsDownloadDurationMs, undefined);
t.assert(Number.isInteger(result.toolsDownloadDurationMs));
});
});
}
Expand Down Expand Up @@ -428,7 +428,7 @@ for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
);
t.deepEqual(result.toolsVersion, defaults.cliVersion);
t.is(result.toolsSource, ToolsSource.Download);
t.is(typeof result.toolsDownloadDurationMs, "number");
t.assert(Number.isInteger(result.toolsDownloadDurationMs));

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

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

t.is(result.toolsSource, ToolsSource.Download);
t.is(typeof result.toolsDownloadDurationMs, "number");
t.assert(Number.isInteger(result.toolsDownloadDurationMs));

const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 1);
Expand Down
4 changes: 3 additions & 1 deletion src/setup-codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,9 @@ export async function downloadCodeQL(
undefined,
finalHeaders
);
const toolsDownloadDurationMs = performance.now() - toolsDownloadStart;
const toolsDownloadDurationMs = Math.round(
performance.now() - toolsDownloadStart
);

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

Expand Down

0 comments on commit 4664f39

Please sign in to comment.