浏览代码

Only validate JSON on Linux

Alexander Wilms 2 年之前
父节点
当前提交
512816b223
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 5 7
      .github/validate_json.py
  2. 2 0
      .github/workflows/github.yml

+ 5 - 7
.github/validate_json.py

@@ -1,13 +1,14 @@
-import jstyleson
+import re
 from pathlib import Path
 from pprint import pprint
-import yaml
+
 import json5
-import re
+import jstyleson
+import yaml
 
 # 'json', 'json5' or 'yaml'
 # json:  strict, but doesn't preserve line numbers necessarily, since it strips comments before parsing
-# json5: strict and preserves line numbers even for files will with line comments
+# json5: strict and preserves line numbers even for files with line comments
 # yaml:  less strict, allows e.g. leading zeros
 VALIDATION_TYPE = 'json5'
 
@@ -20,10 +21,8 @@ for path in sorted(Path('.').glob('**/*.json')):
             if VALIDATION_TYPE == 'json':
                 jstyleson.load(file)
             if VALIDATION_TYPE == 'json5':
-                
                 json5.load(file)
             elif VALIDATION_TYPE == 'yaml':
-                
                 file = file.read().replace("\t", "    ")
                 file = file.replace("//", "#")
                 yaml.safe_load(file)
@@ -38,7 +37,6 @@ for path in sorted(Path('.').glob('**/*.json')):
             # https://stackoverflow.com/a/72850269/2278742
             error_pos = f"{path_str}:{exc.lineno}:{exc.colno}"
             print(error_pos)
-            # error_msg = "position": position_msg, "exception": exc
         if hasattr(exc, 'problem_mark'):
             mark = exc.problem_mark
             error_pos = f"{path_str}:{mark.line+1}:{mark.column+1}"

+ 2 - 0
.github/workflows/github.yml

@@ -146,6 +146,8 @@ jobs:
         submodules: recursive
 
     - name: Validate JSON
+      # the Python yaml module doesn't seem to work on mac-arm
+      if: ${{ startsWith(matrix.preset, 'linux') }}
       run: |
         pip3 install json5 jstyleson
         python3 .github/validate_json.py