Compare commits

..

3 Commits

Author SHA1 Message Date
Michael B. Gale
30b6b5983f Merge branch 'main' into dependabot/npm_and_yarn/node-forge-1.4.2 2026-11-06 12:48:49 +00:00
github-actions[bot]
cb978e786f Rebuild 2026-11-03 16:10:59 +00:00
dependabot[bot]
d977fcd628 Bump node-forge from 1.4.1 to 1.4.2
Bumps [node-forge](https://github.com/digitalbazaar/forge) from 1.4.1 to 1.4.2.
- [Changelog](https://github.com/digitalbazaar/forge/blob/main/CHANGELOG.md)
- [Commits](https://github.com/digitalbazaar/forge/compare/v1.4.1...v1.4.2)

---
updated-dependencies:
- dependency-name: node-forge
  dependency-version: 1.4.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-03 16:07:51 +00:00
18 changed files with 845 additions and 992 deletions

View File

@@ -79,6 +79,7 @@ jobs:
- ubuntu-24.04
- windows-2022
- windows-2025
- macos-14-xlarge
- macos-15-xlarge
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
runs-on: ${{ matrix.os }}

1520
lib/entry-points.js generated

File diff suppressed because it is too large Load Diff

8
package-lock.json generated
View File

@@ -33,7 +33,7 @@
"js-yaml": "^5.5.0",
"jsonschema": "1.5.0",
"long": "^5.3.2",
"node-forge": "^1.4.1",
"node-forge": "^1.4.2",
"semver": "^7.8.5",
"undici": "^7.30.1",
"uuid": "^14.0.3"
@@ -8198,9 +8198,9 @@
}
},
"node_modules/node-forge": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.1.tgz",
"integrity": "sha512-w5/MfWaeMrpR/5ba6fZyAUTLSuE6aYz7H/3cYrqwZEmf5eQS3IaaLgJt4MBv7HglGFWmV22K8h4U18RJQmw/ow==",
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.2.tgz",
"integrity": "sha512-rRtAR5XLJ8gCKd9du4qrKAsgCG1ObGP4gLeNJMa4vYSeq4bmBMOJk5IHkrviBV0q7uoAJlVd8HEQYQSVUb4FGQ==",
"license": "(BSD-3-Clause OR GPL-2.0)",
"engines": {
"node": ">= 6.13.0"

View File

@@ -43,7 +43,7 @@
"js-yaml": "^5.5.0",
"jsonschema": "1.5.0",
"long": "^5.3.2",
"node-forge": "^1.4.1",
"node-forge": "^1.4.2",
"semver": "^7.8.5",
"undici": "^7.30.1",
"uuid": "^14.0.3"

View File

@@ -24,5 +24,3 @@ is:
# PRs), so requiring them would block the PRs they don't run on.
- "github-advanced-security"
- "License compliance check"
# Only runs when a PR is removed from the merge queue.
- "Notify"

View File

@@ -78,6 +78,12 @@ export function getTemporaryDirectory(env: ReadOnlyEnv = getEnv()): string {
);
}
const PR_DIFF_RANGE_JSON_FILENAME = "pr-diff-range.json";
export function getDiffRangesJsonFilePath(env: Env = getEnv()): string {
return path.join(getTemporaryDirectory(env), PR_DIFF_RANGE_JSON_FILENAME);
}
export function getActionVersion(): string {
return __CODEQL_ACTION_VERSION__;
}

View File

@@ -19,10 +19,9 @@ import {
} from "./dependency-caching";
import { addDiagnostic, makeDiagnostic } from "./diagnostics";
import {
type DiffThunkRange,
getDiffRangesJsonFilePath,
DiffThunkRange,
readDiffRangesJsonFile,
} from "./diff-informed";
} from "./diff-informed-analysis-utils";
import { EnvVar } from "./environment";
import { FeatureEnablement, Feature } from "./feature-flags";
import { getGitRoot } from "./git-utils";
@@ -296,10 +295,7 @@ export async function setupDiffInformedQueryRun(
return await withGroupAsync(
"Generating diff range extension pack",
async () => {
const diffRanges = readDiffRangesJsonFile(
logger,
getDiffRangesJsonFilePath(),
);
const diffRanges = readDiffRangesJsonFile(logger);
if (diffRanges === undefined) {
logger.info(
"No precomputed diff ranges found; skipping diff-informed analysis stage.",

View File

@@ -15,7 +15,6 @@ import { createStubCodeQL } from "./codeql";
import { UserConfig } from "./config/db-config";
import * as file from "./config/file";
import * as configUtils from "./config-utils";
import { ActionsEnvVars } from "./environment";
import * as errorMessages from "./error-messages";
import { Feature } from "./feature-flags";
import { RepositoryProperties } from "./feature-flags/properties";
@@ -43,7 +42,6 @@ import {
SAMPLE_DOTCOM_API_DETAILS,
AssertableTarget,
RecordingLogger,
getTestEnv,
} from "./testing-utils";
import {
GitHubVariant,
@@ -153,11 +151,9 @@ function mockListLanguages(languages: string[]) {
test.serial("load empty config", async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = new RecordingLogger();
const state = initAllState({ logger });
const languages = "javascript,python";
setupActionsVars(tempDir, tempDir, {}, state.env);
setupActionsVars(tempDir, tempDir);
const codeql = createStubCodeQL({
async resolveLanguages() {
@@ -170,6 +166,7 @@ test.serial("load empty config", async (t) => {
},
});
const state = initAllState({ logger });
const config = await configUtils.initConfig(
state,
createTestInitConfigInputs({
@@ -200,10 +197,9 @@ test.serial("load empty config", async (t) => {
test.serial("load code quality config", async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = new RecordingLogger();
const state = initAllState({ logger });
const languages = "actions";
setupActionsVars(tempDir, tempDir, {}, state.env);
setupActionsVars(tempDir, tempDir);
const codeql = createStubCodeQL({
async resolveLanguages() {
@@ -215,6 +211,7 @@ test.serial("load code quality config", async (t) => {
},
});
const state = initAllState({ logger });
const config = await configUtils.initConfig(
state,
createTestInitConfigInputs({
@@ -256,10 +253,9 @@ test.serial(
async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = new RecordingLogger();
const state = initAllState({ logger });
const languages = "javascript";
setupActionsVars(tempDir, tempDir, {}, state.env);
setupActionsVars(tempDir, tempDir);
const codeql = createStubCodeQL({
async resolveLanguages() {
@@ -295,6 +291,7 @@ test.serial(
repositoryProperties,
});
const state = initAllState({ logger });
await t.notThrowsAsync(async () => {
const config = await configUtils.initConfig(
state,
@@ -319,8 +316,6 @@ test.serial(
test.serial("loading a saved config produces the same config", async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = new RecordingLogger();
const state = initAllState({ logger });
setupActionsVars(tempDir, tempDir, {}, state.env);
const codeql = createStubCodeQL({
async resolveLanguages() {
@@ -339,6 +334,7 @@ test.serial("loading a saved config produces the same config", async (t) => {
// Sanity check that getConfig returns undefined before we have called initConfig
t.deepEqual(await configUtils.getConfig(tempDir, logger), undefined);
const state = initAllState({ logger });
const config1 = await configUtils.initConfig(
state,
createTestInitConfigInputs({
@@ -368,8 +364,6 @@ test.serial("loading a saved config produces the same config", async (t) => {
test.serial("loading config with version mismatch throws", async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = new RecordingLogger();
const state = initAllState({ logger });
setupActionsVars(tempDir, tempDir, {}, state.env);
const codeql = createStubCodeQL({
async resolveLanguages() {
@@ -393,6 +387,7 @@ test.serial("loading config with version mismatch throws", async (t) => {
.stub(actionsUtil, "getActionVersion")
.returns("does-not-exist");
const state = initAllState({ logger });
const config = await configUtils.initConfig(
state,
createTestInitConfigInputs({
@@ -502,8 +497,7 @@ const otherConfigFileContents = `
test.serial("load non-empty input", async (t) => {
return await withTmpDir(async (tempDir) => {
const state = initAllState();
setupActionsVars(tempDir, tempDir, {}, state.env);
setupActionsVars(tempDir, tempDir);
const codeql = createStubCodeQL({
async resolveLanguages() {
@@ -544,6 +538,7 @@ test.serial("load non-empty input", async (t) => {
const languagesInput = "javascript";
const configFilePath = createConfigFile(otherConfigFileContents, tempDir);
const state = initAllState();
const actualConfig = await configUtils.initConfig(
state,
createTestInitConfigInputs({
@@ -662,9 +657,7 @@ test.serial("API client used when reading remote config", async (t) => {
const configFile = "octo-org/codeql-config/config.yaml@main";
const languagesInput = "javascript";
const state = initAllState({
env: getTestEnv({ [ActionsEnvVars.RUNNER_TEMP]: tempDir }),
});
const state = initAllState();
await configUtils.initConfig(
state,
createTestInitConfigInputs({

View File

@@ -48,10 +48,7 @@ import {
addNoLanguageDiagnostic,
makeTelemetryDiagnostic,
} from "./diagnostics";
import {
getDiffRangesJsonFilePath,
prepareDiffInformedAnalysis,
} from "./diff-informed";
import { prepareDiffInformedAnalysis } from "./diff-informed-analysis-utils";
import { EnvVar, exportEnvVar, getEnv } from "./environment";
import * as errorMessages from "./error-messages";
import { Feature, FeatureEnablement, FeatureWithoutCLI } from "./feature-flags";
@@ -1291,10 +1288,9 @@ export async function initConfig(
}
const hasDiffRanges = await prepareDiffInformedAnalysis(
logger,
inputs.features,
inputs.codeql,
getDiffRangesJsonFilePath(actionState.env),
inputs.features,
logger,
);
await applyIncrementalAnalysisSettings(

View File

@@ -1,12 +1,16 @@
import test, { ExecutionContext } from "ava";
import * as sinon from "sinon";
import * as actionsUtil from "../actions-util";
import type { PullRequestBranches } from "../actions-util";
import * as apiClient from "../api-client";
import { getEnv } from "../environment";
import { Feature, FeatureEnablement, initFeatures } from "../feature-flags";
import { parseRepositoryNwo } from "../repository";
import * as actionsUtil from "./actions-util";
import type { PullRequestBranches } from "./actions-util";
import * as apiClient from "./api-client";
import {
getDiffInformedAnalysisBranches,
prepareDiffInformedAnalysis,
exportedForTesting,
} from "./diff-informed-analysis-utils";
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
import { parseRepositoryNwo } from "./repository";
import {
setupTests,
createFeatures,
@@ -15,16 +19,9 @@ import {
setupActionsVars,
makeMacro,
RecordingLogger,
} from "../testing-utils";
import { GitHubVariant, withTmpDir } from "../util";
import type { GitHubVersion } from "../util";
import {
getDiffInformedAnalysisBranches,
prepareDiffInformedAnalysis,
exportedForTesting,
getDiffRangesJsonFilePath,
} from ".";
} from "./testing-utils";
import { GitHubVariant, withTmpDir } from "./util";
import type { GitHubVersion } from "./util";
setupTests(test);
@@ -195,10 +192,9 @@ test.serial(
.resolves({ type: GitHubVariant.DOTCOM });
const result = await prepareDiffInformedAnalysis(
logger,
features,
codeql,
getDiffRangesJsonFilePath(getEnv()),
features,
logger,
);
t.false(result);
@@ -226,10 +222,9 @@ test.serial(
};
const result = await prepareDiffInformedAnalysis(
logger,
features,
codeql,
getDiffRangesJsonFilePath(getEnv()),
features,
logger,
);
t.false(result);
@@ -264,10 +259,9 @@ test.serial(
} as any);
const result = await prepareDiffInformedAnalysis(
logger,
features,
codeql,
getDiffRangesJsonFilePath(getEnv()),
features,
logger,
);
t.true(result);
@@ -302,10 +296,9 @@ test.serial(
} as any);
const result = await prepareDiffInformedAnalysis(
logger,
features,
codeql,
getDiffRangesJsonFilePath(getEnv()),
features,
logger,
);
t.false(result);

View File

@@ -1,43 +1,23 @@
import * as fs from "fs";
import path from "path";
import * as actionsUtil from "../actions-util";
import type { PullRequestBranches } from "../actions-util";
import { getApiClient, getGitHubVersion } from "../api-client";
import type { CodeQL } from "../codeql";
import { type Env, getEnv } from "../environment";
import type { FeatureEnablement } from "../feature-flags";
import { Feature } from "../feature-flags/features";
import { Logger } from "../logging";
import { getRepositoryNwoFromEnv } from "../repository";
import { getErrorMessage, GitHubVariant, satisfiesGHESVersion } from "../util";
/** The filename used to persist PR diff ranges. */
const PR_DIFF_RANGE_JSON_FILENAME = "pr-diff-range.json";
/**
* Gets the full path of the file used to persist PR diff ranges.
*/
export function getDiffRangesJsonFilePath(env: Env = getEnv()): string {
return path.join(
actionsUtil.getTemporaryDirectory(env),
PR_DIFF_RANGE_JSON_FILENAME,
);
}
import * as actionsUtil from "./actions-util";
import type { PullRequestBranches } from "./actions-util";
import { getApiClient, getGitHubVersion } from "./api-client";
import type { CodeQL } from "./codeql";
import { Feature, FeatureEnablement } from "./feature-flags";
import { Logger } from "./logging";
import { getRepositoryNwoFromEnv } from "./repository";
import { getErrorMessage, GitHubVariant, satisfiesGHESVersion } from "./util";
/**
* This interface is an abbreviated version of the file diff object returned by
* the GitHub API.
*/
export interface FileDiff {
/** The name of the file that has changed. */
interface FileDiff {
filename: string;
/** The number of changes. */
changes: number;
/**
* The diff, if available. It may be absent if the file is binary, if the file diff is too large,
* or if the file is unchanged.
*/
// A patch may be absent if the file is binary, if the file diff is too large,
// or if the file is unchanged.
patch?: string | undefined;
}
@@ -83,10 +63,9 @@ export async function getDiffInformedAnalysisBranches(
* and are therefore available for use, `false` otherwise.
*/
export async function prepareDiffInformedAnalysis(
logger: Logger,
features: FeatureEnablement,
codeql: CodeQL,
jsonFilePath: string,
features: FeatureEnablement,
logger: Logger,
): Promise<boolean> {
let branches: PullRequestBranches | undefined;
try {
@@ -105,7 +84,7 @@ export async function prepareDiffInformedAnalysis(
}
try {
return await computeAndPersistDiffRanges(logger, jsonFilePath, branches);
return await computeAndPersistDiffRanges(branches, logger);
} catch (e) {
logger.warning(
`Failed to compute diff-informed analysis ranges: ${getErrorMessage(e)}`,
@@ -114,45 +93,29 @@ export async function prepareDiffInformedAnalysis(
}
}
/** Describes a changed line range in a file. */
export interface DiffThunkRange {
/** Relative path from the repository root, using forward slashes as separators. */
path: string;
/** The starting line of the change (1-based and inclusive). */
startLine: number;
/** The last line of the change (1-based and inclusive). */
endLine: number;
}
/**
* Writes an array of {@link DiffThunkRange} objects to the file given by {@link jsonFilePath}.
*
* @param logger The logger to use.
* @param jsonFilePath The path of the file to write.
* @param ranges The changed line ranges to write.
*/
export function writeDiffRangesJsonFile(
logger: Logger,
jsonFilePath: string,
ranges: DiffThunkRange[],
): void {
const jsonContents = JSON.stringify(ranges, null, 2);
const jsonFilePath = actionsUtil.getDiffRangesJsonFilePath();
fs.writeFileSync(jsonFilePath, jsonContents);
logger.debug(
`Wrote pr-diff-range JSON file to ${jsonFilePath}:\n${jsonContents}`,
);
}
/**
* Reads an array of {@link DiffThunkRange} objects from the file given by {@link jsonFilePath}.
*
* @param logger The logger to use.
* @returns The array of {@link DiffThunkRange} objects or `undefined` if the file couldn't be read.
*/
export function readDiffRangesJsonFile(
logger: Logger,
jsonFilePath: string,
): DiffThunkRange[] | undefined {
const jsonFilePath = actionsUtil.getDiffRangesJsonFilePath();
if (!fs.existsSync(jsonFilePath)) {
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`);
return undefined;
@@ -175,12 +138,12 @@ export function readDiffRangesJsonFile(
* Return the file line ranges that were added or modified in the pull request.
*
* @param branches The base and head branches of the pull request.
* @param logger The logger to use.
*
* @returns
* An array of {@link DiffThunkRange} objects, where each describes a line range in a file
* that was changed in the pull request described by {@link branches} or `undefined` if
* we were unable to compute them.
* @param logger
* @returns An array of tuples, where each tuple contains the relative path of a
* file (relative to the repository root, as returned by the GitHub compare API),
* the start line and the end line (both 1-based and inclusive) of an
* added or modified range in that file. Returns `undefined` if the action was
* not triggered by a pull request or if there was an error.
*/
export async function getPullRequestEditedDiffRanges(
branches: PullRequestBranches,
@@ -217,25 +180,22 @@ export async function getPullRequestEditedDiffRanges(
* diff from the GitHub API and writes it to the diff ranges JSON file so that
* CodeQL can use it for diff-informed analysis.
*
* @param logger The logger to use.
* @param jsonFilePath The path of the JSON file to write.
* @param branches The base and head branches of the pull request, as returned
* by `getDiffInformedAnalysisBranches`.
*
* @param logger
* @returns `true` if the diff ranges were successfully computed and persisted,
* otherwise `false`.
*/
export async function computeAndPersistDiffRanges(
logger: Logger,
jsonFilePath: string,
branches: PullRequestBranches,
logger: Logger,
): Promise<boolean> {
logger.info("Computing PR diff ranges...");
const ranges = await getPullRequestEditedDiffRanges(branches, logger);
if (ranges === undefined) {
return false;
}
writeDiffRangesJsonFile(logger, jsonFilePath, ranges);
writeDiffRangesJsonFile(logger, ranges);
const distinctFiles = new Set(ranges.map((r) => r.path)).size;
logger.info(
`Persisted ${ranges.length} diff range(s) across ${distinctFiles} file(s).`,
@@ -243,19 +203,6 @@ export async function computeAndPersistDiffRanges(
return true;
}
/**
* Fetch an array of {@link FileDiff} objects using the GitHub API describing the changed files
* in the pull request with the base and head refs given by {@link branches}.
*
* @param branches The pull request branch refs.
* @param logger The logger to use.
*
* @throws Non-HTTP errors that occur while fetching the file diffs.
*
* @returns
* An array of {@link FileDiff} objects describing the changed files in the PR, or
* `undefined` if we couldn't obtain the changed files from the API.
*/
async function getFileDiffsWithBasehead(
branches: PullRequestBranches,
logger: Logger,
@@ -296,16 +243,6 @@ async function getFileDiffsWithBasehead(
}
}
/**
* Extracts an array of {@link DiffThunkRange} objects from {@link fileDiff}.
*
* @param fileDiff The {@link FileDiff} object describing changes to a particular file.
* @param logger The logger to use.
*
* @returns
* The {@link DiffThunkRange} objects extracted from {@link fileDiff},
* or `undefined` if there are none that could be extracted.
*/
function getDiffRanges(
fileDiff: FileDiff,
logger: Logger,

View File

@@ -5,7 +5,6 @@ import test from "ava";
import * as sinon from "sinon";
import * as actionsUtil from "../actions-util";
import * as diffInformed from "../diff-informed";
import * as gitUtils from "../git-utils";
import {
createTestConfig,
@@ -61,7 +60,7 @@ test.serial(
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
sinon
.stub(diffInformed, "getDiffRangesJsonFilePath")
.stub(actionsUtil, "getDiffRangesJsonFilePath")
.returns(diffRangeFilePath);
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
const changesFilePath = await writeOverlayChangesFile(
@@ -127,7 +126,7 @@ test.serial(
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
sinon
.stub(diffInformed, "getDiffRangesJsonFilePath")
.stub(actionsUtil, "getDiffRangesJsonFilePath")
.returns(diffRangeFilePath);
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
@@ -197,7 +196,7 @@ test.serial(
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
sinon
.stub(diffInformed, "getDiffRangesJsonFilePath")
.stub(actionsUtil, "getDiffRangesJsonFilePath")
.returns(diffRangeFilePath);
sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot);
@@ -260,7 +259,7 @@ test.serial(
const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json");
sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir);
sinon
.stub(diffInformed, "getDiffRangesJsonFilePath")
.stub(actionsUtil, "getDiffRangesJsonFilePath")
.returns(diffRangeFilePath);
// getGitRoot returns the repo root (parent of sourceRoot)
sinon.stub(gitUtils, "getGitRoot").resolves(repoRoot);

View File

@@ -1,9 +1,9 @@
import * as fs from "fs";
import * as path from "path";
import * as actionsUtil from "../actions-util";
import { getOptionalInput, getTemporaryDirectory } from "../actions-util";
import { type Config } from "../config-utils";
import { getDiffRangesJsonFilePath } from "../diff-informed";
import { getFileOidsUnderPath, getGitRoot } from "../git-utils";
import { Logger } from "../logging";
import { getBaseDatabaseOidsFilePath } from "../util";
@@ -135,7 +135,7 @@ async function getDiffRangeFilePaths(
sourceRoot: string,
logger: Logger,
): Promise<string[]> {
const jsonFilePath = getDiffRangesJsonFilePath();
const jsonFilePath = actionsUtil.getDiffRangesJsonFilePath();
if (!fs.existsSync(jsonFilePath)) {
logger.debug(

View File

@@ -1821,8 +1821,7 @@ function createToolcacheEntry(
/**
* Stubs out the download and the diagnostic sink, then downloads the CodeQL tools.
*
* @returns the extraction directory and, if the toolcache cleanup diagnostic was emitted, the
* cleanup duration it reports and its other attributes.
* @returns the extraction directory and the toolcache cleanup diagnostic, if emitted.
*/
async function runDownloadCodeQL(
toolcacheRoot: string,
@@ -1838,7 +1837,6 @@ async function runDownloadCodeQL(
): Promise<{
codeqlFolder: string;
cleanupDiagnostic: toolsDownload.ToolcacheCleanupResult | undefined;
cleanupDurationMs: number | undefined;
}> {
stubDownloadAndExtract();
const addDiagnostic = sinon.stub(diagnostics, "addNoLanguageDiagnostic");
@@ -1868,21 +1866,11 @@ async function runDownloadCodeQL(
.map((call) => call.args[1])
.find((d) => d.source?.id === "codeql-action/toolcache-bundle-cleanup");
if (diagnostic === undefined) {
return {
codeqlFolder,
cleanupDiagnostic: undefined,
cleanupDurationMs: undefined,
};
}
// The duration varies between runs, so split it out to let tests compare the other attributes
// exactly.
const { durationMs, ...cleanupDiagnostic } =
diagnostic.attributes as toolsDownload.ToolcacheCleanupResult & {
durationMs: number;
};
return { codeqlFolder, cleanupDiagnostic, cleanupDurationMs: durationMs };
return {
codeqlFolder,
cleanupDiagnostic: diagnostic?.attributes as
toolsDownload.ToolcacheCleanupResult | undefined,
};
}
/**
@@ -2003,35 +1991,6 @@ test.serial(
},
);
test.serial(
"downloadCodeQLBundle reports the total time taken to clean up the toolcache",
async (t) => {
await withTmpDir(async (tmpDir) => {
setupActionsVars(tmpDir, tmpDir);
createToolcacheEntry(tmpDir, "CodeQL", CLEANUP_CLI_VERSION);
createToolcacheEntry(tmpDir, "CodeQL", CLEANUP_STALE_VERSION);
// Advance the clock by 1.5s each time a path is deleted, so that deleting both versions
// takes 3s.
let elapsedMs = 1000;
sinon.stub(performance, "now").callsFake(() => elapsedMs);
const rm = fs.promises.rm;
sinon.stub(fs.promises, "rm").callsFake(async (...args) => {
elapsedMs += 1500;
await rm(...args);
});
const { cleanupDurationMs } = await runDownloadCodeQL(
tmpDir,
CLEANUP_BUNDLE_VERSION,
);
t.is(cleanupDurationMs, 3000);
});
},
);
test.serial(
"downloadCodeQLBundle reports no deleted versions when the toolcache has no CodeQL bundles",
async (t) => {

View File

@@ -814,7 +814,6 @@ async function tryDeleteToolcacheBundles({
return;
}
const startTime = performance.now();
const result = await deleteToolcacheBundles({ env, logger });
addNoLanguageDiagnostic(
@@ -822,7 +821,7 @@ async function tryDeleteToolcacheBundles({
makeTelemetryDiagnostic(
"codeql-action/toolcache-bundle-cleanup",
"Toolcache CodeQL bundle cleanup",
{ ...result, durationMs: util.durationMsSince(startTime) },
{ ...result },
),
);
}

View File

@@ -342,16 +342,13 @@ export async function deleteToolcacheBundles({
const versionDirectory = path.join(toolDirectory, entry.name);
try {
const deletionStart = performance.now();
await fs.promises.rm(versionDirectory, {
force: true,
recursive: true,
});
deletedVersions.push(entry.name);
logger.info(
`Deleted the CodeQL tools at '${versionDirectory}' from the toolcache to free up disk space (${formatDuration(
durationMsSince(deletionStart),
)}).`,
`Deleted the CodeQL tools at '${versionDirectory}' from the toolcache to free up disk space.`,
);
} catch (e) {
failed = true;

View File

@@ -9,7 +9,7 @@ import * as sinon from "sinon";
import * as analyses from "./analyses";
import { AnalysisKind, CodeQuality, CodeScanning } from "./analyses";
import * as api from "./api-client";
import * as diffUtils from "./diff-informed";
import * as diffUtils from "./diff-informed-analysis-utils";
import { getEnv } from "./environment";
import { Logger } from "./logging";
import * as sarif from "./sarif";
@@ -1074,7 +1074,6 @@ function runFilterAlertsByDiffRange(
logger: Logger = new RecordingLogger(),
): Partial<sarif.Log> {
sinon.stub(diffUtils, "readDiffRangesJsonFile").returns(diffRanges);
sinon.stub(diffUtils, "getDiffRangesJsonFilePath").returns("");
return uploadLib.filterAlertsByDiffRange(logger, input);
}

View File

@@ -13,10 +13,7 @@ import * as api from "./api-client";
import { getGitHubVersion, wrapApiConfigurationError } from "./api-client";
import { CodeQL, getCodeQL } from "./codeql";
import type { ActionConfig } from "./config/action-config";
import {
getDiffRangesJsonFilePath,
readDiffRangesJsonFile,
} from "./diff-informed";
import { readDiffRangesJsonFile } from "./diff-informed-analysis-utils";
import { ActionsEnvVars, EnvVar, exportEnvVar } from "./environment";
import { FeatureEnablement } from "./feature-flags";
import * as fingerprints from "./fingerprints";
@@ -1082,10 +1079,7 @@ export function filterAlertsByDiffRange(
logger: Logger,
sarifLog: Partial<sarif.Log>,
): Partial<sarif.Log> {
const diffRanges = readDiffRangesJsonFile(
logger,
getDiffRangesJsonFilePath(),
);
const diffRanges = readDiffRangesJsonFile(logger);
if (!diffRanges?.length) {
return sarifLog;
}