@@ -81,11 +81,12 @@ def use_sourcegraph_api(
81
81
headers = {"Content-Type" : "application/json" }
82
82
params = {
83
83
"q" : (
84
- "('self-hosted' OR "
85
- "(/runs-on/ AND NOT "
84
+ "context:global "
85
+ "self-hosted OR "
86
+ "(runs-on AND NOT "
86
87
"/(ubuntu-16.04|ubuntu-18.04|ubuntu-20.04|ubuntu-22.04|ubuntu-latest|"
87
88
"windows-2019|windows-2022|windows-latest|macos-11|macos-12|macos-13|"
88
- "macos-12-xl|macos-13-xl|macos-latest|matrix.[a-zA-Z] \\ s)/) ) "
89
+ "macos-12-xl|macos-13-xl|macos-latest)/ ) "
89
90
f"{ repo_filter } "
90
91
"lang:YAML file:.github/workflows/ count:30000"
91
92
)
@@ -107,13 +108,24 @@ def use_sourcegraph_api(
107
108
if line and line .decode ().startswith ("data:" ):
108
109
json_line = line .decode ().replace ("data:" , "" ).strip ()
109
110
event = json .loads (json_line )
111
+
112
+ if "title" in event and event ["title" ] == "Unable To Process Query" :
113
+ Output .error ("SourceGraph was unable to process the query!" )
114
+ Output .error (f"Error: { Output .bright (event ['description' ])} " )
115
+ return False
116
+
110
117
for element in event :
111
118
if "repository" in element :
112
119
results .add (
113
120
element ["repository" ].replace ("github.com/" , "" )
114
121
)
122
+ else :
123
+ Output .error (
124
+ f"SourceGraph returned an error: { Output .bright (response .status_code )} "
125
+ )
126
+ return False
115
127
116
- return results
128
+ return sorted ( results )
117
129
118
130
def use_search_api (self , organization : str , query = None ):
119
131
"""Utilize GitHub Code Search API to try and identify repositories
@@ -153,7 +165,7 @@ def use_search_api(self, organization: str, query=None):
153
165
organization , custom_query = query
154
166
)
155
167
156
- return candidates
168
+ return sorted ( candidates )
157
169
158
170
def present_results (self , results , output_text = None ):
159
171
"""
0 commit comments