From 5a546846a418cbd4a2994a4d5ac937f6b3b98299 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Wed, 21 Oct 2026 16:29:38 +0100 Subject: [PATCH] Allow `check-diagnostics.ts` to check multiple SARIF files --- package-lock.json | 1 + pr-checks/check-diagnostics.ts | 20 ++++++++++++++++++-- pr-checks/package.json | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c06678b60..ec0adc691 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/pr-checks/check-diagnostics.ts b/pr-checks/check-diagnostics.ts index 13bec9c3c..b77e6d34a 100644 --- a/pr-checks/check-diagnostics.ts +++ b/pr-checks/check-diagnostics.ts @@ -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"); diff --git a/pr-checks/package.json b/pr-checks/package.json index 343f94381..a29428b9f 100644 --- a/pr-checks/package.json +++ b/pr-checks/package.json @@ -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",