@@ -168,13 +168,23 @@ def make_integration_test_description(task_def: dict[str, Any], additional_depen
168168 return taskdesc
169169
170170
171- def create_decision_task (repo_url : str , repo_name : str , branch : str ) -> dict [str , Any ]:
171+ def create_decision_task (decision ) -> dict [str , Any ]:
172+ repo_url = decision ["repo" ]
173+ branch = decision ["branch" ]
174+ repo_name = decision ["project" ]
175+
176+ r = requests .get (f"{ repo_url } /raw/{ branch } /.taskcluster.yml" )
177+ r .raise_for_status ()
178+ tcyml = yaml .safe_load (r .text )
179+
172180 context = {
181+ "tasks_for" : "github-push" ,
173182 "event" : {
174183 # branch isn't technically accurate here...but it's good enough
175184 "after" : branch ,
176185 "before" : branch ,
177- "ref" : branch ,
186+ "base_ref" : None ,
187+ "ref" : f"refs/heads/{ branch } " ,
178188 "repository" : {
179189 "html_url" : repo_url ,
180190 "name" : repo_name ,
@@ -184,11 +194,12 @@ def create_decision_task(repo_url: str, repo_name: str, branch: str) -> dict[str
184194 "email" : "no one" ,
185195 },
186196 },
197+ "as_slugid" : lambda _ : "nothing" ,
187198 }
188- return {}
199+ return jsone . render ( tcyml , context )[ "tasks" ][ 0 ]
189200
190201
191- def create_action_task (action : dict ):
202+ def create_action_task (action : dict ) -> dict [ str , Any ] :
192203 """Creates an action task specified by the inputs given. This necessarily
193204 creates a decision task as well, because action tasks depend on them at
194205 runtime."""
@@ -199,32 +210,28 @@ def create_action_task(action: dict):
199210 name = action .pop ("name" )
200211 perm = action .pop ("perm" )
201212 action_input = action .pop ("input" )
202- # TODO: we need a fake decision task, and for this to point at that
203- # because we need to pull parameters.yml and probably other things
204-
205- decision_taskdef = create_decision_task (repo , project , branch )
206- yield decision_taskdef
207-
208- taskid = decision_taskdef ["taskId" ]
209213
210214 r = requests .get (f"{ repo } /raw/{ branch } /.taskcluster.yml" )
211215 r .raise_for_status ()
212216 tcyml = yaml .safe_load (r .text )
213217
218+ # probably need to use task reference for this...maybe just put the <label> here and then wrap the entire damn thing in task-reference?
219+ decision_taskid = "nothing"
220+
214221 context = {
215222 "tasks_for" : "action" ,
216223 "repository" : {
217224 "url" : repo ,
218225 "project" : project ,
219226 },
220227 "push" : {
221- "branch" : branch ,
228+ "branch" : f"refs/heads/ { branch } " ,
222229 "revision" : branch ,
223230 },
224- "ownTaskId" : taskid ,
225- "taskId" : taskid ,
231+ "ownTaskId" : decision_taskid ,
232+ "taskId" : decision_taskid ,
226233 "action" : {
227- "taskGroupId" : taskid ,
234+ "taskGroupId" : decision_taskid ,
228235 "title" : name ,
229236 "cb_name" : name ,
230237 "name" : name ,
@@ -236,7 +243,7 @@ def create_action_task(action: dict):
236243 "input" : action_input ,
237244 }
238245
239- yield jsone .render (tcyml , context )["tasks" ]
246+ return jsone .render (tcyml , context )["tasks" ][ 0 ]
240247
241248
242249@transforms .add
@@ -259,8 +266,16 @@ def schedule_tasks_at_index(config, tasks):
259266 continue
260267
261268 yield make_integration_test_description (task_def )
269+ if "decision" in task :
270+ decision = task .pop ("decision" )
271+ taskdef = create_decision_task (decision )
272+ # keep the original name to allow other tasks to reference it
273+ taskdef ["metadata" ]["name" ] = f"{ config .kind } -{ task ['name' ]} "
274+ yield make_integration_test_description (taskdef )
275+
262276 if "action" in task :
263- for task_def in create_action_task (task .pop ("action" )):
264- from pprint import pprint
265- pprint (task_def )
266- yield make_integration_test_description (task_def )
277+ action = task .pop ("action" )
278+ taskdef = create_action_task (action )
279+ # keep the original name to allow other tasks to reference it
280+ taskdef ["metadata" ]["name" ] = f"{ config .kind } -{ task ['name' ]} "
281+ yield make_integration_test_description (taskdef , action ["depends" ])
0 commit comments