File tree 2 files changed +55
-0
lines changed
2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ import re
4
+ import sys
5
+ from pathlib import Path
6
+ from pprint import pprint
7
+
8
+ # VCMI supports JSON with comments, but not JSON5
9
+ import jstyleson
10
+
11
+ validation_failed = False
12
+
13
+ for path in sorted (Path ("." ).glob ("**/*.json" ), key = lambda path : str (path ).lower ()):
14
+ # because path is an object and not a string
15
+ path_str = str (path )
16
+ if path_str .startswith ("." ):
17
+ continue
18
+
19
+ try :
20
+ with open (path_str , "r" ) as file :
21
+ jstyleson .load (file )
22
+ print (f"✅ { path_str } " )
23
+ except Exception as exc :
24
+ print (f"❌ { path_str } : { exc } " )
25
+ validation_failed = True
26
+
27
+ if validation_failed :
28
+ sys .exit (1 )
Original file line number Diff line number Diff line change
1
+ name : Mod Validation
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - ' vcmi-*'
7
+ pull_request :
8
+ workflow_dispatch :
9
+
10
+
11
+ jobs :
12
+ validate-json :
13
+ if : always()
14
+ runs-on : ubuntu-24.04
15
+ defaults :
16
+ run :
17
+ shell : bash
18
+ steps :
19
+ - name : Checkout repository
20
+ uses : actions/checkout@v4
21
+
22
+ - name : Install jstyleson
23
+ run : sudo apt install python3-jstyleson
24
+
25
+ - name : Validate JSON
26
+ run : python3 .github/validate_json.py
27
+
You can’t perform that action at this time.
0 commit comments