1+ import os
2+ import fnmatch
13import sys
24import json
35import re
@@ -50,6 +52,7 @@ def check_config_keys_and_values(service_config: dict) -> None:
5052 stubs_configs_file_path = sys .argv [1 ]
5153 protos_output_folder = sys .argv [2 ].split ('/' )[1 ]
5254 protos_folder = sys .argv [3 ].split ('/' )[1 ]
55+ print (f'protos folder: { protos_folder } ' )
5356
5457 # read stubs configs file
5558 stubs_json_dict = json .loads (open (stubs_configs_file_path , 'r' ).read ())
@@ -83,5 +86,21 @@ def check_config_keys_and_values(service_config: dict) -> None:
8386 implemented_services .append (service_config ['name' ])
8487
8588
89+ proto_files = []
90+ for root , dirnames , filenames in os .walk (protos_folder ):
91+ for filename in fnmatch .filter (filenames , '*.proto' ):
92+ proto_files .append (os .path .join (root , filename ))
93+
94+ for proto_file in proto_files :
95+ with open (proto_file , 'r' ) as f :
96+ proto_file_text = f .read ()
97+ if 'service' not in proto_file_text :
98+ continue
99+
100+ service_name = re .search (r'service\s+(.+)\s*{' , proto_file_text ).group (1 ).strip ()
101+ if service_name not in implemented_services :
102+ raise Exception (f'{ service_name } is not added in stubs configs!' )
103+
104+
86105 print ('\n \n stubs configs file is valid ✅' )
87- exit (0 )
106+ exit (0 )
0 commit comments