Do not fail diff informed analyses when analyze is run twice in the same job

This commit is contained in:
Henry Mercer 2025-05-01 12:00:46 +01:00
parent 018ac1a585
commit 083772aae4
3 changed files with 14 additions and 3 deletions

7
lib/analyze.js generated
View file

@ -343,7 +343,12 @@ function writeDiffRangeDataExtensionPack(logger, ranges) {
ranges = [{ path: "", startLine: 0, endLine: 0 }];
}
const diffRangeDir = path.join(actionsUtil.getTemporaryDirectory(), "pr-diff-range");
fs.mkdirSync(diffRangeDir);
// We expect the Actions temporary directory to already exist, so are mainly
// using `recursive: true` to avoid errors if the directory already exists,
// for example if the analyze Action is run multiple times in the same job.
// This is not really something that is supported, but we make use of it in
// tests.
fs.mkdirSync(diffRangeDir, { recursive: true });
fs.writeFileSync(path.join(diffRangeDir, "qlpack.yml"), `
name: codeql-action/pr-diff-range
version: 0.0.0

File diff suppressed because one or more lines are too long

View file

@ -498,7 +498,13 @@ function writeDiffRangeDataExtensionPack(
actionsUtil.getTemporaryDirectory(),
"pr-diff-range",
);
fs.mkdirSync(diffRangeDir);
// We expect the Actions temporary directory to already exist, so are mainly
// using `recursive: true` to avoid errors if the directory already exists,
// for example if the analyze Action is run multiple times in the same job.
// This is not really something that is supported, but we make use of it in
// tests.
fs.mkdirSync(diffRangeDir, { recursive: true });
fs.writeFileSync(
path.join(diffRangeDir, "qlpack.yml"),
`