@@ -59,23 +59,21 @@ def filter_test_files(
5959 changed_files_map : Dict [str , str ],
6060 test_keywords : List [str ]
6161) -> Dict [str , str ]:
62- """
63- Filters out test files from the map of changed files.
64- """
62+ """Filters out test files from the map of changed files."""
6563 logging .info ("🔬 Filtering out test files from the review scope..." )
6664
6765 files_for_review_map = {}
66+ test_keywords_set = set (test_keywords )
67+
6868 for path , diff in changed_files_map .items ():
69- is_test_file = any (
70- keyword in part .lower ()
71- for keyword in test_keywords
72- for part in os .path .normpath (path ).split (os .sep )
73- )
69+
70+ path_parts = {part .lower () for part in os .path .normpath (path ).split (os .sep )}
7471
75- if not is_test_file :
72+ if not path_parts . intersection ( test_keywords_set ) :
7673 files_for_review_map [path ] = diff
7774 else :
78- logging .info (f" - Ignoring test file based on keywords: { path } " )
75+ logging .info (f" - Ignoring test file based on exact keyword match: { path } " )
76+
7977
8078 return files_for_review_map
8179
@@ -209,8 +207,19 @@ def review(
209207 test_keywords = filtering_config .get ('test_keywords' , ['test' , 'spec' ])
210208 changed_files_map = filter_test_files (changed_files_map , test_keywords )
211209
210+ is_bitbucket_pr = "BITBUCKET_PR_ID" in os .environ
211+ is_github_pr = "GITHUB_ACTIONS" in os .environ and "GITHUB_PR_NUMBER" in os .environ
212+
212213 if not changed_files_map :
213- logging .info ("✅ No non-test files to review after filtering." )
214+ logging .info ("✅ No non-test files to review after filtering. Changes were likely only in test files." )
215+
216+ if is_bitbucket_pr :
217+ logging .info ("🚀 Publishing results to Bitbucket PR..." )
218+ bitbucket_client .cleanup_and_post_all_comments ([], {})
219+ elif is_github_pr :
220+ logging .info ("🚀 Publishing results to GitHub PR..." )
221+ github_client .handle_pr_results ([], {})
222+
214223 raise typer .Exit ()
215224
216225 changed_files_content = {
0 commit comments