Skip to content

Commit 7909d63

Browse files
committed
Fix file validation in action summary
Fixes #70 --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/GrantBirki/json-yaml-validate/issues/70?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent 8dca03d commit 7909d63

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/functions/json-validator.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ export async function jsonValidator(exclude) {
149149
.withPromise()
150150
}
151151

152+
// Create a Set to track processed files
153+
const processedFiles = new Set()
154+
152155
for (const fullPath of files) {
153156
core.debug(`found file: ${fullPath}`)
154157

@@ -188,6 +191,12 @@ export async function jsonValidator(exclude) {
188191
continue
189192
}
190193

194+
// Check if the file has already been processed
195+
if (processedFiles.has(fullPath)) {
196+
core.debug(`skipping duplicate file: ${fullPath}`)
197+
continue
198+
}
199+
191200
var data
192201
try {
193202
// 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) {
250259
continue
251260
}
252261

262+
// Add the file to the processedFiles Set
263+
processedFiles.add(fullPath)
264+
253265
result.passed++
254266
core.info(`${fullPath} is valid`)
255267
}

src/functions/yaml-validator.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export async function yamlValidator(exclude) {
6262
.withPromise()
6363
}
6464

65+
// Create a Set to track processed files
66+
const processedFiles = new Set()
67+
6568
for (const fullPath of files) {
6669
core.debug(`found file: ${fullPath}`)
6770

@@ -93,6 +96,12 @@ export async function yamlValidator(exclude) {
9396
continue
9497
}
9598

99+
// Check if the file has already been processed
100+
if (processedFiles.has(fullPath)) {
101+
core.debug(`skipping duplicate file: ${fullPath}`)
102+
continue
103+
}
104+
96105
let multipleDocuments = false
97106

98107
try {
@@ -176,6 +185,9 @@ export async function yamlValidator(exclude) {
176185
continue
177186
}
178187

188+
// Add the file to the processedFiles Set
189+
processedFiles.add(fullPath)
190+
179191
result.passed++
180192
core.info(`${fullPath} is valid`)
181193
}

0 commit comments

Comments
 (0)