Skip to content

Commit

Permalink
Fix file validation in action summary
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Aug 24, 2024
1 parent 8dca03d commit 7909d63
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/functions/json-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`)
}
Expand Down
12 changes: 12 additions & 0 deletions src/functions/yaml-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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`)
}
Expand Down

0 comments on commit 7909d63

Please sign in to comment.