1
1
import json
2
- from pathlib import Path
2
+ import os
3
3
import re
4
+ from pathlib import Path
4
5
5
6
# Function to print GitHub action notice
6
7
def print_github_action_notice (file , url ):
7
8
print (f"::warning file={ file } ,line=1::Annotation: { url } " )
8
9
9
10
# Read specification URLs from JSON file
10
- with open ("specification_urls.json" , "r" ) as f :
11
+ with open ("bin/ specification_urls.json" , "r" ) as f :
11
12
urls = json .load (f )
12
13
13
- # Iterate through files in tests folder
14
- for root , dirs , files in Path ("tests" ). walk ( ):
15
- for file in files :
16
- if file .endswith (' .json' ): # Check if file is JSON
17
- file_path = root / file
18
-
14
+ # Iterate through JSON files in tests folder and subdirectories
15
+ for root , dirs , files in os . walk ("tests" ):
16
+ for file_name in files :
17
+ if file_name .endswith (" .json" ):
18
+ file_path = os . path . join ( root , file_name )
19
+
19
20
# Read the file content
20
- with open (file_path , "r" ) as f :
21
+ with open (file_path , 'r' , encoding = 'utf-8' ) as f :
21
22
changed_file_content = f .read ()
22
23
23
24
# Parse JSON content
@@ -27,7 +28,7 @@ def print_github_action_notice(file, url):
27
28
if "specification" in test :
28
29
for specification_object in test ["specification" ]:
29
30
for spec , section in specification_object .items ():
30
- draft = root . split ( '/' )[ - 1 ]
31
+ draft = Path ( file_path ). parent . name
31
32
if spec in ["core" , "validation" , "hyper-schema" ]:
32
33
print_github_action_notice (file_path , urls [draft ][spec ] + section )
33
34
elif spec in ["quote" ]:
0 commit comments