Allow check-diagnostics.ts to check multiple SARIF files

This commit is contained in:
Michael B. Gale
2026-10-21 16:29:38 +01:00
parent 00d7ef8570
commit 5a546846a4
3 changed files with 20 additions and 2 deletions

1
package-lock.json generated
View File

@@ -10488,6 +10488,7 @@
"@octokit/core": "^7.0.8",
"@octokit/plugin-paginate-rest": ">=16.0.0",
"@octokit/plugin-rest-endpoint-methods": "^18.0.0",
"glob": "^13.0.6",
"lite-matter": "^0.1.2",
"mdast-util-from-markdown": "^2.1.0",
"semver": "^7.8.5",

View File

@@ -1,6 +1,8 @@
import fs from "fs";
import path from "path";
import * as core from "@actions/core";
import { globSync } from "glob";
import * as sarif from "../src/sarif";
@@ -91,9 +93,23 @@ function checkSarif(sarifFile: string) {
const sarifPath = process.env["SARIF_PATH"];
if (sarifPath === undefined) {
throw new Error("The path to a SARIF file must be set in 'SARIF_PATH'.");
throw new Error(
"The path to a SARIF file or directory must be set in 'SARIF_PATH'.",
);
}
checkSarif(sarifPath);
if (fs.statSync(sarifPath).isDirectory()) {
const sarifFiles = globSync(path.join(sarifPath, "**", "*.sarif"));
if (sarifFiles.length < 1) {
throw new Error(`Unable to find any .sarif files in '${sarifPath}'.`);
}
for (const sarifFile of sarifFiles) {
checkSarif(sarifFile);
}
} else {
checkSarif(sarifPath);
}
core.info("Finished diagnostic export test");

View File

@@ -9,6 +9,7 @@
"@octokit/core": "^7.0.8",
"@octokit/plugin-paginate-rest": ">=16.0.0",
"@octokit/plugin-rest-endpoint-methods": "^18.0.0",
"glob": "^13.0.6",
"lite-matter": "^0.1.2",
"mdast-util-from-markdown": "^2.1.0",
"semver": "^7.8.5",