diff --git a/src/functions/json-validator.js b/src/functions/json-validator.js index 6d74cca..d444cb6 100644 --- a/src/functions/json-validator.js +++ b/src/functions/json-validator.js @@ -149,6 +149,9 @@ export async function jsonValidator(exclude) { .withPromise() } + // Create a Set to track processed files + const processedFiles = new Set() + for (const fullPath of files) { core.debug(`found file: ${fullPath}`) @@ -188,6 +191,12 @@ export async function jsonValidator(exclude) { continue } + // Check if the file has already been processed + if (processedFiles.has(fullPath)) { + core.debug(`skipping duplicate file: ${fullPath}`) + continue + } + var data try { // if the file is a yaml file but being treated as json and yamlAsJson is true @@ -250,6 +259,9 @@ export async function jsonValidator(exclude) { continue } + // Add the file to the processedFiles Set + processedFiles.add(fullPath) + result.passed++ core.info(`${fullPath} is valid`) } diff --git a/src/functions/yaml-validator.js b/src/functions/yaml-validator.js index 2363470..b64e34b 100644 --- a/src/functions/yaml-validator.js +++ b/src/functions/yaml-validator.js @@ -62,6 +62,9 @@ export async function yamlValidator(exclude) { .withPromise() } + // Create a Set to track processed files + const processedFiles = new Set() + for (const fullPath of files) { core.debug(`found file: ${fullPath}`) @@ -93,6 +96,12 @@ export async function yamlValidator(exclude) { continue } + // Check if the file has already been processed + if (processedFiles.has(fullPath)) { + core.debug(`skipping duplicate file: ${fullPath}`) + continue + } + let multipleDocuments = false try { @@ -176,6 +185,9 @@ export async function yamlValidator(exclude) { continue } + // Add the file to the processedFiles Set + processedFiles.add(fullPath) + result.passed++ core.info(`${fullPath} is valid`) }