Skip to content

Commit 8ea9fef

Browse files
author
Patrick Bareiss
committed
bug fixes
1 parent 757f9ce commit 8ea9fef

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

.github/workflows/validate.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ on:
1919
- 'bin/dataset_schema.json'
2020
- 'bin/requirements.txt'
2121

22+
permissions:
23+
contents: read
24+
issues: write
25+
pull-requests: write
26+
2227
jobs:
2328
validate-attack-data:
2429
runs-on: ubuntu-latest

bin/validate.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ def parse_arguments():
181181
formatter_class=argparse.RawDescriptionHelpFormatter,
182182
epilog="""
183183
Examples:
184-
%(prog)s # Validate files in the default 'datasets' directory
184+
%(prog)s # Validate files in default 'datasets' dir (failures only)
185+
%(prog)s -v # Validate with verbose output (show all files)
185186
%(prog)s /path/to/data # Validate files in a specific directory
186187
%(prog)s ../other_datasets # Validate files in a relative path
187188
"""
@@ -194,6 +195,12 @@ def parse_arguments():
194195
help='Directory to search for YAML files (default: datasets)'
195196
)
196197

198+
parser.add_argument(
199+
'-v', '--verbose',
200+
action='store_true',
201+
help='Show validation results for all files (default: only show failures)'
202+
)
203+
197204
return parser.parse_args()
198205

199206

@@ -239,7 +246,8 @@ def main():
239246
return
240247

241248
print(f"Found {len(yaml_files)} YAML files to validate...")
242-
print("-" * 60)
249+
if args.verbose:
250+
print("-" * 60)
243251

244252
total_files = len(yaml_files)
245253
valid_files = 0
@@ -254,20 +262,22 @@ def main():
254262
except ValueError:
255263
relative_path = yaml_file.relative_to(input_dir)
256264

257-
print(f"\nValidating: {relative_path}")
258-
259265
errors = validate_yaml_file(yaml_file, schema)
260266

261267
if errors:
262268
invalid_files += 1
263-
print(f"❌ INVALID - {len(errors)} error(s):")
269+
# Always show failures
270+
print(f"\n❌ INVALID: {relative_path}")
271+
print(f" {len(errors)} error(s):")
264272
for error in errors:
265273
print(f" • {error}")
266274
# Store failed validation details
267275
failed_validations.append((relative_path, errors))
268276
else:
269277
valid_files += 1
270-
print("✅ VALID")
278+
# Only show valid files in verbose mode
279+
if args.verbose:
280+
print(f"\n✅ VALID: {relative_path}")
271281

272282
# Print summary
273283
print("\n" + "=" * 60)
@@ -280,15 +290,16 @@ def main():
280290
if invalid_files > 0:
281291
print(f"\n{invalid_files} file(s) failed validation!")
282292

283-
# Print detailed failed validations at the end
284-
print("\n" + "=" * 60)
285-
print("FAILED VALIDATIONS")
286-
print("=" * 60)
287-
for file_path, errors in failed_validations:
288-
print(f"\n📁 {file_path}")
289-
print("-" * 40)
290-
for i, error in enumerate(errors, 1):
291-
print(f"{i}. {error}")
293+
# In verbose mode, also print detailed failed validations at the end
294+
if args.verbose and failed_validations:
295+
print("\n" + "=" * 60)
296+
print("FAILED VALIDATIONS SUMMARY")
297+
print("=" * 60)
298+
for file_path, errors in failed_validations:
299+
print(f"\n📁 {file_path}")
300+
print("-" * 40)
301+
for i, error in enumerate(errors, 1):
302+
print(f"{i}. {error}")
292303

293304
sys.exit(1)
294305
else:

0 commit comments

Comments
 (0)